amath 352 hw 1 - AMATH 352 HW1 1. a) b) f = @(x) x .*...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
If the error becomes zero for some choice of tol, then the exact accuracy of the calculus answer has been reached. 3.a)
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 04/14/2008 for the course AMATH 352 taught by Professor Leveque during the Winter '07 term at University of Washington.

Page1 / 5

amath 352 hw 1 - AMATH 352 HW1 1. a) b) f = @(x) x .*...

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