       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:= Needs["Calculus`DSolve`"]
>
>In:= 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
>
> 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:=
Needs["Calculus`DSolve`"]

In:=
Block[{Solve = ss},
DSolve[2 y[x] + (x + y[x]) y'[x] == 0, y[x], x]
]
Out=
2
ss[y[x] (3 x + y[x])  == C, y[x]]
In:=
impsol = %[]
Out=
2
y[x] (3 x + y[x])  == C

Caution: If Solve is used in DSolve then this technique might cause
problems (not what you got by hand).

Check the solution

In:=
D[impsol,x]
Out=
2
(3 x + y[x])  y'[x] + 2 y[x] (3 x + y[x]) (3 + y'[x]) == 0
In:=
Simplify[%]
Out=
3 (3 x + y[x]) (2 y[x] + x y'[x] + y[x] y'[x]) == 0

Investigate graphically

In:=
<<Graphics`ImplicitPlot`

eqn = impsol/.y[x] ->y

Out=
2
y (3 x + y)  == C

Make some rules to give C a selection of values.

In:=

Out=
{{C -> -4}, {C -> -3}, {C -> -2}, {C -> -1},
{C -> 0}, {C -> 1}, {C -> 2}, {C -> 3},
{C -> 4}}

In
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?