Derivative is calculated 2 different ways.

I used the code syms x ((x^2)+4)^2*(2*x^3-1)^3 diff(ans)
This is an improper result-- but if I use syms x ((x^2)+4)^2*(2*x^3-1)^3 expand(ans) diff(ans)
It works fine.
Even more frustratingly, when I name the function anything, my workaround with "expand" no longer works. I can only do it as expand(ans). Any explanation of why? My whole class is having an issue with this problem and I am the only one who has been able to get MATLAB to get the correct answer-- but I don't know why.

 采纳的回答

They are two versions of the same expression:
syms x
f(x) = ((x^2)+4)^2*(2*x^3-1)^3;
df = diff(f)
df = simplify(df, 'Steps', 20)
fe = expand(f)
dfe = diff(fe)
dfe = simplify(dfe, 'Steps', 20)
EqualityTest = isAlways(df == dfe)
EqualityTest =
logical
1

更多回答(0 个)

产品

版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by