Mathematica Calculate Derivative of Function in Mathematica

AI Thread Summary
The discussion centers on a Mathematica code snippet where the user attempts to differentiate a vector function x defined in terms of variables u, v, and w. The output from Mathematica shows an unexpected result, indicating a misunderstanding of how x is defined and differentiated. It is clarified that x was defined without explicitly referencing u, leading to confusion when trying to differentiate x[u]. The correct approach is to use D[x, u] for differentiation. The comparison with Wolfram Alpha highlights its more flexible syntax, which can interpret ambiguous expressions more intuitively, providing the expected result. The conversation emphasizes the differences in handling syntax between Mathematica and Wolfram Alpha, noting that the latter's ability to guess user intent can be both beneficial and problematic.
Rasalhague
Messages
1,383
Reaction score
2
Mathematica:

Code:
In[1]:= x = {(u + 2 v)/3, (u - v)/3, w}; D[x[u], u]

Out[1]= {1/3, 1/3, 0}[u] + {(u + 2 v)/3, (u - v)/3, w}’[u]

Why does it do this? Wolfram Alpha gives the answer I expected:

http://www.wolframalpha.com/input/?i=d%2Fdu+%28{%28u+%2B+2+v%29%2F3%2C+%28u+-+v%29%2F3%2C+w}%29

{1/3, 1/3, w’(u)} = {1/3, 1/3, 0} if w doesn't change with u.
 
Physics news on Phys.org
You defined
x = { ... }
without reference to u. So x was stored as { ... }.
Then you tried taking the derivative of x, which gets converted to
{ ... }
which doesn't make sense. If you ask for D[x,u] you will get what you wanted.

Wolfram Alpha has a more flexible grammar -- ie it's not a programming language.
Thus it guessed what you meant.
 
Thanks, Simon. Problem solved. Yes, I've noticed before that WA is more forgiving and able to guess (for better or worse) at the meaning of ambigious syntax.
 

Similar threads

Back
Top