2

I have this little script to derive implicitly

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

Example:

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

1 == y + x y'[x] + 3 y^2*y'[x]

and then, to obtain the expression for y'[x], I use

Solve[1 == y + x y'[x] + 3 y^2*y'[x],y'[x]] //FullSimplify

How can I get all these steps in one line?

I'd like to have something like

$PrePrint = # /. {D[y_, x_, NonConstants -> {y_}] :> y'[x]} &; //Solve...
Karsten7
  • 27,448
  • 5
  • 73
  • 134
Fernando Silva
  • 187
  • 1
  • 2
  • 7

1 Answers1

3

If my interpretation of your question is correct, the following code should produce the desired behaviour.

prePrint[input_] := 
  Module[{solveFor}, 
   input /. {D[y_, x_, NonConstants -> {y_}] :> (solveFor = y'[x])} //
      If[OwnValues[solveFor] === {}, input, Solve[#, solveFor]] & // 
    FullSimplify];
$PrePrint = prePrint;

Test

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

{{y'[x]] -> (1 - y)/(x + 3 y^2)}}

Karsten7
  • 27,448
  • 5
  • 73
  • 134