Calculate Derivative of Function in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter Rasalhague
  • Start date Start date
  • Tags Tags
    Derivative Mathematica
Click For Summary
SUMMARY

The discussion centers on calculating the derivative of a function in Mathematica, specifically using the command D[x[u], u]. The user encountered unexpected results because the variable x was defined without a reference to u, leading to Mathematica treating it as a static list rather than a function. The correct approach is to use D[x, u] to obtain the desired derivative. Wolfram Alpha provides a more flexible interpretation of ambiguous syntax, which can yield the expected results without strict adherence to programming conventions.

PREREQUISITES
  • Understanding of Mathematica syntax and functions
  • Familiarity with calculus concepts, specifically derivatives
  • Knowledge of variable definitions in programming
  • Experience with Wolfram Alpha for mathematical queries
NEXT STEPS
  • Explore Mathematica's D function for derivatives in depth
  • Learn about variable scoping and definitions in Mathematica
  • Investigate Wolfram Alpha's parsing capabilities for mathematical expressions
  • Review best practices for defining functions in Mathematica
USEFUL FOR

Mathematica users, students learning calculus, educators teaching mathematical programming, and anyone interested in understanding function derivatives in computational software.

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

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
1
Views
3K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 4 ·
Replies
4
Views
3K