Alex_McAvoy

想要成为渔夫的猎手

Matlab 微积分相关技巧

【反函数求导】

一阶导数

对于 $y=f(x)$ 可导且 $f’(x)\neq 0$,则存在反函数 $x=\phi(y)$,且有 $\frac{dx}{dy}=\frac{1}{\frac{dy}{dx}}$

即:$\phi’(y)=\frac{1}{f’(x)}$

1
2
3
4
>> syms x f(x)
>> f(x)=2*x;
>> 1/diff(f,x)
ans(x) = 1/2

二阶导数

在 $y=f(x)$ 二阶可导情况下,反函数为 $x=\phi(y)$ 时

有: $\phi’(y)=\frac{dx}{dy}=\frac{1}{\frac{dy}{dx}}=\frac{1}{f’(x)}$

进一步:$\phi’’(y)=\frac{d^2x}{dy^2}=\frac{d(\frac{dx}{dy})}{dy}=\frac{d(\phi’(y))}{dx}\frac{dx}{dy}=\frac{d(\phi’(y))}{dx}\phi’(y)=[\frac{1}{f’(x)}]’\frac{1}{\phi’(y)}=\frac{-f’’(x)}{[f’(x)]^2}\phi’(y)$

即:$\phi’’(y)=\frac{-f’’(x)}{[f’(x)]^2}\phi’(y)=\frac{-f’’(x)}{[f’(x)]^3}$

1
2
3
4
5
6
7
8
9
10
11
>> syms x f(x)
>> f(x)=x^3;

% 法一
>> temp=1/diff(f)
temp(x) = 1/(3*x^2)
>> -diff(f,2)/(diff(f)^3)

% 法二
>> -diff(f,2)/(diff(f)^3)
ans(x) = -2/(9*x^5)

【参数方程求导】

一阶导数

设函数 $y=y(x)$ 由参数方程 $\left\{\begin{matrix}x=f(t)
\\y=g(t)
\end{matrix}\right.$ 确定,$f(t),g(t)$ 均对 $t$ 可导,且 $f’(t)\neq 0$

则:$\frac{dy}{dx}=\frac{dy/dt}{dx/dt}=\frac{g’(t)}{f’(t)}$

1
2
3
4
5
>> syms t x(t) y(t)
>> x(t)=sin(t);
>> y(t)=t*sin(t)+cos(t);
>> diff(x)/diff(y)
ans(t) = t

二阶导数

设函数 $y=y(x)$ 由参数方程 $\left\{\begin{matrix}x=f(t)
\\y=g(t)
\end{matrix}\right.$ 确定,$f(t),g(t)$ 均对 $t$ 二阶可导,且 $f’(t)\neq 0$

则:$\frac{dy}{dx}=\frac{dy/dt}{dx/dt}=\frac{g’(t)}{f’(t)}$

进一步:$\frac{d^2y}{dx^2}=\frac{d(\frac{dy}{dx})}{dx}=\frac{d(\frac{dy}{dx})/dt}{dx/dt}=\frac{[\frac{g’(t)}{f’(t)}]’}{f’(t)}=\frac{g’’(t)f’(t)-f’’(t)g’(t)}{[f’(t)]^2}\frac{1}{f’(t)}=\frac{g’’(t)f’(t)-f’’(t)g’(t)}{[f’(t)]^3}$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
>> syms t f(t) g(t)
>> f(t)=sin(t);
>> g(t)=t*sin(t)+cos(t);

% 法一
> temp=diff(g)/diff(f)
temp(t) = t
>> diff(temp)/diff(f)
ans(t) = 1/cos(t)

% 法二
>> (diff(g,2)*diff(f)-diff(g)*diff(f,2))/(diff(f)^3)
ans(t) = (cos(t)*(cos(t) - t*sin(t)) + t*cos(t)*sin(t))/cos(t)^3
>> simplify(ans)
ans(t) = 1/cos(t)

【隐函数求导】

单个方程

设 $y=y(x)$ 是由方程 $F(x,y)=0$ 确定的可导函数

对于 $F(x,y)=0$ 两边同时对于 $x$ 进行求导

有:$F_xx’+F_y y_x’=0$

化简有:$F_x+F_y y_x’=0 $

即:$y_x’=\frac{dy}{dx}=-\frac{F_x}{F_y}$

例:求 $sin(x*y)=ln(\frac{x+\pi}{y})+1$ 的导数

1
2
3
4
>> syms x y F(x,y)
>> F(x,y)=sin(x*y)-log((x+pi)/y)-1;
>> -diff(F,x)/diff(F,y)
ans(x, y) = (1/(x + pi) - y*cos(x*y))/(x*cos(x*y) + 1/y)

三元方程组

设两个一元隐函数 $y=y(x),z=z(x)$ 由方程组$\left\{\begin{matrix}F(x,y,z)=0
\\G(x,y,z)=0
\end{matrix}\right.$ 确定

对于 $F(x,y)=0$ 两边同时对于 $x$ 进行求导

有:$F_x+F_y y_x’+F_z z_x’=0$ ①

同理,对于 $G(x,y)=0$ 两边同时对于 $x$ 进行求导

有:$G_x+G_y y_x’+G_z z_x’=0$ ②

对于式 ①,有:$y_x’=\frac{F_z z_x’-F_x}{F_y}$ ③

对于式 ②,有:$z_x’=\frac{-G_y y_x’-G_x}{G_z}$ ④

将式 ④ 带入式 ③ 中,有:$y_x’=\frac{F_z\frac{-G_y y_x’-G_x}{G_z}-F_x}{F_y}$ ⑤

将式 ③ 带入式 ④ 中,有:$z_x’=\frac{-G_y\frac{F_z z_x’-F_x}{F_y}-G_x}{G_z}$ ⑥

将 ⑤、⑥ 化简,有:$\left\{\begin{matrix} y_x’=-\frac{F_z G_x-F_x G_z}{F_y G_z-F_z G_y}
\\ z_x’=-\frac{F_y G_x-F_x G_y}{F_y G_z-F_z G_y}
\end{matrix}\right.$

即:$\left\{\begin{matrix} y_x’=\frac{dy}{dx}=
-\frac{1}{J}\begin{vmatrix}F_x & F_z
\\ G_x & G_z
\end{vmatrix}
\\ z_x’=\frac{dz}{dx}=-\frac{1}{J}\begin{vmatrix} F_y & F_x
\\ G_y & G_x
\end{vmatrix}
\end{matrix}\right.$,其中 $J=\begin{vmatrix} F_y & F_z \\ G_y & G_z \end{vmatrix}\neq 0 $

例:

求:$\left\{\begin{matrix}z=x^2+y^2\\x^2+2y^2+3z^2=20\end{matrix}\right.$ 的 $\frac{dy}{dx},\frac{dz}{dx}$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
>> syms x y z
>> F(x,y,z)=z-x^2-y^2;
>> G(x,y,z)=x^2-2*y^2+3*z^2-20;

% 法一
>> Fx=diff(F,x);Fy=diff(F,y);Fz=diff(F,z);
>> Gx=diff(G,x);Gy=diff(G,y);Gz=diff(G,z);
>> J=det([Fy,Fz;Gy,Gz]);

>> dy=(-1/J)*det([Fx,Fz;Gx,Gz])
dy(x, y, z) = (2*x + 12*x*z)/(4*y - 12*y*z)
>> simplify(dy)
ans(x, y, z) = -(x*(6*z + 1))/(2*y*(3*z - 1))

>> dz=(-1/J)*det([Fy,Fx;Gy,Gx])
dz(x, y, z) = (12*x*y)/(4*y - 12*y*z)
>> simplify(dz)
ans(x, y, z) = -(3*x)/(3*z - 1)

% 法二
>> J=det(jacobian([F,G],[y,z]));

>> dy=(-1/J)*det(jacobian([F,G],[x,z]))
dy(x, y, z) = (2*x + 12*x*z)/(4*y - 12*y*z)
>> simplify(dy)
ans(x, y, z) = -(x*(6*z + 1))/(2*y*(3*z - 1))

>> dz=(-1/J)*det(jacobian([F,G],[y,x]))
dz(x, y, z) = (12*x*y)/(4*y - 12*y*z)
>> simplify(dz)
ans(x, y, z) = -(3*x)/(3*z - 1)

隐函数求偏导

设 $\left\{\begin{matrix} F(x,y,u,v)=0 \\ G(x,y,u,v)=0 \end{matrix}\right.$ 在点 $P(x_0,y_0,u_0,v_0)$ 的某一邻域内有对各变量的连续偏导数,满足 $\left\{\begin{matrix} F(x_0,y_0,u_0,v_0)=0 \\ G(x_0,y_0,u_0,v_0)=0 \end{matrix}\right.$,且偏导数所组成的行列式(雅克比行列式) $J=\frac{\partial(F,G)}{\partial(u,v)}=\begin{vmatrix}\frac{\partial F}{\partial u} & \frac{\partial F}{\partial v} \\ \frac{\partial G}{\partial u} & \frac{\partial G}{\partial v} \end{vmatrix}$ 在点 $P(x_0,y_0,u_0,v_0)\neq 0$

那么该方程组在点 $P$ 的某一邻域内恒能唯一确定一组单值连续且具有连续偏导数的函数 $\left\{\begin{matrix} u=u(x,y) \\ v=v(x,y) \end{matrix}\right.$ ,它们满足 $\left\{\begin{matrix} u_0=u(x_0,y_0) \\ v_0=v(x_0,y_0) \end{matrix}\right.$ ,并有:

$\frac{\partial u}{\partial x}=-\frac{1}{J}\frac{\partial(F,G)}{\partial(x,v)}=-\frac{\begin{vmatrix}F_x&F_v\\G_x&G_v\end{vmatrix}}{\begin{vmatrix}F_u&F_v\\G_u&G_v\end{vmatrix}}$ $\frac{\partial u}{\partial y}=-\frac{1}{J}\frac{\partial(F,G)}{\partial(y,v)}=-\frac{\begin{vmatrix}F_y&F_v\\G_y&G_v\end{vmatrix}}{\begin{vmatrix}F_u&F_v\\G_u&G_v\end{vmatrix}}$

$\frac{\partial v}{\partial x}=-\frac{1}{J}\frac{\partial(F,G)}{\partial(u,x)}=-\frac{\begin{vmatrix}F_u&F_x\\G_u&G_x\end{vmatrix}}{\begin{vmatrix}F_u&F_v\\G_u&G_v\end{vmatrix}}$ $\frac{\partial v}{\partial y}=-\frac{1}{J}\frac{\partial(F,G)}{\partial(u,y)}=-\frac{\begin{vmatrix}F_u&F_y\\G_u&G_y\end{vmatrix}}{\begin{vmatrix}F_u&F_v\\G_u&G_v\end{vmatrix}}$

例:求 $\left\{\begin{matrix}xu-yv=0\\yu+xv=1\end{matrix}\right.$的偏导数 $\frac{\partial u}{\partial x},\frac{\partial u}{\partial y},\frac{\partial v}{\partial x},\frac{\partial v}{\partial y}$

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
>> syms x y u v
>> F(x,y,u,v)=u*x-v*y;
>> G(x,y,u,v)=y*u+x*v-1;

% 法一
>> Fx=diff(F,x);Fy=diff(F,y);Fu=diff(F,u);Fv=diff(F,v);
>> Gx=diff(G,x);Gy=diff(G,y);Gu=diff(G,u);Gv=diff(G,v);
>> J=det([Fu,Fv;Gu,Gv]);

>> dux=-det([Fx,Fv;Gx,Gv])/J
dux(x, y, u, v) = -(u*x + v*y)/(x^2 + y^2)
>> duy=-det([Fy,Fv;Gy,Gv])/J
duy(x, y, u, v) = -(u*y - v*x)/(x^2 + y^2)
>> dvx=-det([Fu,Fx;Gu,Gx])/J
dvx(x, y, u, v) = (u*y - v*x)/(x^2 + y^2)
>> dvy=-det([Fu,Fy;Gu,Gy])/J
dvy(x, y, u, v) = -(u*x + v*y)/(x^2 + y^2)

% 法二
>> J=det(jacobian([F,G],[u,v]));

>> dux=-det(jacobian([F,G],[x,v]))/J
dux(x, y, u, v) = -(u*x + v*y)/(x^2 + y^2)
>> duy=-det(jacobian([F,G],[y,v]))/J
duy(x, y, u, v) = -(u*y - v*x)/(x^2 + y^2)
>> dvx=-det(jacobian([F,G],[u,x]))/J
dvx(x, y, u, v) = (u*y - v*x)/(x^2 + y^2)
>> dvy=-det(jacobian([F,G],[u,x]))/J
dvy(x, y, u, v) = (u*y - v*x)/(x^2 + y^2)
感谢您对我的支持,让我继续努力分享有用的技术与知识点!