Unable to calculate the second derivative of a function
1 view (last 30 days)
Show older comments
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 Comment
Andriy Kavetsky
on 6 Oct 2016
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)
Answers (1)
Marc Jakobi
on 6 Oct 2016
change
th = sym('th(t)'); %th is a time dependent variable
to
th = sym('th'); %th is a time dependent variable
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!