amath 352 hw 1

# amath 352 hw 1 - AMATH 352 HW1 1 a b f =(x x cos(x f=(x x...

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

AMATH 352 HW1 1. a) b) f = @(x) x .* cos(x) f = @(x) x .* cos(x) quad(f, 0, 1) ans = 3.817732902243389e-001 2. From script prob2.m : true = .381773291; f = @(x) x .* cos(x); sprintf( '%-10s %-23s %-15s %-8s' , 'tol' , 'integral' , 'error' , 'f evals' ) for tol=logspace(-8, -15, 8) [integral, fcnt] = quad(f, 0, 1, tol); error = abs(integral-true); stuff = sprintf( '%-10.3e %-23.15e %-15.5e %-8d' , tol, integral, error, fcnt); disp(stuff) end From command window: prob2 ans = tol integral error f evals 1.000e-008 3.817732906689939e-001 3.31006e-010 33 1.000e-009 3.817732906750480e-001 3.24952e-010 53 1.000e-010 3.817732906759953e-001 3.24005e-010 81 1.000e-011 3.817732906760337e-001 3.23966e-010 125 1.000e-012 3.817732906760359e-001 3.23964e-010 197 1.000e-013 3.817732906760362e-001 3.23964e-010 313 1.000e-014 3.817732906760363e-001 3.23964e-010 497 1.000e-015 3.817732906760363e-001 3.23964e-010 781

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

View Full Document
If the error becomes zero for some choice of tol, then the exact accuracy of the calculus answer has been reached. 3.a) newtonsqrt What number do you want to find the square root of? 2 What is your starting guess? 3 iteration approximation 1 1.833333333333333e+000 2 1.462121212121212e+000 3 1.414998429894803e+000 4 1.414213780047198e+000 5 1.414213562373112e+000 For comparison, sqrt(2) = 1.414213562373095e+000 b) newtonsqrt What number do you want to find the square root of? 2 What is your starting guess?

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.

{[ 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