No BSD License  

Highlights from
Alternative Mathematics using MATLAB 7

image thumbnail

Alternative Mathematics using MATLAB 7



13 Mar 2003 (Updated )

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

% ex193a.m:  Euler's Solution Verified				 
clear all
F= inline('1+ X.^3- X.^2.*Y', 'X', 'Y');
X(1)=input('x1=  (e.g. 0) ');  Y(1)=input('y1=  (e.g. 2) ');
n=300;  h=0.01;
for i=1:n
   dy=F( X(i), Y(i))*h;
figure(1),   plot(X,X, 'b',  X,Y),  grid on,  axis([0 n*h 0 3]),  hold on	
   title('Solution to dy/dx+x^2*y=1+x^3')
% Add direction field to figure(1) for comparison
xmax=4;  delx=xmax/30;  
ymax=3;  dely=ymax/30;	
[Xm,Ym]=meshgrid(0:delx:xmax, 0:dely:ymax);
Dx=Xm-Xm+1;				% Unit x-components of arrows
Dy=F(Xm,Ym);				% Compute y-components
L=sqrt(Dx.^2+ Dy.^2);			% Initial length of [Dx Dy]
L=L+1e-10;					% Add small number to avoid L=0
Dx1=Dx./L;  Dy1=Dy./L;		% Unit length for all arrows
figure(1),  quiver(Xm,Ym,  Dx1,Dy1, 'g.'),  grid on,  hold off	
Yex=(Y(1)-X(1)).*exp( X(1).^3/3- X.^3/3)+X;
figure(2),  plot(X,Y-Yex),  grid on,  title('Solution Error')

Contact us