How do I use mathematica to implicitly solve differential equations of a single variable?
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 (li开发者_StackOverflow中文版ke 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.
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.
精彩评论