开发者

Mathematic D and Dt not behaving properly?

The derivative functions D and Dt don't appear to be functioning as advertised. Following the first example in the "Properties and Relations" section of http://reference.wolfram.com/mathematica/ref/Constants.html I have:

In[1]:= {Dt[ax^2 + b, x, Constants -> {a, b}], D[ax^2 + b, x]}

Out[1]= {2 ax Dt[ax, x, Constants -> {a, b}], 0}

I've duplicated the input, but the output is totally different. How do I get the expected output { 2 a x, 2 a x}?

I am using Mathematica 8.0.1.0 64-bit as installed at Rutge开发者_如何学Crs University.


You need a space between a and x, otherwise it thinks you're talking about a variable named ax:

In[2]:= {Dt[a x^2 + b, x, Constants -> {a, b}], D[a x^2 + b, x]}

Out[2]= {2 a x, 2 a x}


(I realize this isn't really answering the OP's question. But given the level of the question, along with OP's desire to use the Contants option, the following info may prove useful for others in the future.)

My 2 cents on Dt.

IMO, using the Constants option is less than ideal---mainly because it produces messy output. For example:

In[1]:= Dt[x^a y^b, Constants -> {a, b}]

Out[1]= a x^(-1 + a) y^b Dt[x, Constants -> {a, b}] + 
 b x^a y^(-1 + b) Dt[y, Constants -> {a, b}]

Am I the only one who finds the above behavior annoying/redundant? Is there a practical reason for this design? If so, please educate me... :)

Alternative approaches:

If you don't want to use the Constants option, here are some alternative approaches.

Use UpValues to force constants.

In[2]:= Remove[a, b];
        a /: Dt[a] = 0;
        b /: Dt[b] = 0;
        Dt[x^a y^b]

Out[5]= a x^(-1 + a) y^b Dt[x] + b x^a y^(-1 + b) Dt[y]

Use Attributes. (i.e., give certain symbols the Constant Attribute.

In[6]:= Remove[a, b];
        SetAttributes[{a, b}, Constant];
        Dt[x^a y^b]

Out[8]= a x^(-1 + a) y^b Dt[x] + b x^a y^(-1 + b) Dt[y]

Use Rules to alter the output of the main Dt[] expression.

In[9]:= Remove[a, b];
        Dt[x^a y^b] /. Dt[a] -> 0 /. Dt[b] -> 0

Out[10]= a x^(-1 + a) y^b Dt[x] + b x^a y^(-1 + b) Dt[y]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜