How to Set a Variable Equal to a Constant with Zero Derivative in Mathematica?

  • Context: Mathematica 
  • Thread starter Thread starter codemonkey209
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 3K views
codemonkey209
Messages
1
Reaction score
0
Hello everyone,
I just started using Mathematica and was wondering how do you set a variable, such as 'A' or 'B', equal to a constant whose derivative is equal to zero. So for example if I were to input something like this:

Dt[A*E^(2 x)*Cos[3 x] + B*E^(2x)*Sin[3 x], {x, 2}]

it wouldn't include something like this in the answer:

Dt[B, x]

but instead take it to be zero thus simplifying the outputted answer.
 
Physics news on Phys.org
Unless you specify that a variable is a constant, Mathematica will assume that it has a non-zero total derivative. For instance, if you want to compute the total derivative with respect to x of the function a*x^n, a naive application of the Dt method gives you the following:

Code:
 In[1]:= Dt[a*x^n, x]
Out[1]:= x^n Dt[a, x] + a x^n (n/x + Dt[n, x] Log[x])

This is perfectly correct since it represents a general application of the Leibniz rule for derivatives. However, if you know that a and n are independent of x, there's clearly more information in the answer than is necessary. Hence, you might specify that a and n are constants as follows:

Code:
 In[2]:= Dt[a*x^n, x, Constants->{a, n}]
Out[2]:= a n x^(-1 + n)

This is all mentioned in the first paragraph of the Mathematica documentation for Dt, by the way.
 
Or you can just use "D" instead of "Dt" unless you WANT the full derivatives for some things but not others?
 
Hepth said:
Or you can just use "D" instead of "Dt" unless you WANT the full derivatives for some things but not others?

Well, yes; in fact my first thought was to point out that pretty much the same thing could be achieved by computing the partial derivative. However, I assume that there's some particular significance to the fact that he/she has gone to the trouble of using Dt[] to compute the total derivative.