Upload
xin-zheng
View
11.010
Download
10
Embed Size (px)
Citation preview
第二章 用 MATLAB 求导当求导的函数比较复杂,或者是求高阶导数时,计算量是很大的。此时可以
用 MATLAB 的 diff 命令来求导数。
例 2.5.1 求sin xy x= 的导数。
解 syms x ↙diff(x^sin(x)) ↙
ans= x^sin(x)*(cos(x)*log(x)+sin(x)/x)可以用 pretty 命令来整理一下显示结果,使之更符合一般的书写格式
pretty(ans) ↙
sin sin[cos( ) log( ) ]x x
x x xx
+
例 2.5.2 求axy e= 的高阶导数。
解 syms a x ↙ diff(exp(a*x),x,3) ↙ ans=
a^3*exp(a*x)
diff(exp(a*x),x,30) ↙ ans= a^30*exp(a*x)
即3 (30) 30,ax axy a e y a e′′′ = = 。
例2.5.3函数y由参数方程21
arctan
x t
y t
= +
=,确定,求
dy
dx。
解 syms t ↙
x=sqrt(1+t ∧ 2); ↙
y=atan(t) ↙
pretty(diffy)/deff(x)) ↙
2 1/ 2
1
(1 )t t+
即得dy
dx= 2
1
1t t+