Review Part 1

Review Part 1 - Review of Part I Methods and Formulas...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 n-th 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 < ( 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: > v = [0 1 2 3] ...........................................................Make a row vector. > u = [0; 1; 2; 3] ....................................................Make a column vector. > w = v .............................................. Transpose: row vector column vector > x = linspace(0,1,11) ...........................Make an evenly spaced vector of length 11. > x = -1:.1:1 ............................. Make an evenly spaced vector, with increments 0 . 1. > y = x.^2 .................................................................. Square all entries. > plot(x,y) ..................................................................... plot y vs. x. > f = inline(2*x.^2 - 3*x + 1,x) ...................................Make a function. > y = f(x) ....................................................A function can act on a vector. > plot(x,y,*,red) ...................................................A plot with options. > Control-c ............................................................ 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 <= 20 S = S + i; i = i + 1; end if ... else ... end Example: if c*y>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.

Page1 / 11

Review Part 1 - Review of Part I Methods and Formulas...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online