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.

ex134.m
% ex134.m:  Plot Second-Order Derivative   
clear all
X=0:0.01:10;  Y=xcos(X);
h=1e-4;					 	% Fixed increment
Der=(xcos(X+h)- xcos(X-h))/(2*h);		% Symmetric quotient
Der2=(xcos(X+h)-2*xcos(X)+xcos(X-h))/h^2;		% d2f/dx2
figure(1),  plot(X,Y,  X,Der,  X,Der2),  grid on,  xlabel('x') 
   legend('f=x*cos(x)', 'df/dx', 'd2f/dx2')
D2ex=-sin(X)- sin(X)- X.*cos(X);	% Exact d2f/dx2
figure(2),  plot(X,Der2,  X,D2ex),  grid on
   legend('d2f/dx2', 'exact')
figure(3),  plot(X,Der2-D2ex),  grid on,  title('Error in d2f/dx2')

Contact us