Symbolic differentiation with respect to first derivative
1 次查看(过去 30 天)
显示 更早的评论
Is it possible to make a derivative of an equation with respective to the first derivative . Illustration:
syms x(t)
eqn = diff(x) - 2
%diff(eqn,diff(x))
The expected result is 1 [edited after sir Walters answer] . A workaround is using subs() but is there any other straightforward way to achieve the result?
0 个评论
采纳的回答
Walter Roberson
2019-12-28
https://www.mathworks.com/help/symbolic/functionalderivative.html is the only available tool provided by Mathworks.
However, this is not going to do what you want:
syms x(t); dx = diff(x); eqn = dx - 2;
>> diff(eqn,dx)
Error using sym/diff (line 26)
Arguments, except for the first, must not be symbolic functions.
(which is a misleading error message that I will file a bug about.)
Note that if you would to have
eqn = x - 2
diff(eqn, x)
the result would be 1, not -2 . -2 is constant with respect to x(t) or diff(x,t) so it is going to vanish in the derivative.
It is tempting to use something like https://www.mathworks.com/help/symbolic/odetovectorfield.html to substitute the derivative with a symbol that you can then differentiate with respect to. However, drivatives are not independent of the original function, and you can arrive at wrong answers if you do this. I have posted examples in the past demonstrating that differentiating with one function with respect to another by processes like this give incorrect solutions (but that was a while ago and might be a bit tricky to locate now.) You cannot generally differentiate with respect to a function using normal calculus: you need The Calculus of Variations, which MATLAB does not implement.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!