Symbolically differentiation a function w.r.t a function

6 ビュー (過去 30 日間)
Udbhav
Udbhav 2020 年 1 月 19 日
コメント済み: Udbhav 2020 年 1 月 20 日
How to differentiate with respect to ; where, with the help of symbolic math tool. I tried writing
syms f(x) g(x) h(x) x
g(x) = sqrt(f(x)^2 + x);
h(x) = diff(g(x),f(x));
but the following error pops up,
%Error using sym/diff (line 70)
%Second argument must be a variable or a nonnegative integer specifying the number of differentiations.
I am new to MATLAB and trying to understand the reason for this error and any suggestions on how can I write;

採用された回答

darova
darova 2020 年 1 月 19 日
Try this
syms g(x) h(x) x f
g(x,f) = sqrt(f^2 + x);
h(x,f) = diff(g(x,f),f)
  2 件のコメント
Udbhav
Udbhav 2020 年 1 月 19 日
Thanks darova for you help. It worked great. Matlab sure requires a little extra effort than Mathematica for symbolic computation :-p
darova
darova 2020 年 1 月 19 日
Can you please accept the answer?

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 1 月 19 日
You cannot differentiate a function with respect to a different unknown function with normal calculus, because you cannot know that the functions are independent. You need Calculus of Variations to create operators for differentiating functions.
In the past I have posted examples demonstrating that the process suggested by Darova can generate the wrong answer.
  2 件のコメント
Udbhav
Udbhav 2020 年 1 月 20 日
Walter, thanks for your answer. I actually needed what darova suggested. But yeah I agree with you completely. I will see your previous posts then for more clarification.
Udbhav
Udbhav 2020 年 1 月 20 日
thanks Walter for your valuable answer. I actually needed what darova suggested at that instant. I will go through your previous posts for further clarification.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by