Professional Documents
Culture Documents
dx
= -xI1 + y2 M
1
with initial conditions y(2)=1. This is separable with gHxL = -x and hHyL = 1+y
2 .
Start by defining Mathematica functions for g and h. Note the underscores; they matter.
g@x_D = -x
-x
h@y_D = 1 H1 + y ^ 2L
1
2
y +1
Use the result of the algebraic solution to define a function (a one-parameter family depending on C, actually)
representing the solution of the ODE.
sepVar.nb
Solving for C
Plug the initial conditions into the ODE solution and solve for C.
cSoln = Solve@odeSoln@x0, CD y0, CD
Solve::ifun :
Inverse functions are being used by Solve, so some solutions may not be found;
use Reduce for complete solution information.
::C 2 + >>
4
Lets return to the issue of the scary warning message later. For now, forge boldly ahead, substituting C=2+ 4
into the ODE solution.
ivpSoln@x_D = odeSoln@xD . cSoln@@1DD
y
ij 1 i i
yyz
tanjjj jj2 jj2 + zz - x2 zzzzz
{{
4{
k2 k k
-2
-4
-6
The solution blows up just below x=3. (You should calculate exactly where!) Ive continued the graph after that
point to highlight the singularity, but the behavior of the solution to the IVP is undefined once it "blows
up."
sepVar.nb
RHS = -x H1 + ivpSoln@xD ^ 2L
y
ij
ij 1 i i
yz
yyz
-x jjjtan2 jjj jj2 jj2 + zz - x2 zzzzz + 1zzz
{{
4{
k
k2 k k
{
RHS LHS
y
y
ij
ij 1 i i
yz
ij 1 i i
yyz
yyz
-x jjjtan2 jjj jj2 jj2 + zz - x2 zzzzz + 1zzz -x sec2 jjj jj2 jj2 + zz - x2 zzzzz
k
k
{
{
k
k
{
{{
4
4
k
k2
{
{
k2
If you remember your trig identities, youll see that these are equal. When looking at complicated expressions,
the FullSimplify[ ] function is amazingly useful...
FullSimplify@RHS LHSD
True
...so the IVP solution is indeed a solution of the ODE. Now check that the IVP solution satisfies the IC:
ivpSoln@x0D y0
True
...so our solution passes both the ODE check and the IC check. All done! Well, not quite.
which has multiple solutions because the tangent function is periodic (with period ).The solution C = 4 + 2 is
the principal value, but there are infinitely many other solutions obtained by adding to 4 + 2 any integer multiple of .
Taking into account the multiple solutions to the algebraic equation, the IVP solution is actually
-Tan@x ^ 2 2 - 2 - Pi 4 + n PiD
2
ji x
zy
tanjjjj- - n + + 2zzzz
2
4
k
{
where n is an integer. However, the tangent function is periodic with period , so the addition of an n phase
shift does not matter.
Thus the scary warning about inverse function was a false alarm. This will usually be the case for problems of
this sort, because well be inverting a function to get C, and then putting the value of C right back into the
function. You do things like this all the time in hand calculations, but dont always think about whats happening.
Heres the plot of the solution where weve used C = 143 + 2 + 4 instead of C = 2 + 4 . As expected, it is
identical to the solution with the principal value of C.
where n is an integer. However, the tangent function is periodic with period , so the addition of an n phase
shift does not matter.
4 sepVar.nb
Thus the scary warning about inverse function was a false alarm. This will usually be the case for problems of
this sort, because well be inverting a function to get C, and then putting the value of C right back into the
function. You do things like this all the time in hand calculations, but dont always think about whats happening.
Heres the plot of the solution where weve used C = 143 + 2 + 4 instead of C = 2 + 4 . As expected, it is
identical to the solution with the principal value of C.
Plot@-Tan@x ^ 2 2 - Pi 4 - 2 + 143 PiD, 8x, 2, 6<D
6
4
2
3
-2
-4
-6