No BSD License  

Highlights from
Alternative Mathematics using MATLAB 7

image thumbnail

Alternative Mathematics using MATLAB 7

by

 

13 Mar 2003 (Updated )

Self-instructive text on undergraduate algebra, statistics, differential and integral calculus.

ex192a.m
% ex192a.m:  Euler's Numerical Solution for dy/dx=-y, Comparison clear all
F=inline('-Y', 'X', 'Y');
X(1)=input('x1=  (e.g. 0) ');  Y(1)=input('y1=  (e.g. 3) ');
n=400;  h=0.01;
for i=1:n
   dy= F( X(i), Y(i))*h;
   X(i+1)=X(i)+h;
   Y(i+1)=Y(i)+dy;
end
figure(1),  plot(X,Y, 'r'),  grid on,  axis([0 n*h 0 3])	
Y_ex=Y(1)*exp(X(1)-X);   		                                           
figure(2),  plot(X, Y-Y_ex),  grid on,  title('Error')


Contact us