[Date Index]
[Thread Index]
[Author Index]
Re: How to prevent Solve from DSolve?
*To*: mathgroup at christensen.cybernetics.net
*Subject*: [mg976] Re: [mg888] How to prevent Solve from DSolve?
*From*: Allan Hayes <hay at haystack.demon.co.uk>
*Date*: Thu, 4 May 1995 06:04:34 -0400
>From: "Richard Q. Chen" <chen at fractal.eng.yale.edu>
>Subject: [mg888] How to prevent Solve from DSolve?
>I find it very frustrating that Mma always tries
>to give explicit solutions to an ODE, even if the solutions are
>so complicated as to be useless.
>
>In[2]:= Needs["Calculus`DSolve`"]
>
>In[3]:= DSolve[2 y[x] + (x + y[x]) y'[x] == 0, y[x], x]
>
>In this particular case I had to use pencil and paper and I obtained
>the much simpler implicit solution
>
> f(x,y) = y*(y+2x)^2 = C[1]
>
> This is the kind of solution I wanted.
>How can I prevent DSolve from using Solve to give complicated
>solution?
We can use Block as follows. Note that the effect is only inside
Block[...] and has no effect on Solve outside this.
In[1]:=
Needs["Calculus`DSolve`"]
In[2]:=
Block[{Solve = ss},
DSolve[2 y[x] + (x + y[x]) y'[x] == 0, y[x], x]
]
Out[2]=
2
ss[y[x] (3 x + y[x]) == C[1], y[x]]
In[3]:=
impsol = %[[1]]
Out[3]=
2
y[x] (3 x + y[x]) == C[1]
Caution: If Solve is used in DSolve then this technique might cause
problems (not what you got by hand).
Check the solution
In[4]:=
D[impsol,x]
Out[4]=
2
(3 x + y[x]) y'[x] + 2 y[x] (3 x + y[x]) (3 + y'[x]) == 0
In[5]:=
Simplify[%]
Out[5]=
3 (3 x + y[x]) (2 y[x] + x y'[x] + y[x] y'[x]) == 0
We added an extra factor.
Investigate graphically
In[6]:=
<<Graphics`ImplicitPlot`
eqn = impsol/.y[x] ->y
Out[6]=
2
y (3 x + y) == C[1]
Make some rules to give C[1] a selection of values.
In[7]:=
cs = List/@Thread[Rule[C[1], Range[-4,4]]]
Out[7]=
{{C[1] -> -4}, {C[1] -> -3}, {C[1] -> -2}, {C[1] -> -1},
{C[1] -> 0}, {C[1] -> 1}, {C[1] -> 2}, {C[1] -> 3},
{C[1] -> 4}}
In[8]
ImplicitPlot[eqn/.cs, {x, -5, 5},{y, -5, 5},
PlotPoints -> 50, AxesStyle -> GrayLevel[.7]
];
This does not show the line y + 3x == 0.
That's because (y+3x)^2 does not change sign when it crosses this line.
Allan Hayes
hay at haystack.demon.co.uk
Prev by Date:
**Re: how can I do this functionally?**
Next by Date:
**Books**
Previous by thread:
**How to slow down plotting of curves?**
Next by thread:
**Books**
| |