{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw15_solutions

# hw15_solutions - Section 3.2 2 5b 7 Section3.3 3a Use...

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

Section 3.2 2 5b 7

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

View Full Document
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)); % update x1 with newton method e = abs(x1 - x0);
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern