总述
函数说明
function result=paradiff(y, x, t, n)
%paradiff
%参数方程求导的递归实现
% 调用格式:
% y1 = paradiff(y, x, t, n)
% 其中:y=f(t), x=g(t), t为参数, n为导数阶次
%
% Examples:
% 已知参数方程 y=sin(t)/(t+1)^3; x=cos(t)/(t+1)^3
% 求d3y/dx3
% MATLAB求解语句:
% syms t; y=sin(t)/(t+1)^3; x=cos(t)/(t+1)^3;
% f = paradiff(y,x,t,3);
% [n,d]=numden(f); %分离分子分母
% F=simplify(n)/simplify(d) %分子分母各自化简
应用举例
问题: 已知参数方程
y
=
s
i
n
t
(
t
+
1
)
3
,
x
=
c
o
s
t
(
t
+
1
)
3
y=\frac{sint}{(t+1)^3}, x=\frac{cost}{(t+1)^3}
y=(t+1)3sint,x=(t+1)3cost
求
d
3
y
/
d
x
3
d^3y/dx^3
d3y/dx3
代码如下:
syms t
y=sin(t)/(t+1)^3; x=cos(t)/(t+1)^3;
f=paradiff(y,x,t,3);
[n,d]=numden(f); % //分离分子分母
F=simplify(n)/simplify(d) % //分子分母各自化简
最终结果为:
函数实现
function result=paradiff(y, x, t, n)
if mod(n,1)~=0
error('n should positive integer, please correct')
else
if n==1
result = diff(y,t)/diff(x,t);
else
result = diff(paradiff(y,x,t,n-1),t)/diff(x,t);
end
end
此函数源文件可前往下面网址下载: