Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica assign derivative

  1. Oct 20, 2008 #1
    Hi. A quick mathematica question. If I compute a derivative using D[f[x],x], how can I assign this result to another function, e.g. I want g[x]=f'[x] using the D-notation. Thanks.
  2. jcsd
  3. Oct 20, 2008 #2
    This what you mean?

    In[1]:= j = x^2

    Out[1]= x^2

    In[2]:= e = D[j, x]

    Out[2]= 2 x

    In[3]:= f = D[e, x]

    Out[3]= 2

    In[4]:= ff = D[f, x]

    Out[4]= 0
  4. Oct 21, 2008 #3
    g[x_] = D[f[x], x]

    Note the underscore in g[x_].

    (Alternatively, you could just do g = f')
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook