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.

ex103.m
% ex103.m:  Find Zeros by Bisection				                 
clear all,  format long
f=inline('x^3- 2*x^2- x+2');								% Define function f(x)
figure(1),  fplot(f, [-2 3]),  grid on,  zoom on		% Plot survey
x1=input('x1= (e.g. 0.5)'); 				% Bracketing values
x2=input('x2= (e.g. 1.5)');			 
while 1==1													% Repeat forever   
   f1=f(x1);  f2=f(x2);
   x0=(x1+x2)/2;  f0=f(x0);     
   if f0*f1>0,  x1=x0;  else x2=x0;  end 			% Replace one value
   if abs(x2-x1)<1e-15,  break,  end					% Stop the loop
end															% Endpoint of loop
x0                   											% Display final value

Contact us