hw2_4

# hw2_4 - fx_12_p_ts(n-1) = ((fx_jm1/24) -

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

%Song, Hwan %AAE412 %HW2, No.4 % clear all close all clc c n = 2; %Initial Value set up f_prime = 2; f for n = 2:1:15 %Setting up steps delta_x(n-1) = 2^(-n); %Delta_x value at x = 0 in function f x_jm1 = -1.5*delta_x(n-1); %x(j-1) x_j = -.5*delta_x(n-1); %x(j) x_jp1 = .5*delta_x(n-1); %x(j+1) x_jp2 = 1.5*delta_x(n-1); %x(j+2) fx_jm1 = (sin(x_jm1 + sin(x_jm1)))/(1+log(1+tan(x_jm1))); %f(x) at x(j-1) fx_j = (sin(x_j+sin(x_j)))/(1+log(1+tan(x_j))); %f(x) at x(j) fx_jp1 = (sin(x_jp1 + sin(x_jp1)))/(1+log(1+tan(x_jp1))); %f(x) at x(j+1) fx_jp2 = (sin(x_jp2 + sin(x_jp2)))/(1+log(1+tan(x_jp2))); %f(x) at x(j+2) %Expression using Taylor Series
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fx_12_p_ts(n-1) = ((fx_jm1/24) - (9*fx_j/8)+(9*fx_jp1/8)-(fx_jp2/24))/ (delta_x(n-1)); %Expression using Central Difference fx_12_p_cd(n-1) = (fx_jp1-fx_j)/delta_x(n-1); %Error when Taylor series is used error_ts(n-1) = abs(fx_12_p_ts(n-1)-f_prime); %Error when Central Defference error_cd(n-1) = abs(fx_12_p_cd(n-1)-f_prime); end e loglog(delta_x,error_cd,'r') hold on; loglog(delta_x,error_ts,'b'); legend('Central Difference Error', 'Taylor Series Error') title('Error vs Delta x by Song, Hwan') xlabel('Delta x') ylabel('Error') grid on g...
View Full Document

## This document was uploaded on 10/24/2010.

Ask a homework question - tutors are online