4
$\begingroup$

I am trying to introduce myself to the total derivative Dt in the documentation tutorial/TotalDerivatives. But I ran into what I think is a problem.

There seems to be a serious problem in the documentation tutorial/TotalDerivatives. It says that Clear[y] removes the definition for the derivative of y. But it doesn't.

Dt[x^2 + y^2 + z^2, x]

2 x + 2 y Dt[y, x] + 2 z Dt[z, x]

Then I did:

y /: Dt[y, x] = 0

0

Followed by:

Dt[x^2 + y^2 + z^2, x]

2 x + 2 z Dt[z, x]

Then I tried to clear y.

Clear[y]

But look what happens when I try Dt again. It doesn't return the first answer again.

Dt[x^2 + y^2 + z^2, x]

2 x + 2 z Dt[z, x]

Now I quit the kernel and start again, not re-evaluating the notebook, and use the TagUnset rule, which does work.

Dt[x^2 + y^2 + z^2, x]

2 x + 2 y Dt[y, x] + 2 z Dt[z, x]

TagSet again:

y /: Dt[y, x] = 0

0

Evaluate again:

Dt[x^2 + y^2 + z^2, x]

2 x + 2 z Dt[z, x]

Then TagUnset:

y /: Dt[y, x] =.

Evaluate again and it works properly.

Dt[x^2 + y^2 + z^2, x]

2 x + 2 y Dt[y, x] + 2 z Dt[z, x]

Is this a bug in the documentation or am I missing something?

$\endgroup$
  • $\begingroup$ What about ClearAll? $\endgroup$ – Marius Ladegård Meyer Jul 11 '15 at 18:13
  • $\begingroup$ @MariusLadegårdMeyer It seems that ClearAll works for this example in version 8, but not in version 10.1. Perhaps there is some caching going on in the evaluation of Dt[x^2+y^2+z^2,x], because Clear and ClearAll do indeed clear the UpValues of y, as the documentation says they should. $\endgroup$ – Jens Jul 11 '15 at 18:46
5
$\begingroup$

I speculate about the reason for this behavior in the comment, but no matter whether that's the correct explanation, I would say that the documentation isn't wrong because I can verify the removal of the UpValues using Definition. However, this doesn't solve the problem.

As a workaround that requires less typing than the UnSet approach in the question, I would suggest using Remove as follows:

y /: Dt[y, x] = 0

(* ==> 0 *)

Dt[x^2 + y^2 + z^2, x]

(* ==> 2 x + 2 z Dt[z, x] *)

Definition[y]

(* ==> y /: Dt[y, x] = 0 *)

Clear[y]

Definition[y]

(* ==> Null *)

Dt[x^2 + y^2 + z^2, x]

(* ==> 2 x + 2 z Dt[z, x] *)

Remove[y]

Dt[x^2 + y^2 + z^2, x]

(* ==> 2 x + 2 y Dt[y, x] + 2 z Dt[z, x] *)
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.