8. Use matlab to complete symbolic calculus and limits (matlab program)

1. Brief description

      

1. Symbolic calculus

  • The numerical calculation method of calculus can only obtain the approximate solution expressed in numerical value, but cannot obtain the analytical solution expressed in the form of function.
  • In MATLAB, analytical solutions to calculus can be obtained through symbolic manipulation.

1. Symbolic limit

  • The function of finding the limit of a function in MATLAB is  limitthat it can be used to find the limit value of the function at a specified point and the left and right limit values.
  • MATLAB gives NaN for limit values ​​that are not defined, and Inf for limit values ​​that are infinite. limit The calling format of the function is as follows.
  • (1)  limit(f,x,a): Find the limit value of the symbolic function f ( x ) f(x) f(x) lim ⁡ x → af ( x ) \lim_{x \to a}f(x) x→alim​f(x)
  • That is, it calculates the limit value of the f ( x ) f(x) f(x) function when the variable xx x approaches the constant aa a .
  • (2)  limit(f,a): Find the limit value of the symbolic function f ( x ) f(x) f(x). Since the argument of the symbolic function f ( x ) f(x) f(x) is not specified, when this format is used, the variable of the symbolic function f ( x ) f(x) f(x) is the default argument determined by the  symvar(f) function , that is, the variable xx x approaches ∞ \infty ∞.
  • (3)  limit(f): Find the limit value of the symbolic function f ( x ) f(x) f(x). The variable of the symbolic function f ( x ) f(x) f(x) is the  symvar(f) default variable determined by the function; when the target value of the variable is not specified, the system default variable tends to 0, that is, a = 0 a=0 a=0 Condition.
  • (4)  limit(f,x,a,'right'): Find the limit value of the symbolic function f ( x ) f(x) f(x) lim ⁡ x → a + \lim_{x \to a^{+} } x→a+lim
  • 'right' means that the variable xx x approaches aa a from the right.
  • (5)  limit(f;x,a,'lef'): Find the limit value of the symbolic function f ( x ) f(x) f(x) lim ⁡ x → a − \lim_{x \to a^{-} } x→a−lim
  • 'left' means that the variable xx x approaches aa a from the left.

2. Code and running results


%% Learning Objectives: Matlab Symbolic Calculus and Limits,


%% Differential


clear all;
syms x y;
f=5*x^4+y*sin(x)+x*cos(y)+6
g1=diff(f)
g2=diff(f,3)    %求3阶导数
g3=diff(f,x,3)
g4=diff(f,y,3)

 


%% limit

clear all;
syms xh;
y1=limit((cos(x+h)-cos(x))/h,h,0) % is equivalent to deriving cos x
y2=limit(((x+h)^3- x^3)/h,h,0)

 

%%  
%% Indefinite integral

clear all;
syms x y;
f1=cos(x)+cos(y)
g1=int(f1)
g2=int(f1,x)
g3=int(f1,y)

 


%% Definite integral

clear all;
syms x;
f1=1/x^2+sin(x)
g1=int(f1,1,3)
g2=int(f1,x,1,3)
f2=3/x^2;
g3=int(f2,x,1,+inf)
 

 

Guess you like

Origin blog.csdn.net/m0_57943157/article/details/132266719