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.

% ex154.m:  Improper Integral of a Gaussian					         
clear all,  format long
h=0.01;  		         		% Length of sub-intervals
x1=0;  		         		% First Simpson coordinate
sumi=0;  i=0;  			% Reset sumi and index		
while 1==1 				% Forever
   i=i+1;				% Step up index
   x2=x1+h;  x3=x1+2*h;  	% Simpson coordinates
   sumi=sumi+term;		% Sum of areas
   X(i)=x3;				% Coordinate for plot of integral
   Int(i)=sumi*h/3;		% Store integral as vector element
   if abs(term/sumi)<1e-14,  break,  end
   x1=x1+2*h;			% Prepare x1 for next turn
end					% End of loop
figure(1),  plot(X,Int),  grid on,  xlabel('x'),  ylabel('integral')
i					% Number of loops used
integrals=[Int(i)  sqrt(pi)/2]	% Comparison to exact
format short e,  error=Int(i)-sqrt(pi)/2

Contact us