       NDSolve with square root

• To: mathgroup at smc.vnet.net
• Subject: [mg120980] NDSolve with square root
• From: william cuervo <wfcuervo at gmail.com>
• Date: Sat, 20 Aug 2011 06:16:41 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```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!

```

• Prev by Date: Re: Shooting method
• Next by Date: Re: Parameter Optimization to match a PDE solution to experimental results
• Previous by thread: Solving coupled differential equations iteratively.
• Next by thread: Re: NDSolve with square root