4

I'm trying to force Mathematica to implicitly differentiate an ellipse equation of the form:

x^2/a^2+y^2/b^2 == 100

with a = 8 and b = 6.

The command I'm using looks like this:

D[x^2/a^2 + y^2/b^2 == 100/. y -> 3/4*Sqrt[6400-x^2], x]

where, y->3/4*Sqrt[6400-x^2] comes from solving y in terms of x.

I got this far by following the advice found here: http://www.hostsrv.com/webmaa/app1/MSP/webm1010/implicit

Input for this script is the conventional way that an implicit relationship beween x and y is expressed in calculus textbooks. In Mathematica you need to make this relationship explicit by using y[x] in place of y. This is done automatically in the script by replacing all occurances of y with y[x].

But the solution Mathematica gives does not have y' or dy/dx in it (like when I solved it by hand). So I don't think it's been solved correctly. Any idea on what command would get the program to solve an implicit differential? Thanks.

Simon
  • 14,631
  • 4
  • 41
  • 101
franklin
  • 1,800
  • 7
  • 32
  • 59

1 Answers1

8

The conceptually easiest option (as you mentioned) is to make y a function of x and use the partial derivative operator D[]

In[1]:= D[x^2/a^2 + y[x]^2/b^2 == 100, x]
        Solve[%, y'[x]]

Out[1]= (2 x)/a^2 + (2 y[x] y'[x])/b^2 == 0

Out[2]= {{y'[x] -> -((b^2 x)/(a^2 y[x]))}}

But for more complicated relations, it's best to use the total derivative operator Dt[]

In[3]:= SetOptions[Dt, Constants -> {a, b}];

In[4]:= Dt[x^2/a^2 + y^2/b^2 == 100, x]
        Solve[%, Dt[y, x]]

Out[4]= (2 x)/a^2 + (2 y Dt[y, x, Constants -> {a, b}])/b^2 == 0

Out[5]= {{Dt[y, x, Constants -> {a, b}] -> -((b^2 x)/(a^2 y))}}

Note that it might be neater to use SetAttributes[{a, b}, Constant] instead of the SetOptions[Dt, Constants -> {a, b}] command... Then the Dt doesn't carry around all that extra junk.

The final option (that you also mentioned) is to solve the original equation for y[x], although this is not always possible...

In[6]:= rep = Solve[x^2/a^2 + y^2/b^2 == 100, y]

Out[6]= {{y -> -((b Sqrt[100 a^2 - x^2])/a)}, {y -> (b Sqrt[100 a^2 - x^2])/a}}

And you can check that it satisfies the differential equation we derived above for both solutions

In[7]:= D[y /. rep[[1]], x] == -((b^2 x)/(a^2 y)) /. rep[[1]]

Out[7]= True

You can substitute your values a = 8 and b = 6 anytime with replacement rule {a->8, b->6}.

If you actually solve your differential equation y'[x] == -((b^2 x)/(a^2 y[x]) using DSolve with the correct initial condition (derived from the original ellipse equation) then you'll recover the solution for y in terms of x given above.

Simon
  • 14,631
  • 4
  • 41
  • 101
  • +1. I strongly agree with the suggestion to not set the attributes of `Dt` globally, since this may be quite error-prone. I am not even sure that showing this usage in the first place is a good idea - you could pass the options to `Dt` explicitly instead. – Leonid Shifrin Sep 15 '11 at 13:49
  • 1
    If you first set some symbols to constants for `Dt` globally, and then forget it and do some unrelated computations involving `Dt` and those symbols, you may get surprising results. The mentioned computations may invoke `Dt` in some unobvious way, say through top-level code is some system function. Worse yet, if someone esle wrote some package etc and did it there, and then you use that package, you won't even know about it, and the results will be *very* puzzling. – Leonid Shifrin Sep 16 '11 at 09:15
  • Actually, it is probably not as bad as I first thought, as `Dt` carries around the option settings. I still would prefer to not do this - but this is more a matter of personal preference. – Leonid Shifrin Sep 16 '11 at 09:31