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!
DSolve[xi^2*(f'[x]) + (1/2)*f[x]^2 - 1/2 == 0, f[x], x] // FullSimplify
. The ODE you fed Maple does not seem equivalent to the firstZFeqn
above, but maybe I'm blind to some obvious transformation. $\endgroup$ZFeqn
above. However, this answers my question of why the previous attempts were not finding the solutions that I expected - I forgot that MMA does not like equations of the type(f'[x])^2 = ...
! $\endgroup$