Calculate Derivative of Function in Mathematica

In summary, Mathematica is a programming language that requires specific syntax and will output an error if the syntax is not correct. In this conversation, the user encountered an error when trying to take the derivative of a previously defined expression. Wolfram Alpha, on the other hand, has a more flexible grammar and was able to guess at the intended meaning of the syntax, resulting in the expected answer.
  • #1
Rasalhague
1,387
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
  • #2
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.
 
  • #3
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.
 

What is a derivative in mathematics?

A derivative is a mathematical concept that represents the rate of change of a function at a particular point. It is the slope of the tangent line to the function at that point, and it can be used to calculate the instantaneous rate of change or the gradient of the function.

How do I calculate the derivative of a function in Mathematica?

To calculate the derivative of a function in Mathematica, you can use the built-in function D[ ]. This function takes two arguments: the function you want to differentiate and the variable with respect to which you want to take the derivative. For example, to calculate the derivative of f(x) = x^2, you can use D[x^2, x] to get 2x.

Can Mathematica calculate higher-order derivatives?

Yes, Mathematica can calculate higher-order derivatives using the D[ ] function. To calculate the second derivative of a function, you can use D[f(x), {x, 2}]. Similarly, for third-order derivatives, you can use D[f(x), {x, 3}], and so on.

What if I want to evaluate the derivative at a specific point?

You can use the D[ ] function with a third argument to specify the point at which you want to evaluate the derivative. For example, D[x^2, x, x=2] will give you the value of the derivative of x^2 at x=2, which is 4.

Can I plot the derivative of a function using Mathematica?

Yes, you can use the Plot[ ] function in Mathematica to plot the derivative of a function. Simply use Plot[D[f(x), x], {x, xmin, xmax}], where f(x) is the function you want to differentiate and xmin and xmax are the limits of the x-axis. This will give you a visual representation of the derivative of the function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
123
Replies
12
Views
1K
  • Calculus and Beyond Homework Help
Replies
10
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
41
Views
8K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
Replies
17
Views
2K
Back
Top