2

Consider the following line of code:

D[x == y^3 + x y, x, NonConstants -> y]

The output would be:

1 == y + x D[y, x, NonConstants -> {y}] + 3 y^2 D[y, x, NonConstants -> {y}]

This is a confusing and cumbersome notation for the more natural:

1 == y + x y' + 3y^2 y'

I am trying to use the Notation package to help me replace the messy, default, output with the more natural one.
I have not succeeded.

Of-course I have read this Q. The answer, if relevant, seems inaccessible to me, unfortunately.
Any help would be appreciated.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Trevor
  • 237
  • 1
  • 4
  • Related or a duplicate: How to make traditional output for derivatives. Otherwise you should improve your question to make it clearer. – Artes Oct 08 '13 at 20:03
  • @artes: I don't see how I can change the display/notation of an implicit derivative using the answers supplied. Can you? – Trevor Oct 08 '13 at 21:20
  • expr /. D[y, x, NonConstants -> {y}] :> y'[x] yields 1 == y + x y'[x] + 3 y^2 y'[x]. – Artes Oct 11 '13 at 21:55
  • @Artes, thanks for the reply. Is there a way to make such a change permanent? As it is, it seems I need to post-fix each expression with your addition. – Trevor Oct 11 '13 at 22:10
  • I'm not sure what you are asking but I guess if you have more equations you can do it once e.g. { l1==r1, l2==r2,..., ln==rn} /. D[y, x, NonConstants -> {y}] :> y'[x]. – Artes Oct 11 '13 at 22:29
  • you're not satisfied with the result of D[x == y[x]^3 + x y[x], x] /. {y[x] :> y, y'[x] :> y'}, which is exactly the form you wanted? – murray Oct 12 '13 at 03:00
  • You have typo xy in the original implicit equation; it should be x y. – murray Oct 12 '13 at 03:00
  • @Murray,Artes , It is the result I wanted. What I'm asking, is if there's a way to hijack D[..., NonConstants->y], in such a way as to make this change permanent? So I wouldn't have to apply it specifically to each (group of) expression. Rather, do it once per-session. – Trevor Oct 12 '13 at 09:01

2 Answers2

3

I would consider using Dt:

Dt[x == y^3 + x y, x]
(* 1 == y + x Dt[y, x] + 3 y^2 Dt[y, x] *)

You can specify literal constants with SetAttributes:

ClearAll[a];
SetAttributes[a, Constant];
Dt[(x^2 + y^2)^2 == a^2 x y, x]
(* 2 (x^2 + y^2) (2 x + 2 y Dt[y, x]) == a^2 y + a^2 x Dt[y, x] *)

If x and y might become dependent variables, then omit the second argument and you get:

de = Dt[(x^2 + y^2)^2 == a^2 x y]
(* 2 (x^2 + y^2) (2 x Dt[x] + 2 y Dt[y]) == a^2 y Dt[x] + a^2 x Dt[y] *)

You can turn y into an explicit function of x:

de /. y -> y[x]
(* 2 (x^2 + y[x]^2) (2 x Dt[x] + 2 Dt[x] y[x] y'[x]) == a^2 Dt[x] y[x] + a^2 x Dt[x] y'[x] *)

If you want to turn x into the dependent variable, you can replace Dt[x] by 1:

de /. y -> y[x] /. Dt[x] -> 1
(* 2 (x^2 + y[x]^2) (2 x + 2 y[x] y'[x]) == a^2 y[x] + a^2 x y'[x] *)
Michael E2
  • 235,386
  • 17
  • 334
  • 747
1

Based on the comments above I believe you are merely looking for a way to automate Artes' replacement. Using $PrePrint:

$PrePrint = # /. {D[y_, x_, NonConstants -> {y_}] :> y'[x]} &;

Now:

D[x == y^3 + x y, x, NonConstants -> y]
1 == y + x y'[x] + 3 y^2 y'[x]

You could also use $Post or Format or MakeBoxes depending on your specific needs.
Using MakeBoxes is usually robust and does not tie up $Post or $PrePrint.

MakeBoxes[D[y_, x_, NonConstants -> {y_}], fmt_] := ToBoxes[y'[x], fmt]
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371