%
% Transcript of session January 16, 2002 AM261b
%
 
>> xk = 1234567890233456789;
>> xk = 1234567890233456789

xk =

  1.2346e+018

>> format long
>> xk

xk =

    1.234567890233457e+018

>> xkp1 = 1234567890234567899

xkp1 =

    1.234567890234568e+018

>> xk-xkp1

ans =

    -1111040

>> (xkp1-xk)/xk

ans =

    8.999424080192967e-013

>> seciter1 = inline( '((sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))','x1','x2') )
??? seciter1 = inline( '((sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))','x1','x2') )
                                                                                 |
Error: Missing operator, comma, or semicolon.

>> seciter1 = inline( '((sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))','x1','x2') ))
??? seciter1 = inline( '((sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))','x1','x2') ))
                                                                                 |
Error: Missing operator, comma, or semicolon.

>> seciter1 = inline( '(sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))','x1','x2') 

seciter1 =

     Inline function:
     seciter1(x1,x2) = (sin(x1)*x2 - sin(x2)*x1)/(sin(x1)-sin(x2))

>> x0 = 3

x0 =

     3

>> x1 = 3.1

x1 =

   3.10000000000000

>> x2 = seciter1(x0,x1)

x2 =

   3.14177309200854

>> x3 = seciter1(x1,x2)

x3 =

   3.14159260178022

>> x4 = seciter1(x2,x3)

x4 =

   3.14159265358979

>> x5 = seciter1(x3,x4)

x5 =

   3.14159265358979

>> x5 = seciter1(x4,x5)

x5 =

   3.14159265358979

>> x5 = seciter1(x3,x4)

x5 =

   3.14159265358979

>> x6 = seciter1(x4,x5)

x6 =

   3.14159265358979

>> x7 = seciter1(x5,x6)
Warning: Divide by zero.
> In C:\MATLAB6p1\toolbox\matlab\funfun\inlineeval.m at line 13
  In C:\MATLAB6p1\toolbox\matlab\funfun\@inline\subsref.m at line 25

x7 =

   NaN

>> sin(x6)-sin(x5)

ans =

     0

>> x5*sin(x6)-x6*sin(x5)

ans =

     0

>> f = inline( 'x-x^(1/3)-2', 'x' )

f =

     Inline function:
     f(x) = x-x^(1/3)-2

>> seciter2 = inline( 'x2 - f(x2).*(x2-x1)./(f(x2)-f(x1))', x1, x2 )
Warning: Subscript indices must be integer values.
> In C:\MATLAB6p1\toolbox\matlab\funfun\@inline\display.m at line 19

seciter2 =

     Inline function:
     seciter2(x,P1,P2,P3) = x2 - f(x2).*(x2-x1)./(f(x2)-f(x1))

>> f(4)

ans =

   0.41259894803180

>> f(3)

ans =

  -0.44224957030741

>> x0 = 4

x0 =

     4

>> x1 = 3

x1 =

     3

>> seciter2 = inline( 'x2 - f(x2).*(x2-x1)./(f(x2)-f(x1))', 'x1', 'x2' )

seciter2 =

     Inline function:
     seciter2(x1,x2) = x2 - f(x2).*(x2-x1)./(f(x2)-f(x1))

>> x2 = seciter2( x0, x1 )
??? Error using ==> inlineeval
Error in inline expression ==> x2 - f(x2).*(x2-x1)./(f(x2)-f(x1))
??? Undefined function or variable 'f'.

Error in ==> C:\MATLAB6p1\toolbox\matlab\funfun\@inline\subsref.m
On line 25  ==>     INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

>> f(4)

ans =

   0.41259894803180

>> help seciter2

  f = inline( 'x-x^(1/3)-2', 'x' )

>> help seciter2

  Secant method example
  f = inline( 'x-x^(1/3)-2', 'x' )

>> seciter2( 4, 3 )
??? Input argument 'f1' is undefined.

Error in ==> C:\Data\courses\am261b\seciter2.m
On line 4  ==> x2 = x1 - f1.*(x1-x0)./(f1-f0);

>> seciter2( 4, 3, f(4), f(3) )

ans =

   3.51734261780860

>> seciter2( 4, 3, f(4), f(3) )

ans =

   3.51734261780860

>> [x2,f2] = seciter2( 4, 3, f(4), f(3) )

x2 =

   3.51734261780860


f2 =

  -0.00345547095352

>> [x3,f3] = seciter2( 3, x2, f(3), f2 )

x3 =

   3.52141665251300


f3 =

    3.162504256248866e-005

>> clear
>> x = linspace( -10, 10, 101);
>> y = atan(x);
>> plot( x, y )
>> x = linspace( -1, 1, 101);
>> y = x.^2 - 0.1;
>> plot( x, y )
>> grid
>> y = x.^2 - 0.0001;
>> plot( x, y )
>> grid
>> 