Nonlinear PDE solver

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]]

enter image description here


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}]

enter image description here