hw2_solutions

# hw2_solutions - MAE 107 Computational Methods in...

This preview shows pages 1–4. Sign up to view the full content.

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

View Full Document

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: MAE 107 Computational Methods in Engineering Spring 2007 Homework #2 Solutions Problem 1: Problem 4.7 on page 110 of the textbook. The function (correcting a typographical error in the text) ( ) 2 3 1 1 ) ( x x f − = has the derivative ( ) 2 2 3 1 6 ) ( x x x f − = ′ Evaluating this derivative at x = 0.577 using double precision arithmetic, rounded to the nearest integer 911 , 352 , 2 ) 577 . ( = ′ f Since the denominator is close to zero, we expect problems with subtractive cancellation when using limited precision arithmetic. Using three-digit arithmetic with chopping (normalized base 10): ( ) 000 , 216 10 216 . 10 160 . 10 346 . ) 577 . ( 10 160 . 3 1 10 400 . 3 1 10 996 . 3 10 332 . 10 346 . 6 6 4 1 4 2 2 2 2 2 2 1 = × = × × = ′ × = − × = − × = × = × = − − − f x x x x x In this case, the relative error is % 8 . 90 or 908 . 911 , 352 , 2 000 , 216 911 , 352 , 2 = − = ε Using four-digit arithmetic with chopping (normalized base 10): ( ) 000 , 048 , 2 10 2048 . 10 1690 . 10 3462 . ) 577 . ( 10 1690 . 3 1 10 1300 . 3 1 10 9987 . 3 10 3329 . 10 3462 . 6 7 4 1 5 2 2 2 2 2 2 1 = × = × × = ′ × = − × = − × = × = × = − − − f x x x x x And in this case the relative error is % 96 . 12 or 1296 . 911 , 352 , 2 000 , 048 , 2 911 , 352 , 2 = − = ε Problem 2 : Problem 4.13 on page 110 of the textbook. Equation (4.11) on page 94 of the textbook is 2 1 1 1 ) )( ( ! 2 1 ) )( ( ) ( ) ( i i i i i i i i x x x f x x x f x f x f − ′ ′ + − ′ + = + + + and for the function c bx ax x f + + = 2 ) ( we have a x f b ax x f 2 ) ( 2 ) ( = ′ ′ + = ′ . Therefore, equation (4.11) becomes c bx ax ax x ax ax bx bx ax x ax c bx ax x x a x x b ax c bx ax x f i i i i i i i i i i i i i i i i i i i i i + + = + − + − + − + + + = − + − + + + + = + + + + + + + + + 1 2 1 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2 2 ) ( ! 2 2 ) )( 2 ( ) ( MAE 107 Spring 2007 HW 2 Problem 3 Contents bisect.m Define f(x), and plot it Use bisect.m to compute root of f(x) Use a smaller interval to see if number of iterations is reduced bisect.m type bisect.m % Function to find the root of function 'f' near between [x1, x2] % using bisection method function xm = bisect(f, x1, x2) itmax = 100; % set maximum number of iterations accuracy = 1e-4; % set required accuracy prev_xm = NaN; % used for computing estimated error disp(sprintf('Desired accuracy = %e\n', accuracy)); for iter = 1:itmax % calculate midpoint of dcurrent domain xm = (x1 + x2) / 2; disp( sprintf(... 'Iter#=%2d, x-range=(%+6.4f,%+6.4f), xm=%+8.6f, f(xm)=%+8.6e, Estim error=%+6.4e', ......
View Full Document

{[ snackBarMessage ]}

### Page1 / 9

hw2_solutions - MAE 107 Computational Methods in...

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

View Full Document
Ask a homework question - tutors are online