# Why does NDSolve work with an initial condition but not a final condition?

I am using NDSolve to solve the two-dimensional time-dependent (2+1D) Schroedinger equation for a traveling gaussian wavepacket in free space. The exact solution is:

psi[x_, y_, t_] := (
4 E^(I (25 - t/2 + x) - ((25 - t + x)^2 + y^2)/(64 + 2 I t)) Sqrt[
2/\[Pi]])/(32 + I t)


Which at t=0 looks like:

If I specify only the initial conditions at t=0: psin[x,y,0]=psi[x,y,0], NDSolve works fine:

NDSolve[{I D[psin[x, y, t], {t, 1}] + 1/2 D[psin[x, y, t], {x, 2}] +
1/2 D[psin[x, y, t], {y, 2}] == 0, psin[x, y, 0] == psi[x, y, 0],
psin[-100, y, t] == 0, psin[100, y, t] == 0, psin[x, -100, t] == 0,
psin[x, 100, t] == 0}, psin, {x, -100, 100}, {y, -100, 100}, {t, 0,
50}, MaxStepSize -> 1]


Which at t=0 looks like:

But if I instead give only the final condition at t=50: psin[x,y,50]=psi[x,y,50], NDSolve does not work:

NDSolve[{I D[psin[x, y, t], {t, 1}] + 1/2 D[psin[x, y, t], {x, 2}] +
1/2 D[psin[x, y, t], {y, 2}] == 0,
psin[x, y, 50] == psi[x, y, 50], psin[-100, y, t] == 0,
psin[100, y, t] == 0, psin[x, -100, t] == 0,
psin[x, 100, t] == 0}, psin, {x, -100, 100}, {y, -100, 100}, {t, 0,
50}, MaxStepSize -> 1]

NDSolve::eerr: Warning: scaled local spatial error estimate of
84.65891274149153 at t = 0. in the direction of independent variable x is
much greater than the prescribed error tolerance. Grid spacing with 200 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 method options.


Which at t=0 looks like:

Why does NDSolve work with an initial condition but not a final condition? What can be done to get NDSolve to work with a final condition?

• try a change of variable tprime=50-t so then NDSolve will see your condition as an initial condition. – george2079 Nov 20 '17 at 0:16
• Can you please explain the details? – Michael B. Heaney Nov 20 '17 at 18:24

The problem is with inconsistent conditions. Look at

psi[-70, y, 0] // N // Simplify // Chop
psi[70, y, 0] // N // Simplify // Chop
psi[x, -40, 0] // N // Simplify // Chop
psi[x, 40, 0] // N // Simplify // Chop


The results are all 0 under a Chop, so that they match within tolerances the set bc's. However

psi[-70, y, 50] // N // Simplify // Chop
psi[70, y, 50] // Simplify // Chop
psi[x, -40, 50] // N // Simplify // Chop
psi[x, 40, 50] // N // Simplify // Chop


results in

0
(-6.11209*10^-7 + 5.43003*10^-6 I) E^((-0.0045403 + 0.00709421 I) y^2)
(-0.0000226642 - 0.0000300422 I) 2.71828^((0. + 1. I) x - (0.0045403 -
0.00709421 I) (x - 25.)^2)
(-0.0000226642 - 0.0000300422 I) 2.71828^((0. + 1. I) x - (0.0045403 -
0.00709421 I) (x - 25.)^2)


Your other conditions require these values of x and y be 0 for all t. The conditions are near enough to 0 at t = 0, but not near enough to 0 at t = 50, so that NDSolve experiences instability when you use the end condition.

• I fixed the boundary conditions so they are consistent, but it did not fix the problem. I revised the question to include the new boundary conditions. – Michael B. Heaney Nov 20 '17 at 18:22
• I tried with WorkingPrecision->50 and still get the warnings except for the inconsistent bc warning. It takes forever, but behavior along y = 0 for x from -100 to about +50 looks fairly close to psi. At x > 50 still blows up. Higher WP probably will not help much and will be too slow. It was the higher WP that alerted me to the inconstent bc's in your original problem. – Bill Watts Nov 21 '17 at 0:17