Difference between "diff(x^2)" and "2*x"
Show older comments
Hi, I can't figure out how are the following two situations different:
syms x1 x2 F;
U=x1^2+(x2-F)^2;
solve('diff(U,x1)=0','diff(U,x2)=0','x1,x2')
vs.
solve('2*x1=0','2*(x2-F)=0','x1,x2')
In the first case MATLAB can't find a solution, although it is a simple linear system (the same one as in the second case which works fine). Any ideas? Thank you:)
Accepted Answer
More Answers (1)
Wayne King
on 19 Sep 2012
Edited: Wayne King
on 19 Sep 2012
syms x1 x2 F;
U=x1^2+(x2-F)^2;
sol = solve(diff(U,x1)==0,diff(U,x2)==0,x1,x2);
sol.x1
sol.x2
Identical for me to:
sol2 = solve(2*x1==0,2*(x2-F)==0,x1,x2);
sol2.x1
sol2.x2
1 Comment
Jan commented:
Thanks for your answer, I should add that I'm using MATLAB R2010b and the syntax has changed, but that still doesn't explain this behavior to me. Your modified code
syms x1 x2 F;
U=x1^2+(x2-F)^2;
sol = solve('diff(U,x1)=0','diff(U,x2)=0','x1,x2')
sol.x1
sol.x2
still generates:
Warning: Could not extract individual solutions. Returning a MuPAD set object.
I will update to a recent version, because I'm almost certain that this is not due to a trivial mistake on my part (although it is possible of course). Thank you for any further comments!
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!