% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; clc; clear; % Problem EPage 118 % % x y'' + 2 y' - x y = e^x with y(0) = 0.5 and y(2) = 3.694528 % n=10; x = linspace( 0, 2, n+1 ); C = x; D = 2 * ones( 1, n+1 ); E = - x; F = exp( x ); y_tp = twopoint(x,C,D,E,F,1,1,0.5,3.694528); plot( x, y_tp, '-r' ); hold('on'); xs = linspace( 0, 2, 100 ); ys = exp( xs )/2; plot( xs, ys, '-g' ); xlabel('x'); ylabel('y(x)'); legend( 'twopoint (n=10)', 'exact', 'location', 'best' ); %saveas( gcf, '../../WriteUp/Graphics/Chapter6/c_6_p_4_plot.eps', 'epsc' );