How to define second derivative in symbolic

AA, I have a project to derive some equations that defined in symbolic variables. For example, r= cos(A), I want the symbolic system show me a result that dr/dA = -sin(A)*(dA/d) as A has derivatives values dA/d and so far for d²A/d² If I want the second derivative of r.

 Accepted Answer

Use the symbolic diff function —
syms A
r(A) = cos(A)
r(A) = 
D1r = diff(r)
D1r(A) = 
D2r = diff(r,2)
D2r(A) = 
.

6 Comments

Here you go —
syms A(t)
r = cos(A)
r(t) = 
D1r = diff(r)
D1r(t) = 
D2r = diff(r,2)
D2r(t) = 
Here, A has to be defined as a function of something, otherwise it is treated as a constant. So I made it a function of t.
.
As always, my pleasure!

Sign in to comment.

More Answers (1)

dr/dA = -sin(A)*(dA/d)
d²r/dA² = -cos(A)*(dA/d)^2-sin(A)*d²A/d²

3 Comments

How can I let MATLAB symbolic shows this result as finally, I will substitute the derivative
Any variable, it doesn't matter

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!