Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4515

Re: NDSolve with square root

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: NDSolve with square root
Date 2011-08-21 09:38 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j2qjmv$d30$1@smc.vnet.net> (permalink)
References <201108201016.GAA04950@smc.vnet.net>

Show all headers | View raw


If you make the approximate initial condition exact by using Rationalize...

   DSolve[{x'[t] == Sqrt[1 - x[t]],
   x[Rationalize[2.1]] == Rationalize[0.9975]}, x[t], t]

... then you'll get TWO solutions:

{{x[t] -> (-21 + 110*t - 25*t^2)/100}, {x[t] -> (4*t - t^2)/4}}

As can readily be checked, the first solution is valid for t <= 11/5 
whereas the second is valid for t < 2 -- and NOT when t = 2.1 !

On 8/20/11 6:16 AM, william cuervo wrote:
> Hi!
>
> I have to solve a system of two coupled nonlinear ordinary differential
> equations. In the function that defines the system there are terms with
> square root of the dependant variables. I tried to solve the system
> numerically but in the nmerical solution I get violent oscillations.
>
>
> Then I realized that the same problem appears in the numerical solution of
> this very simple exactly solvable differential equation:
>
> x'[t] == Sqrt[1 - x[t]] , x[2.1] == 0.9975
>
> The exact solution is x(t)=(1/4)(4t-t^2).
>
> I tried:
> NDSolve[{x'[t] == Sqrt[1 - x[t]] , x[2.1] == 0.9975`}, x, {t, -5, 5},
> MaxSteps ->  4000000]
>
> using ExplicitEuler, ExplicitRungeKutta and MidPoint Methods.
>
> It seems to me that the problem is the square root (1-x(t))^(1/2). When the
> numerical solution approach an extremum, then x'(t) and (1-x(t))^(1/2) both
> approach zero. But then (1-x(t)) also approaches zero, and in fact (1-x(t))
> takes negative values, that makes the square root imaginary.
>
> I explore the situation with the fourth-order Runge-Kutta method with step
> h=0.2 and in the firt iteration I find the complex value:
>
> x(2.1)=1.00463+ 0.0042963 I
>
> The same happens with the Euler method and the MidPoint Method
>
> Any hint of how to get the correct numerical solution of this equation???
>
> Thanks a lot!
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: NDSolve with square root Murray Eisenberg <murray@math.umass.edu> - 2011-08-21 09:38 +0000

csiph-web