Matlab Symbolic Calculus Notes

Source: Internet
Author: User
Tags cos diff documentation sin

1. Symbol limit

Limits of Limit (f,x,a) on expression f,x-a
Limit (f,a) to the above function simplification, to the expression F, the default argument, a limit, the default argument here can be found through Findsym (f,1), is generally the most recent argument from the X-letter.

For example:

Clear
CLC
syms a b x y;
F=a+2*b+3*x+4*y;
Limit (f,2)
Findsym (f,1)
Results

Ans =
 
A + 2*b + 4*y + 6
 

ans =

x
Limit (f) For further simplification of the above function, the limits of the expression F, the default argument, 0 o'clock.
Limit (f,x,a, ' right ') or limit (F,x,a, ' left ') on the expression f,x

The following is an example of Help limit, where INF means infinity, and the exp () function indicates how many times E

    Examples:
      syms x a t h;
 
      Limit (sin (x) x)                 returns   1
      limit ((x-2)/(X^2-4), 2)          returns   (
      1+2*t/x) ^ (3*x), X, INF)    returns   exp (6*t)
      limit (1/x,x,0, ' right ')          returns   inf
      limit (1/x,x,0, ' left ')           returns   -inf
      limit ((Sin (x+h)-sin (x))/h,h,0)  returns   cos (x)
      v = [(1 + a/x) ^X, exp (-X) ];
      Limit (V,x,inf, ' left ')           returns   [exp (a),  0]
Example: When n→∞ (1+1/n) The limit of ^n is E

Clear
CLC
syms N;
Limit ((1+1/n) ^n,n,inf)
Results

Ans =
 
exp (1)

Note: The limit function is only used for function limits, not for sequence limits, and for limit

diff Differential and difference quotient

Diff Differential and differential
differential operation; Help Sym/diff, differential operation help diff
Note that diff does not use the toolbox as a differential operation, while using the symbol toolbox is a differential operation

Symbolic functions Section
When diff (s) s is a symbolic function, the derivative of S is computed, and the default argument can be found by Findsym (s,1)
diff (S, ' V ') or diff (S,sym (' V ')) s is the symbolic function, the derivative of S is computed, the argument is V
When diff (S,n) s is a symbolic function, computes the n-derivative of s, using the default argument
When diff (s, ' V ', N) s is a symbolic function, the n-order derivative of S is computed, and the independent variable is V

Cases

Clear
CLC
syms x;
F=log (x) +sin (x) +x^2
diff (F)
Results

f =
 
log (x) + sin (x) + x^2
 
 
ans =
 
2*x + cos (x) + 1/x

Cases

Clear
CLC
syms x y;
F=x^6+y^5
diff (f,y,3)
Results

F =
 
x^6 + y^5
 
 
ans =
 
60*y^2


General function Section
diff (x) x is a vector (row and column), calculating the difference between the two adjacent numbers [X (2)-X (1) × (3)-X (2) ... X (n)-X (n-1)]
When diff (x) x is a matrix, the difference between the 2~n line of the matrix and the 1~n-1 line is computed, [x (2:n,:)-X (1:n-1,:)]
diff (X,n) expands the above function diff (X), where n specifies n-order difference, and second-order difference is the result of the first difference and then the difference operation
diff (X,n,dim) to the above function diff (x,n) expansion, DIM take 1 or 2, take 1 o'clock by row differential, as above results, take 2 o'clock by column difference

Cases

Clear
CLC
x=1:10
diff (x)
Results

x =

     1     2     3     4     5     6     7     8     9


ans =

     1 1     1     1     1     1     1)     1     1
Cases

Clear
CLC
x=magic (4)
diff (x)
Results

x =     2     3
     5     8
     9     7 6 (    4     ) 1


ans =

   -11     9     7    -5
     4    -4    -4     4
    -5     7     9   -11
Cases

Clear
CLC
x=magic (3)
diff (x,1)
Results

x =

     8     1     6
     3     5     7
     4     9     2


ans =

    -5     4     1
     1     4    -5
Cases

Clear
CLC
x=magic (3)
diff (x,1,1)
Results

x =

     8     1     6
     3     5     7
     4     9     2


ans =

    -5     4     1
     1     4    -5
Example: Second order differential

Clear
CLC
x=magic (3)
diff (x,2,1)
Results

x =

     8     1     6
     3     5     7
     4     9     2


ans =

     6     0    -6
Example: Differential by column

Clear
CLC
x=magic (3)
diff (x,1,2)
Results

x =

     8     1     6
     3     5     7
     4     9     2


ans =

    -7     5
     2     2
     5    -7
Example: Finding the approximate derivative y/x by difference
Clear
CLC
Dx=0.01*2*pi;
X=0:dx:2*pi;
Y=sin (x);
F=diff (y)/dx

Results

f = Columns 1 through 18 0.9993 0.9954 0.9875 0.9758 0.9601 0.9407 0.9176 0.8909 0.8606 0.8269 0.7900 0.7500 0.7070 0.6612 0.6128 0.5620 0.5090 0.4539 Columns 36 through 0.39    71 0.3387 0.2789 0.2181 0.1564 0.0941 0.0314-0.0314-0.0941-0.1564-0.2181-0.2789-0.3387 -0.3971-0.4539-0.5090-0.5620-0.6128 Columns Notoginseng through 54-0.6612-0.7070-0.7500-0.7900-0 .8269-0.8606-0.8909-0.9176-0.9407-0.9601-0.9758-0.9875-0.9954-0.9993-0.9993-0.9954-0.9   875-0.9758 Columns through 72-0.9601-0.9407-0.9176-0.8909-0.8606-0.8269-0.7900-0.7500 -0.7070-0.6612-0.6128-0.5620-0.5090-0.4539-0.3971-0.3387-0.2789-0.2181 Columns through 9 0-0.1564-0.0941-0.0314 0.0314 0.0941 0.1564 0.2181 0.2789 0.3387 0.3971 0.4539 0.509   0 0.5620 0.6128 0.7070 0.7500 0.7900 Columns 0.6612 through 100 0.8269 0.8606 0.8909 0.9176 0.9407 0.9 601 0.9758 0.9875) 0.9954 0.9993

int symbol integral
Help Sym/int
Int (s) s is a symbolic function, the default arguments are indefinite integrals, the default arguments can be found by Findsym (s,1)
Int (s,v) S is a symbolic function, the indefinite integral of the Independent variable V
Int (s,a,b) S is a symbolic function, the integral is determined by the default argument, and the integral area is a-b

Int (s,v,a,b) S is a symbolic function, and the integral region is a-b for the independent variable V

Help Sym/int documentation Examples

    Examples:
      syms x x1 alpha U t;
      A = [cos (x*t), sin (x*t),-sin (x*t), cos (x*t)];
      Int (1/(1+x^2))           returns     Atan (x)
      int (sin (alpha*u), Alpha)  returns     -cos (Alpha*u)/u
      Int ( BesselJ (1,x), x)      returns     -besselj (0,x)
      int (X1*log (1+x1), 0,1)    returns
      int (4*x* T,x,2,sin (t))    returns     -2*t*cos (t) ^2-6*t
      INT ([exp (t), exp (alpha*t)])  returns  [exp (t), Exp (alpha*t)/alpha]
      int (a,t)                 returns      [Sin (t*x)/x,-cos (T*X)/x]
                                            [cos (t*x)/x,  sin (t*x)/x ]
Example: Indefinite integral for ln (x)
Clear
CLC
syms x;
F=log (x);
Int (f)
Results

Ans =
 
x* (log (x)-1)
Example: to sin (x), to find the definite integral of 0~π

Clear
CLC
syms x;
F=sin (x);
Int (F,0,PI)
Results

Ans =
 
2


Integral transformation
Fourier transform, Laplace transform, Z-transform
Fouier (f,u,v) Fourier transform, F is the symbolic expression of f (U), U is an independent variable and V is an independent variable of the image function. The result is an image function f (v)
Ifourier (f,v,u) Fourier inverse transformation, F is the symbolic expression of f (v), V is the independent variable, and U is the independent variable of the original function. The result is the original function f (u)
Laplace (F,w,z) Laplace transform
Ilaplace (l,y,x) Laplace inverse transformation
Ztrans (f,k,w) Z-transform
Iztrans (f,w,k) inverse Z-transform

Example: Fourier transform for e^ (-x^2)

Clear
CLC
syms x t;
F=exp (-x^2)
f=fourier (f,x,t)

Results

f =
 
1/exp (x^2)
 
 
f =
 
pi^ (/exp) (T^2/4)

Olve Solving Algebraic equations
Solve (' eqn1 ', ' eqn2 ',..., ' eqnn ') specifies 0 solutions for one or more symbolic expressions
Solve (' eqn1 ', ' eqn2 ',..., ' eqnn ', ' var1,var2,..., varn ') specify one or more symbolic expressions for 0 solutions, Var is an argument

Solve (' eqn1 ', ' eqn2 ',..., ' eqnn ', ' var1 ', ' var2 ',... ' Varn ') specify one or more symbolic expressions for 0 solutions, Var is an argument

Cases

Clear
CLC
syms x;
F=cos (x);
Solve (f)
Results

Ans =
 
PI/2

Cases

Clear
CLC
syms x y;
F1=x+y;
f2=x^3-y^2;
[X,y]=solve (F1,F2)
Results

x =
 
 0
 1
 
 
y =
 
  0
 -1

Dsolve Solving differential equations
Dsolve (' eqn1 ', ' eqn2 ', ..., boundary conditions, arguments)
D is a derivative, D2 means that the second-order d^2/dt^2,d3y means the third derivative of y

Examples of Help Dsolve documentation

    Examples:
 
       dsolve (' dx =-a*x ') returns
 
         ans = C1/exp (a*t)
 
       x = dsolve (' dx =-a*x ', ' x (0) = 1 ', ' s ') returns
 
         x =  1/exp (a*s)
 
       s = dsolve (' Df = f + g ', ' Dg =-f + g ', ' f (0) = 1 ', ' g (0) = 2 ')
       returns a structure s with Fields
 
         S.F = (i + a)/exp (t* (i-1))-exp (t* (i + 1)) * (I-1/2)
         S.G = exp (t* (i + 1)) * (I/2 + 1)-(I/2-1)/exp (t* (i-1))
 
       D Solve (' Df = f + sin (t) ', ' f (PI/2) = 0 ')
       dsolve (' d2y =-a^2*y ', ' y (0) = 1, Dy (pi/a) = 0 ')
       S = Dsolve (' Dx = y ', ' D y =-X ', ' x (0) =0 ', ' Y (0) =1 ')
       S = Dsolve (' Du=v, dv=w, dw=-u ', ' u (0) =0, V (0) =0, W (0) =1 ')
       w = dsolve (' d3w =-W ', ' W (0 ) =1, Dw (0) =0, d2w (0) =0 ')
Symsum Series Summation
Help Sym/symsum

Symsum (S) series summation upper and lower limit is a->b

Documentation examples

    Examples:
       symsum (k)                     K^2/2-K/2
       symsum (k,0,n-1)               (n (n-1))/2
       symsum (k,0,n)                 (n + 1)/2 Simple
       (Symsum (k^2,0,n))       N^3/3 + N^2/2 + N/6 symsum
       (k^2,0,10)              385 symsum
       (k^2,11,10)             0
       symsum (1/k^2)                 -psi (k, 1)
       symsum (1/k^2,1,inf)           PI^2/6












Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.