%
% - File name : nonlin_onevar_2.m (Generated by Hee Jung : fall/1999)
% - Solve a nonlinear equation of one variable 
% - Example problem : solve   0.1*e^(x) + sin(x) -5 = x  for x.
% - Method 2 : Express equations in homogeneous form (i.e. f(x)=0) and use
%              'fzero' function 
%            : type help fzero for the further information on this command
%
clear   % removes all variables from the workspace

% Define function f(x)
f = inline('0.1*exp(x) + sin(x) -5 - x');

% Find x using fzero 
% syntax of fzero :  x = fzero(fun,x0).
%                 :  fzero will try to find solution near x0

% you type :
x = fzero(f,5)
% you'll get : 
%   Zero found in the interval: [4.6, 5.2828].
%   x = 4.6699

% you type :
x = fzero(f,0)
% you'll get : 
%   Zero found in the interval: [-5.12, 3.6204].
%   x = -4.1516

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Note : nonlinear equations can have multiple solutions. So the 
%        solutions found by fzero can be different with a different x0.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


