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

  • Thread starter Thread starter codemonkey209
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary
In Mathematica, to set a variable equal to a constant with a zero derivative, use the `Dt` function while specifying constants in the `Constants` option. By default, Mathematica assumes variables have non-zero derivatives, which may lead to unnecessary complexity in results. For example, using `Dt[a*x^n, x, Constants->{a, n}]` simplifies the output by treating 'a' and 'n' as constants. Alternatively, the `D` function can be used for partial derivatives if full derivatives are not needed. Understanding these options allows for more efficient calculations in Mathematica.
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
3
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K