This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Review of Part I Methods and Formulas Solving equations numerically: f ( x ) = 0 an equation we wish to solve. x a true solution. x starting approximation. x n approximation after n steps. e n = x n x error of nth step. r n = y n = f ( x n ) residual at step n . Often  r n  is sufficient. Newtons method: x i +1 = x i f ( x i ) f ( x i ) Bisection method: f ( a ) and f ( b ) must have different signs. x = ( a + b ) / 2 Choose a = x or b = x , depending on signs. x is always inside [ a,b ]. e &lt; ( b a ) / 2, current maximum error. Secant method*: x i +1 = x i x i x i 1 y i y i 1 y i Regula Falsi*: x = b b a f ( b ) f ( a ) f ( b ) Choose a = x or b = x , depending on signs. Convergence: Bisection is very slow. Newton is very fast. Secant methods are intermediate in speed. Bisection and Regula Falsi never fail to converge. Newton and Secant can fail if x is not close to x . Locating roots: Use knowledge of the problem to begin with a reasonable domain. Systematically search for sign changes of f ( x ). Choose x between sign changes using bisection or secant. Usage: For Newtons method one must have formulas for f ( x ) and f ( x ). 23 24 LECTURE 7. SYMBOLIC COMPUTATIONS Secant methods are better for experiments and simulations. Matlab Commands: &gt; v = [0 1 2 3] ...........................................................Make a row vector. &gt; u = [0; 1; 2; 3] ....................................................Make a column vector. &gt; w = v .............................................. Transpose: row vector column vector &gt; x = linspace(0,1,11) ...........................Make an evenly spaced vector of length 11. &gt; x = 1:.1:1 ............................. Make an evenly spaced vector, with increments 0 . 1. &gt; y = x.^2 .................................................................. Square all entries. &gt; plot(x,y) ..................................................................... plot y vs. x. &gt; f = inline(2*x.^2  3*x + 1,x) ...................................Make a function. &gt; y = f(x) ....................................................A function can act on a vector. &gt; plot(x,y,*,red) ...................................................A plot with options. &gt; Controlc ............................................................ Stops a computation. Program structures: for ... end Example: for i=1:20 S = S + i; end if ... end Example: if y == 0 disp(An exact solution has been found) end while ... end Example: while i &lt;= 20 S = S + i; i = i + 1; end if ... else ... end Example: if c*y&gt;0 a = x; else b = x; end Function Programs: Begin with the word function ....
View
Full
Document
This note was uploaded on 01/15/2011 for the course MATH 345 taught by Professor Staff during the Spring '08 term at Ohio State.
 Spring '08
 Staff

Click to edit the document details