Chain rule with symbolic toolbox

15 views (last 30 days)
Hello,
I'm trying to derive a symbolic function that is a function of another symbolic function. Say that I have a function x that is an unspecified function x=x(y(theta)). I'd like to take the derivative of x with respect to theta: dx/dtheta=dx/dy * dy/dtheta
In Matlab I write
syms theta y(theta);
x=sym('x(y(theta))');
diff(x,theta)
The answer I get is 0. I really cannot figure out what is wrong with the code. Any help is greatly appreciated. Thanks!

Accepted Answer

Star Strider
Star Strider on 5 Apr 2014
This:
syms theta y(theta) x(y)
x = x(y)
Dyt = diff(y,theta)
Dxt = diff(x,theta)
produces:
x =
x(y(theta))
Dyt(theta) =
D(y)(theta)
Dxt =
D(x)(y(theta))*diff(y(theta), theta)
Is that what you wanted?
  6 Comments
Meet Mevada
Meet Mevada on 21 Mar 2021
Thanks man.This helped me a lot.
Star Strider
Star Strider on 21 Mar 2021
Meet Mevada — My pleasure!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!