Skip to main content
correcting incorrect screenshot
Source Link
Brad
  • 135
  • 13

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

EDIT: I have put this third equation into Maple, and have found the solution required... I am very interested to know why Mathematica couldn't/shouldn't be able to handle this! See the below image

EDIT2: Maple finds the solution! Removed the screenshot of Maple since there was a typo in the factors. Easiest route is to square root each side of the equation and get the first order ODE in the form f'(x) rather than (f(x)')^2, which Mathematica seemingly struggles to solve. Problem is now solved; thanks to all of Michael, Ulrich and Alexei!

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

EDIT: I have put this third equation into Maple, and have found the solution required... I am very interested to know why Mathematica couldn't/shouldn't be able to handle this! See the below image: Maple finds the solution!

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

EDIT: I have put this third equation into Maple, and have found the solution required... I am very interested to know why Mathematica couldn't/shouldn't be able to handle this!

EDIT2: Removed the screenshot of Maple since there was a typo in the factors. Easiest route is to square root each side of the equation and get the first order ODE in the form f'(x) rather than (f(x)')^2, which Mathematica seemingly struggles to solve. Problem is now solved; thanks to all of Michael, Ulrich and Alexei!

maple description
Source Link
Brad
  • 135
  • 13

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

EDIT: I have put this third equation into Maple, and have found the solution required... I am very interested to know why Mathematica couldn't/shouldn't be able to handle this! See the below image: Maple finds the solution!

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.

EDIT: I have put this third equation into Maple, and have found the solution required... I am very interested to know why Mathematica couldn't/shouldn't be able to handle this! See the below image: Maple finds the solution!

Source Link
Brad
  • 135
  • 13

DSolve to obtain a tanh solution

We are given a simple ODE with BCs:

$\xi^2 \frac{df^2}{dx^2} + f - f^3 = 0$

$f(x=0) = 0$

$\\f(x\to\infty) = 1$

On paper this is quite easy to solve. One can obtain the solution

$f(x) = \operatorname{tanh}\left(\frac{x}{\sqrt{2}\xi}\right).$

The actual physics of the problem needs not a particular boundary at infinity, but just that far away from $x=0$ (or many $\xi$ lengths away), the value of $f$ tends to $1$ (here, $f$ has been normalised already).

This problem is a special (zero-field) case of a more general problem, so later I will try and generalise this approach to something that I don't know the analytic solution to easily. However, I am having trouble even obtaining this simple case in Mathematica. I am trying to use DSolve to find an analytic solution. I show three attempts.

Solving without the boundary conditions, to implement later

First, the standard approach

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn}, f[x], x]

However, this gives me a horrid result, in terms of Jacobi functions.

Solving with the boundary conditions

Secondary, with the BCs as well

ZFeqn = xi^2 * f''[x] + f[x] - f[x]^3 == 0

sol = DSolve[{ZFeqn, f[0] == 0, f[Infinity] == 1}, f[x], x]

This runs for a little while (1 minute) and then gives up. I have seen some previous posts discuss how to explicitly deal with boundary conditions at infinity, but to avoid that...

Implementing the boundary condition by hand

As is generally a good idea, we can manipulate first. We multiply by $f'$ and perform the integral, applying the BC at infinity to find the integration constant ($1/2$). We now solve the 1st order ODE with one BC

ZFeqn = xi^2 * (f'[x])^2 + f[x] - (1/2)*f[x]^3 - 1/2 == 0

sol = DSolve[{ZFeqn, f[0] == 0}, f[x], x]

However, even this finds a solution in terms of inverse elliptic functions - not the simple tanh function I expect!

Any further wisdom would be greatly appreciated.