Unable to calculate the second derivative of a function

1 次查看(过去 30 天)
I want to calculate the second derivative of a function. Below are the steps I am following-
syms a b;
th = sym('th(t)'); %th is a time dependent variable
y = diff(a^2*cos(th)+(b/12)*sin(th));
thd = diff(th); %derivative of th wrt time
ybythd = diff(y,thd); %derivative of y wrt thd
p = diff(ybythd); %derivative of ybythd wrt time
It calculates the following value of p
p = diff(diff((b*cos(th(t))*diff(th(t), t))/12 - a^2*sin(th(t))*diff(th(t), t), t), diff(th(t), t))
I do not see any term of d2th/dt2 in the above result. What is missing?
  1 个评论
Andriy Kavetsky
Andriy Kavetsky 2016-10-6
y = diff(a^2*cos(th)+(b/12)*sin(th),th,2) %second derrivative ////////////////////////////////////////// y = diff(a^2*cos(a)+(b/12)*sin(a),a,2) %second derrivative from a and its result
y =
2*cos(a) - 4*a*sin(a) - (b*sin(a))/12 - a^2*cos(a)

请先登录,再进行评论。

回答(1 个)

Marc Jakobi
Marc Jakobi 2016-10-6
change
th = sym('th(t)'); %th is a time dependent variable
to
th = sym('th'); %th is a time dependent variable

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by