diary erg3
my_exp(1,5)
{Error: <a href="matlab: opentoline('G:\ce213\matlab\lab3\my_exp.m',4,7)">File: my_exp.m Line: 4 Column: 7</a>
Unexpected MATLAB expression.
} 
my_exp(1,5)

ans =

    1.7167

help taylor
 --- help for sym/taylor ---

  <strong>taylor</strong>(f) is the fifth order Taylor polynomial approximation
        of f about the point x=0 (also known as fifth order
        Maclaurin polynomial), where x is obtained via symvar(f,1).
 
  <strong>taylor</strong>(f,x) is the fifth order Taylor polynomial approximation
        of f with respect to x about x=0. x can be a vector.
        In case x is a vector, multivariate expansion about x(1)=0,
        x(2)=0,... is used.
 
  <strong>taylor</strong>(f,x,a) is the fifth order Taylor polynomial approximation
        of f with respect to x about the point a. x and a can be
        vectors. If x is a vector and a is scalar, then a is
        expanded into a vector of the same size as x with all
        components equal to a. If x and a both are vectors, then
        they must have same length.
        In case x and a are vectors, multivariate expansion about
        x(1)=a(1),x(2)=a(2),... is used.
 
  In addition to that, the calls
 
    <strong>taylor</strong>(f,'PARAM1',val1,'PARAM2',val2,...)
    <strong>taylor</strong>(f,x,'PARAM1',val1,'PARAM2',val2,...)
    <strong>taylor</strong>(f,x,a,'PARAM1',val1,'PARAM2',val2,...)
 
  can be used to specify one or more of the following parameter
  name/value pairs:
 
    Parameter        Value
 
    'ExpansionPoint' Compute the Taylor polynomial approximation
                     about the point a. a can be a vector. If x is a
                     vector, then a has to be of the same length as x.
                     If a is scalar and x is a vector, a is expanded into
                     a vector of the same length as x with all components
                     equal to a. Note that if x is not given as in
                     taylor(f,'ExpansionPoint',a), then a must be
                     scalar (since x is determined via symvar(f,1)).
                     It is always possible to specify the expansion
                     point as third argument without explicitly using
                     a parameter value pair.
 
    'Order'          Compute the Taylor polynomial approximation with
                     order n-1, where n has to be a positive integer. The
                     default value n=6 is used.
 
    'OrderMode'      Compute the Taylor polynomial approximation using
                     relative or absolute order. 'Absolute' order is the
                     truncation order of the computed series. 'Relative'
                     order n means the exponents of x in the computed
                     series range from some leading order v to the highest
                     exponent v + n - 1 (i.e., the exponent of x in the
                     Big-Oh term is v + n). In this case, n essentially
                     is the "number of x powers" in the computed series
                     if the series involves all integer powers of x
 
    Examples:
       syms x y z;
 
       taylor(exp(-x))
       returns  x^4/24 - x^5/120 - x^3/6 + x^2/2 - x + 1
 
       taylor(sin(x),x,pi/2,'Order',6)
       returns  (pi/2 - x)^4/24 - (pi/2 - x)^2/2 + 1
 
       taylor(sin(x)*cos(y)*exp(x),[x y z],[0 0 0],'Order',4)
       returns  x - (x*y^2)/2 + x^2 + x^3/3
 
       taylor(exp(-x),x,'OrderMode','Relative','Order',8)
       returns  - x^7/5040 + x^6/720 - x^5/120 + x^4/24 - x^3/6 + ...
                x^2/2 - x + 1
 
       taylor(log(x),x,'ExpansionPoint',1,'Order',4)
       returns  x - 1 - 1/2*(x - 1)^2 + 1/3*(x - 1)^3
 
       taylor([exp(x),cos(y)],[x,y],'ExpansionPoint',[1 1],'Order',4)
       returns  exp(1) + exp(1)*(x - 1) + (exp(1)*(x - 1)^2)/2 + ...
               (exp(1)*(x - 1)^3)/6'), cos(1) + (sin(1)*(y - 1)^3)/6 - ...
                sin(1)*(y - 1) - (cos(1)*(y - 1)^2)/2
 
       taylor(exp(z)/(x - y),[x,y,z],'ExpansionPoint',[Inf,0,0], ...
              'OrderMode','Absolute','Order',6)
       returns  y^2/x^3 + z^2/(2*x) + z^3/(6*x) + z^4/(24*x) + y/x^2 + ...
                z/x + 1/x + (y*z)/x^2 + (y*z^2)/(2*x^2)
 
    See also <a href="matlab:help sym/symvar">sym/symvar</a>, <a href="matlab:help sym/symsum">sym/symsum</a>, <a href="matlab:help sym/diff">sym/diff</a>.

help sym/symvar
 <strong>symvar</strong> Finds the symbolic variables in a symbolic expression or matrix.
     <strong>symvar</strong>(S), where S is a scalar or matrix sym, returns a vector sym 
     containing all of the symbolic variables appearing in S. The 
     variables are returned in lexicographical order. If no symbolic variables
     are found, <strong>symvar</strong> returns the empty vector. 
     The constants pi, i and j are not considered variables.
  
     <strong>symvar</strong>(S,N) returns the N symbolic variables closest to 'x' or 'X'. 
     Upper-case variables are returned ahead of lower-case variables.
     If S is a symbolic function the inputs to S are listed in front of the
     other free variables.
  
     Examples:
        symvar(alpha+a+b) returns
         [a, alpha, b]
  
        symvar(cos(alpha)*b*x1 + 14*y,2) returns
         [x1, y]
  
        symvar(y*(4+3*i) + 6*j) returns
         y

my_exp(1,5)

s =

    1.5000


s =

    1.6667


s =

    1.7083


s =

    1.7167


ans =

    1.7167

my_exp
{Error using <a href="matlab:helpUtils.errorDocCallback('my_exp', 'G:\ce213\matlab\lab3\my_exp.m', 4)" style="font-weight:bold">my_exp</a> (<a href="matlab: opentoline('G:\ce213\matlab\lab3\my_exp.m',4,0)">line 4</a>)
Not enough input arguments.
} 
my_exp(1,5)

s =

     2


s =

    2.5000


s =

    2.6667


s =

    2.7083


s =

    2.7167


ans =

    2.7167

1 + 1 + 1/2 + 1/1*2*3 + 1/1*2*3*4 + 1/1*2*3*4*5

ans =

  152.5000

1 + 1 + 1/2 + 1/(1*2*3) + 1/(1*2*3*4) + 1/(1*2*3*4*5)

ans =

    2.7167

x= 100

x =

   100

n= 50

n =

    50

exp_x = my_exp(x,n)

s =

   101


s =

        5101


s =

   1.7177e+05


s =

   4.3384e+06


s =

   8.7672e+07


s =

   1.4766e+09


s =

   2.1318e+10


s =

   2.6933e+11


s =

   3.0251e+12


s =

   3.0582e+13


s =

   2.8110e+14


s =

   2.3688e+15


s =

   1.8428e+16


s =

   1.3314e+17


s =

   8.9785e+17


s =

   5.6773e+18


s =

   3.3792e+19


s =

   1.8998e+20


s =

   1.0120e+21


s =

   5.1224e+21


s =

   2.4695e+22


s =

   1.1366e+23


s =

   5.0048e+23


s =

   2.1122e+24


s =

   8.5592e+24


s =

   3.3355e+25


s =

   1.2519e+26


s =

   4.5318e+26


s =

   1.5842e+27


s =

   5.3542e+27


s =

   1.7515e+28


s =

   5.5519e+28


s =

   1.7068e+29


s =

   5.0940e+29


s =

   1.4772e+30


s =

   4.1654e+30


s =

   1.1431e+31


s =

   3.0550e+31


s =

   7.9575e+31


s =

   2.0214e+32


s =

   5.0107e+32


s =

   1.2128e+33


s =

   2.8680e+33


s =

   6.6299e+33


s =

   1.4990e+34


s =

   3.3163e+34


s =

   7.1829e+34


s =

   1.5238e+35


s =

   3.1678e+35


s =

   6.4558e+35


exp_x =

   6.4558e+35

x= 100

x =

   100

n= 50

n =

    50

exp_x = my_exp(x,n)

exp_x =

   6.4558e+35

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

  156.3031

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

  156.3031

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

  156.3031

clc
erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

  156.3031

my_exp(100,50)

ans =

   6.4558e+35

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

   4.9203e-07

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

   4.9203e-07

erg3

x =

   100


n =

    50


exp_x =

   6.4558e+35


y =

  -100


exp_y =

   2.1871e+35


ans =

   1.5490e-36


error =

   4.9203e-07

diary off
