hw15_solutions

Hw15_solutions - Section 3.2 2 5b 7 Section3.3 3a Use Newton method to find the root of function f(x = 1-2*x*exp-x/2 The output is as below In

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

View Full Document Right Arrow Icon
Section 3.2 2 5b 7
Background image of page 1

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

View Full DocumentRight Arrow Icon
Section3.3 3a Use Newton method to find the root of function f(x) = 1-2*x*exp(-x/2). The output is as below In iteration 1, estimated x = 0.5, error is 0.5 In iteration 2, estimated x = 0.68935, error is 0.18935 In iteration 3, estimated x = 0.7144, error is 0.025049 In iteration 4, estimated x = 0.71481, error is 0.00040632 In iteration 5, estimated x = 0.71481, error is 1.0553e-007 After 5 iterations, the error is smaller than 10^-6 Bisection method needs more iteration to get this accuracy since it converges much slower. Matlab code is as below %% section 3.3 problem 3a % use newton method to solve an equation % f(x) = 1-2*x*exp(-x/2) % f'(x) = (x-2)*exp(-x/2) x0 = 0; % starting x eps = 10^(-6); % error accuracy needed x1 = x0 - 1/((x0-2)*exp(-x0/2))*(1-2*x0*exp(-x0/2)); % apply newton method e = abs(x1 - x0); % estimate error using |Xn - Xn+1| n = 1; % n is the counter which records the # of iterations disp([ 'in iteration ' ,num2str(n), ', estimated x = ' ,num2str(x1), ' error is ' ,num2str(e)]) while e >= eps % if the error is bigger than the accuracy x0 = x1; % update x0 x1 = x0 - 1/((x0-2)*exp(-x0/2))*(1-2*x0*exp(-x0/2));
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2012 for the course MAE 107 taught by Professor Rottman during the Spring '08 term at UCSD.

Page1 / 10

Hw15_solutions - Section 3.2 2 5b 7 Section3.3 3a Use Newton method to find the root of function f(x = 1-2*x*exp-x/2 The output is as below In

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