# Nonlinear PDE solver

I would like to solve the following nonlinear PDE:

$$\frac{\partial^2 \phi}{\partial x^2} - \frac{\partial^2 \phi}{\partial t^2} = \lambda |\phi|^2 \phi$$

I was trying:

NDSolve[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3, f[x, 0] == Sin[2*Pi*x], f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1}]


but, I am consistenly getting NDSolve::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve.

Is there any solver for non-linear PDEs?

The error message is misleading. NDSolve fails, because not enough boundary conditions in t have been supplied. If, for instance, (D[f[x, t], t] /. t -> 0) == 0 is added, then

sol = First@NDSolve[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3,
f[x, 0] == Sin[2*Pi*x], (D[f[x, t], t] /. t -> 0) == 0,
f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1}];


yields

Plot3D[f[x, t] /. sol, {x, 0, 1}, {t, 0, 1}, AxesLabel -> {x, t, f},
LabelStyle -> Directive[Black, Bold, 12]]


In version 12.0 you can also solve this with the FEM:

NDSolveValue[{D[f[x, t], x, x] - D[f[x, t], t, t] == f[x, t]^3,
f[x, 0] == Sin[2*Pi*x], (D[f[x, t], t] /. t -> 0) == 0,
f[0, t] == 0, f[1, t] == 0}, f, {x, 0, 1}, {t, 0, 1},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement"}}]


Plot the difference between the solutions:

Plot3D[(f[x, t] /. sol) - solFEM[x, t], {x, 0, 1}, {t, 0, 1}]


## protected by xzczdSep 19 '17 at 2:54

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).