How can I assign a derivative in Mathematica using D-notation?

  • Context: Undergrad 
  • Thread starter Thread starter daudaudaudau
  • Start date Start date
  • Tags Tags
    Derivative Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
daudaudaudau
Messages
297
Reaction score
0
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.
 
Physics news on Phys.org
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
 
g[x_] = D[f[x], x]

Note the underscore in g[x_].

(Alternatively, you could just do g = f')