Differentiating gives wrong result
古いコメントを表示
Hello
One of my functions returns this symbolic expression
(10000*(x2*cos((9*pi)/40) + x1*sin((9*pi)/40))^2)/9801 + (10000*(x1*cos((9*pi)/40) - x2*sin((9*pi)/40))^2)/9801 - 1
If I use the diff function(by x1) on it, it gives wrong result(ignores the variables or I don't know):
(20000*cos((9*pi)/40)*(x1*cos((9*pi)/40) - x2*sin((9*pi)/40)))/9801 + (20000*sin((9*pi)/40)*(x2*cos((9*pi)/40) + x1*sin((9*pi)/40)))/9801
Instead of:
(50706024009129175657667733171308125*x1)/24848487065673752728138376231780352
If I simply run this code, it works, so something is probably wrong with my returned expression from the function
syms x1 x2
f=(10000*(x2*cos((9*pi)/40) + x1*sin((9*pi)/40))^2)/9801 + (10000*(x1*cos((9*pi)/40) - x2*sin((9*pi)/40))^2)/9801 - 1;
diff(f,x1)
2 件のコメント
Alex Mcaulley
2019 年 8 月 12 日
Can you show the complete code that generates the symbolic expression? As you say, it works just executing your code.
Richárd Tóth
2019 年 8 月 12 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!