MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: DSolve Issues

  • To: mathgroup at
  • Subject: [mg88355] Re: DSolve Issues
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Sat, 3 May 2008 06:13:35 -0400 (EDT)
  • Organization: University of Bergen
  • References: <fveguc$5ed$>

The short answer is: Use Chop[] (look it up).

The longer answer is that (imprecise) floating point numbers should not 
be used in symbolic calculations.  Convert them to rationals using 
Rationalize[], or just use a parameter in their place.

0.0 is not the same as 0 in Mathematica.  The latter is exactly zero, 
while the former is only known to be approximately zero (in you case, 
approx. to 15 digits).  Mathematica keeps 0.0*x unevaluated because it 
is not sure that 0.0 is an exact zero.

To convince you that using imprecise numbers with DSolve is a bad idea, 
here's a typical example of what might go wrong:

Suppose that we solve an equation with floating point coefficients using 
Solve[].  Solve[] will substitute back the solutions into the equation 
and verify them.  Because of accumulated numerical errors it might find 
that some of the solutions are not correct, and drop them.  So Solve[] 
might not return all solutions if imprecise numbers were used in the 

Another note: avoid named starting with capital letters.  This way 
you'll never use a built-in name accidentally.  For example, the symbol 
K that you used is a built-in symbol.

donkorgi12 wrote:
> I am solving the following Differential Equation
> Phi''[r]+2*r^(-1)Phi'[r]+0.104479*Phi[r]==0 and Phi[0]==K (some
> constant)   ; kinda has a cos/sin solution
> 2.71828^(-0.323232 \[ImaginaryI] r) ((0.+
>      0. \[ImaginaryI]) + (0.+ 0. \[ImaginaryI]) 2.71828^(
>     0.646465 \[ImaginaryI] r) + (0.+ 1.54687 \[ImaginaryI]) K - (0.+
>       1.54687 \[ImaginaryI]) 2.71828^(0.646465 \[ImaginaryI] r) K)
> all divided by r.
> My problem is that Mathematica is not treating those "zeros".... as
> well zeros. Thus, the solution cannot really be used. In fact, if I
> manually reproduce the solution and remove those "zeros", then the
> solution is fine.
> I have another similar ODE Anyone have any ideas.
> Phi''[r]+2*r^(-1)Phi'[r]- 287.31*Phi[r]==0 and Phi[3R]==0(some
> constant)  ; kinda has a cosh/sinh solution
> As you might have notice I need to match these two solutions and their
> derivatives at some point.  The ratio of which gives me what I desire
> the value of R.
> Yet, Mathematica treats those "zeros" as something else.

  • Prev by Date: ExtraAxes for Plot[]
  • Next by Date: Re: DSolve Issues
  • Previous by thread: Re: DSolve Issues
  • Next by thread: Re: DSolve Issues