Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem performing a substitution in a multiple derivative

I have a basic problem in Mathematica which has puzzled me for a while. I want to take the m'th derivative of x*Exp[t*x], then evaluate this at x=0. But the following does not work correct. Please share your thoughts.

D[x*Exp[t*x], {x, m}] /. x -> 0

Also what does the error mean

General::ivar: 0 is not a valid variable.

Edit: my previous example (D[Exp[t*x], {x, m}] /. x -> 0) was trivial. So I made it harder. :) My question is: how to force it to do the derivative evaluation first, then do substitution.

like image 306
Qiang Li Avatar asked Jan 27 '11 00:01

Qiang Li


1 Answers

As pointed out by others, (in general) Mathematica does not know how to take the derivative an arbitrary number of times, even if you specify that number is a positive integer. This means that the D[expr,{x,m}] command remains unevaluated and then when you set x->0, it's now trying to take the derivative with respect to a constant, which yields the error message.

In general, what you want is the m'th derivative of the function evaluated at zero. This can be written as

Derivative[m][Function[x,x Exp[t x]]][0]

or

Derivative[m][# Exp[t #]&][0]

You then get the table of coefficients

In[2]:= Table[%, {m, 1, 10}]
Out[2]= {1, 2 t, 3 t^2, 4 t^3, 5 t^4, 6 t^5, 7 t^6, 8 t^7, 9 t^8, 10 t^9}

But a little more thought shows that you really just want the m'th term in the series, so SeriesCoefficient does what you want:

In[3]:= SeriesCoefficient[x*Exp[t*x], {x, 0, m}]
Out[3]= Piecewise[{{t^(-1 + m)/(-1 + m)!, m >= 1}}, 0]

The final output is the general form of the m'th derivative. The PieceWise is not really necessary, since the expression actually holds for all non-negative integers.

like image 126
Simon Avatar answered Sep 18 '22 13:09

Simon