Re: DSolve and N do not commute
- To: mathgroup at smc.vnet.net
- Subject: [mg40213] Re: [mg40184] DSolve and N do not commute
- From: Dr Bob <drbob at bigfoot.com>
- Date: Wed, 26 Mar 2003 02:42:02 -0500 (EST)
- References: <200303250804.DAA08372@smc.vnet.net>
- Reply-to: drbob at bigfoot.com
- Sender: owner-wri-mathgroup at wolfram.com
It's a bug. Here's the general solution:
general = a f'[r] + f''[r] == b f[r];
s0 = f /. First@DSolve[general, f, r] /. C -> A
general /. f -> s0 // Simplify
Function[{r}, E^((1/2)*(-a - Sqrt[
a^2 + 4*b])*r)*A[1] + E^((1/2)*(-a + Sqrt[
a^2 + 4*b])*r)*A[2]]
True
And here's the solution with those constants, with N before DSolve.
constants = {a -> (8/3)*2^(2/3), b -> (-(8/3))*2^(1/3)}; eq2 = N[general /.
constants];
s2 = f /. First@DSolve[eq2, f, r]
Function[{r}, C[1]/E^(3.174802103936397*
r) + (r*C[2])/
E^(3.174802103936397*r)]
Here's a simple check for correctness:
eq2 /. {f -> s2} // Simplify
(-2.116534735957597*C[2])/ E^(3.174802103936397*r) == 0
and that is zero only if C[2]==0. (How about that?)
eq2 //. {f -> s2, C[2] -> 0} // Simplify
True
Here's another check, going back to the general equation:
general /. Flatten@{f -> s2, constants} // Simplify;
Chop@%
(-2.1165347359575954*C[2])/E^(3.174802103936397*r) == 0
Again, setting C[2] to zero gives a correct solution.
s2[r] /. C[2] -> 0
C[1]/E^(3.174802103936397*r)
But if C[2] isn't zero, the solution is wrong, and that's a BUG.
Bobby
On Tue, 25 Mar 2003 03:04:52 -0500 (EST), arkadas ozakin
<arkadaso at hotmail.com> wrote:
> Take the following differential equation,
>
> eq = (f''[r] + 8 2^(2/3)/3 f'[r] == -8 2^(1/3)/3 f[r])
>
> DSolve[eq, f[r], r] gives something like
>
> f[r] -> C[1] Exp[k1 r] + C[2] Exp[k2 r]
>
> where k1 and k2 are two different numbers.
>
> However,
>
> DSolve[N[eq],f[r],r] gives something like
>
> f[r] -> (C[1] + C[2] r) Exp[k2num r]
>
> where k2num is the numerical version of the constant k2 above.
>
> I don't know how DSolve handles numerical constants, but the
> discrepancy between the two results wasn't something I expected
> (that's why it took me quite a bit of time to figure out what was
> going wrong in my longish Mathematica notebook...)
>
> Does anyone know why this happened? Is this a bug, or am I doing
> something wrong? Any suggestions for avoiding similar things in the
> future?
>
> arkadas
>
>
--
majort at cox-internet.com
Bobby R. Treat
- References:
- DSolve and N do not commute
- From: arkadaso@hotmail.com (arkadas ozakin)
- DSolve and N do not commute