#+ -*- coding: iso-8859-1; -*- #+TITLE: Numerical methods with Octave #+AUTHOR: Eric S Fraga #+EMAIL: address@hidden #+DATE: 2010.10.10 18:54:55 * COMMENT Preamble :noexport: #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: #+XSLT: #+startup: beamer #+LaTeX_CLASS: beamer #+LaTeX_CLASS_OPTIONS: [bigger,t] #+BEAMER_FRAME_LEVEL: 2 #+latex_header: \definecolor{verylightgray}{rgb}{0.93,0.93,1.0} #+latex_header: \mode{\usetheme{progressbar}} #+latex_header: \mode{\usecolortheme[rgb={0.5,0.5,0.5}]{structure}\usetheme[secheader]{Boadilla}\usepackage{pgfpages}\pgfpagesuselayout{4 on 1}[a4paper,landscape,border shrink=5mm]} #+latex_header: \usepackage[absolute,overlay]{textpos}\setlength{\TPHorizModule}{1mm}\setlength{\TPVertModule}{1mm}\newcommand{\UCL}{\begin{textblock}{14}(120.0,0.0)\pgfuseimage{ucllogo}\end{textblock}} #+ latex_header: \AtBeginSection[]{\begin{frame}\frametitle{Topic}\tableofcontents[currentsection]\end{frame}} #+latex_header: \usepackage{algorithm} #+latex_header: \usepackage{algorithmic} %[noend] option possible #+latex_header: \renewcommand{\algorithmicrequire}{\textbf{Given:}} #+latex_header: \renewcommand{\algorithmicensure}{\textbf{Outputs:}} #+latex_header: \usepackage{alltt} #+latex_header: \usepackage{cancel} #+ ------------------------ COMMANDS ------------------------- #+latex_header: \newcommand{\D}{{\mbox{d}}} #+latex_header: \newcommand{\Diff}[2]{\frac{\D }{\D #2}#1} #+latex_header: \newcommand{\diff}[2]{\frac{\D #1}{\D #2}} #+latex_header: \newcommand{\HS}{\hspace*{1cm}} #+latex_header: \date{$Revision: 1.7 $}\renewcommand{\date}[1]{} #+ ------------------------ LISTINGS ------------------------- #+latex_header: \lstset{keywordstyle=\color{blue},commentstyle=\color{black!50!white},identifierstyle=\color{red!60!black}} #+COLUMNS: %20ITEM %13BEAMER_env(Env) %6BEAMER_envargs(Args) %4BEAMER_col(Col) %7BEAMER_extra(Extra) * Octave *** Newton's method ***** The code :BMCOL:B_block: :PROPERTIES: :BEAMER_col: 0.5 :BEAMER_env: block :END: #+source: newtons-method #+begin_src octave :exports both :results output f = @(x) x^2 - 2; df = @(x) 2*x; x = 2 % initial guess y = f(x) while abs(y)>1e-5 dy = df(x); x = x - y/dy y = f(x) end #+end_src ***** The output :BMCOL:B_block: :PROPERTIES: :BEAMER_col: 0.5 :BEAMER_env: block :BEAMER_envargs: <2-> :END: #+results: newtons-method : x = 2 : y = 2 : x = 1.5000 : y = 0.25000 : x = 1.4167 : y = 0.0069444 : x = 1.4142 : y = 6.0073e-06