MATLAB提供用于计较标记导数的`diff`呼吁。 以最简朴的形式，将要微分的成果通报给`diff`呼吁作为参数。

``````syms t
f = 3*t^2 + 2*t^(-2);
diff(f)
``````

``````Trial>> syms t
f = 3*t^2 + 2*t^(-2);
diff(f)

ans =

6*t - 4/t^3
``````

``````pkg load symbolic
symbols

t = sym("t");
f = 3*t^2 + 2*t^(-2);
differentiate(f,t)
``````

``````ans =

6*t - 4/t^3
``````

## 根基微分法则的验证

h(x) = af(x) + bg(x)相对付`x`，由h’(x) = af’(x) + bg’(x)给出。

sum和subtraction法则表述为：假如`f``g`是两个函数，则`f'``g'`别离是它们的导数，如下 -

``````(f + g)' = f' + g'

(f - g)' = f' - g'
``````

product法则表述为：假如`f``g`是两个函数，则`f'``g'`别离是它们的导数，如下 -

``````(f.g)' = f'.g + g'.f
``````

quotient法则表白，假如`f``g`是两个函数，则`f'``g'`别离是它们的导数，那么 -

``````f' = 0
``````

chain法则表述为 - 相对付`x`的函数`h(x)= f(g(x))`的函数的导数是 -

``````h'(x)= f'(g(x)).g'(x)
``````

``````syms x
syms t
f = (x + 2)*(x^2 + 3)
der1 = diff(f)
f = (t^2 + 3)*(sqrt(t) + t^3)
der2 = diff(f)
f = (x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 = diff(f)
f = (2*x^2 + 3*x)/(x^3 + 1)
der4 = diff(f)
f = (x^2 + 1)^17
der5 = diff(f)
f = (t^3 + 3* t^2 + 5*t -9)^(-6)
der6 = diff(f)
``````

``````f =
(x^2 + 3)*(x + 2)

der1 =
2*x*(x + 2) + x^2 + 3

f =
(t^(1/2) + t^3)*(t^2 + 3)

der2 =
(t^2 + 3)*(3*t^2 + 1/(2*t^(1/2))) + 2*t*(t^(1/2) + t^3)

f =
(x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)

der3 =
(2*x - 2)*(3*x^3 - 5*x^2 + 2) - (- 9*x^2 + 10*x)*(x^2 - 2*x + 1)

f =
(2*x^2 + 3*x)/(x^3 + 1)

der4 =
(4*x + 3)/(x^3 + 1) - (3*x^2*(2*x^2 + 3*x))/(x^3 + 1)^2

f =
(x^2 + 1)^17

der5 =
34*x*(x^2 + 1)^16

f =
1/(t^3 + 3*t^2 + 5*t - 9)^6

der6 =
-(6*(3*t^2 + 6*t + 5))/(t^3 + 3*t^2 + 5*t - 9)^7
``````

``````pkg load symbolic
symbols
x=sym("x");
t=sym("t");
f = (x + 2)*(x^2 + 3)
der1 = differentiate(f,x)
f = (t^2 + 3)*(t^(1/2) + t^3)
der2 = differentiate(f,t)
f = (x^2 - 2*x + 1)*(3*x^3 - 5*x^2 + 2)
der3 = differentiate(f,x)
f = (2*x^2 + 3*x)/(x^3 + 1)
der4 = differentiate(f,x)
f = (x^2 + 1)^17
der5 = differentiate(f,x)
f = (t^3 + 3* t^2 + 5*t -9)^(-6)
der6 = differentiate(f,t)
``````

## 指数，对数和三角函数的导数

``````syms x
y = exp(x)
diff(y)
y = x^9
diff(y)
y = sin(x)
diff(y)
y = tan(x)
diff(y)
y = cos(x)
diff(y)
y = log(x)
diff(y)
y = log10(x)
diff(y)
y = sin(x)^2
diff(y)
y = cos(3*x^2 + 2*x + 1)
diff(y)
y = exp(x)/sin(x)
diff(y)
``````

``````y =
exp(x)
ans =
exp(x)

y =
x^9
ans =
9*x^8

y =
sin(x)
ans =
cos(x)

y =
tan(x)
ans =
tan(x)^2 + 1

y =
cos(x)
ans =
-sin(x)

y =
log(x)
ans =
1/x

y =
log(x)/log(10)
ans =
1/(x*log(10))

y =
sin(x)^2
ans =
2*cos(x)*sin(x)

y =

cos(3*x^2 + 2*x + 1)
ans =
-sin(3*x^2 + 2*x + 1)*(6*x + 2)

y =
exp(x)/sin(x)
ans =
exp(x)/sin(x) - (exp(x)*cos(x))/sin(x)^2
``````

Matlab教程

2017-11-02

MATLAB提供用于计较标记导数的diff呼吁。 以最简朴的形式，将要微分的成果通报给diff呼吁作为参数。譬喻，计较函数的导数的方程式 - 例子建设脚