Differential eq with square root numerical

In summary: Thanks a lot!Can you write the system down.In summary, x'(t) and (1-x(t))^(1/2) both approach zero when the numerical solution approach an extremum, but then (1-x(t)) also approaches zero, and in fact (1-x(t)) takes negative values, which makes the square root imaginary.
  • #1
xapiens
3
0
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)=(1-x(t))^(1/2) with initial condition x(2.1)=0.9975. The exact solution is x(t)=(1/4)(4t-t^2).

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!
 
Physics news on Phys.org
  • #2
Can you write the system down.
 
  • #3
Hi!

Initially I want to get the numerical solution of this very simple system.

x'(t)=(1-x(t))^(1/2) with initial condition x(2.1)=0.9975.Also I note that if I start with initial conditions in the maximum x(2)=1, the RK4 gives contant solution x(t)=1. That is the reason I have to start with x(2.1)=0.9975.
 
  • #4
You know that you can solve that analytically right? Another way to tackle this problem is by Newton's method, you define your points [itex]t_{i}[/itex], then you write down your equation at the point [itex]t_{i}[/itex], this then will lead to you computing the Jacobian and then it should only take a few iterations to get the answer.
 
  • #5
Yes! I know the exact solution. But I need to get the numerical solution of the differential equation. It is a warm up to a harder equation with similar problems.
 
  • #6
I found that Newtons method works very well for this kind of thing but you have to have a reasonable first guess though, or at least something random that the iteration can work with.
 
  • #7
xapiens said:
Any hint of how to get the correct numerical solution of this equation?

Thanks a lot!

You could hard-code the algorithm to follow the correct path over the underlying multisheet of the square root function, or eliminate the multi-function from the differential equation:

[tex]x'=\sqrt{1-x}[/tex]

[tex]x''=1/2(1-x)^{-1/2}(-x')[/tex]

[tex]x''=-1/2\frac{x'}{\sqrt{1-x}}[/tex]

[tex]x''=-1/2[/tex]

Now, in place of your original DE, use:

[tex]x''=-1/2;\quad x(t_0)=x_0,\quad x'(t_0)=\sqrt{1-x}[/tex]
 
  • #8
Jackmell, I think that this is a little specialised for the problem in hand (although it is a rather nice solution), it is just a warm up problem for him, I think he is asking for a more general method.
 
  • #9
hunt_mat said:
Jackmell, I think that this is a little specialised for the problem in hand (although it is a rather nice solution), it is just a warm up problem for him, I think he is asking for a more general method.

Let's do the easy one first:

xapiens said:
Yes! I know the exact solution. But I need to get the numerical solution of the differential equation. It is a warm up to a harder equation with similar problems.

The code below is the first approach in Mathematica using a modified Euler-method which maintains the correct path over the multisheet (Riemann surface of the complex square root).


Code:
platch = True; 
xold = 0; 
thet = 0; 
a = 1; 
dh = 0.01; 
myvals = Table[temp = 1 - xold; 
     If[platch == True && temp < 0, 
      {xold = 2 - xold; platch = False; a = -1; }]; 
     xnew = xold + a*Sqrt[1 - xold]*dh; 
     xold = xnew; {thet += dh, xnew}, {n, 1, 500}]; 
ListPlot[myvals, PlotStyle -> Red, Joined -> True]

And that gives the desired answer. Anyway, I think the problem with a standard numerical analysis of this DE, is that the algorithm is passing through the branch-point where the two branches of the root meet and since delta h is finite, it over-shoots the branch-point landing on a surface which has an imaginary component. In the algorithm above, I force the algorithm to follow a path which is always real. Maybe though I don't have this quite presented right but that's what I'm sticking with for now.

How about posting the harder one xapiens.
 
Last edited:

1. What is a differential equation with a square root?

A differential equation with a square root is an equation that involves a function and its derivative, where the function contains a square root term.

2. How do you solve a differential equation with a square root numerically?

To solve a differential equation with a square root numerically, you can use numerical methods such as Euler's method or Runge-Kutta methods. These methods involve breaking down the problem into smaller steps and using numerical calculations to approximate the solution.

3. Why are differential equations with square roots difficult to solve analytically?

Differential equations with square roots are difficult to solve analytically because they often do not have exact solutions that can be expressed in terms of simple functions, and therefore require numerical methods to approximate the solution.

4. Can a differential equation with a square root have multiple solutions?

Yes, a differential equation with a square root can have multiple solutions. This is because the square root function has two possible outputs for any given input, resulting in multiple solutions.

5. Are there any real-life applications of differential equations with square roots?

Yes, there are many real-life applications of differential equations with square roots, such as in physics, engineering, and economics. For example, in physics, the motion of a falling object subject to air resistance can be described by a differential equation with a square root term.

Similar threads

Replies
2
Views
986
Replies
5
Views
1K
  • Differential Equations
Replies
1
Views
624
  • Differential Equations
Replies
7
Views
332
  • Differential Equations
Replies
5
Views
2K
  • Differential Equations
Replies
1
Views
1K
  • Differential Equations
Replies
2
Views
1K
  • Differential Equations
Replies
3
Views
1K
  • Differential Equations
Replies
5
Views
608
  • Differential Equations
Replies
1
Views
717
Back
Top