I am trying to used NDsolve to solve Nonlinear Schroedinger Equation:
NDSolve[{I D[u[x, t], t] == -0.5*D[u[x, t], x, x] + 0.5*x^2*u[x, t] +
Abs[u[x, t]]^2 u[x, t], u[x, 0] == Exp[I*x]}, u, {t, 0, 2}, {x, 0,
2}]
The above step is not working, I need to get the value of u may be real and imaginary and plot3D for both.
Thanks

u[x, 0]in the equations... where is the equals sign?u[x, 0] == ...? Same thing forExp[I*x]. – flinty Sep 15 '21 at 14:22at t = 2.in the direction of independent variable x is much greater than the prescribed error tolerance... I'm using v12.3.1. – flinty Sep 15 '21 at 14:28NDSolve::eerr: Warning: scaled local spatial error estimate of 361.1054605875608
– user62716 Sep 15 '21 at 14:31at t = 2.in the direction of independent variable x is much greater than the prescribed error tolerance. Grid spacing with 25 points may be too large to achieve the desired accuracy or precision. A singularity may have formed or a smaller grid spacing can be specified using the MaxStepSize or MinPoints methodNDSolve. I know you're solving problem defining in open domain and in traditional math the b.c. isn't often explicitly given, but b.c.s approximating the open boundary is necessary for numeric calcalation, see e.g. this. You'll find even more related question under [tag:boundary-condition-at-infinity]. – xzczd Sep 15 '21 at 16:15