# P19_1 - c ErrorCOH2 = ((true - centerOH4)/true)*100 E...

This preview shows page 1. Sign up to view the full content.

function P19_1 f x = pi/4; x h = pi/12; h true = -sin(x); t forwardOH = (f(x+h) - f(x))/h f ErrorFOH = ((true - forwardOH)/true)*100 E forwardOH2 = (-f(x+2*h) + 4*f(x+h) - 3*f(x))/(2*h) f ErrorFOH2 = ((true - forwardOH2)/true)*100 E backwardOH = (f(x) - f(x-h))/h b ErrorBOH = ((true - backwardOH)/true)*100 E backwardOH2 = (3*f(x) - 4*f(x-h) + f(x-2*h))/(2*h) b ErrorBOH2 = ((true - backwardOH2)/true)*100 E centerOH2 = (f(x+h) - f(x-h))/(2*h) c ErrorCOH = ((true - centerOH2)/true)*100 E centerOH4 = (-f(x+2*h) + 8*f(x+h) - 8*f(x-h) + f(x-2*h))/(12*h)
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: c ErrorCOH2 = ((true - centerOH4)/true)*100 E fprintf(' first-order second-order\n') fprintf('forward %11.8f %11.8f\n', forwardOH, forwardOH2) fprintf(' %7.3f %6.3f\n', ErrorFOH, ErrorFOH2) fprintf('backward %11.8f %11.8f\n', backwardOH, backwardOH2) fprintf(' %6.3f %6.3f\n', ErrorBOH, ErrorBOH2) fprintf('centered %11.8f %11.8f\n', backwarOH, backwardOH2) f function new = f(x) f new = cos(x); n...
View Full Document

## This note was uploaded on 09/21/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Spring '09 term at University of Florida.

Ask a homework question - tutors are online