# Solving an equation in space and time using the Crank-Nicolson approach

Assume I have the following equation (light propagating in $z$-direction through the matter): $$id_zu+d^2_ru=0$$ with $u(z, r)$ being a complex wave. The time scale in this equation is $$t\equiv t_\text{lab}-zn_0/c$$ I know how to solve that equation using a Crank-Nicolson-algorithm: I can reformulate it with $$\partial_zu_m^{n+\frac{1}{2}}=\frac{u^{n+1}_m-u_m^n}{dz}$$ and $$\partial_r^2u_m^{n+\frac{1}{2}}=\frac{\partial_r^2u^{n+1}_m+\partial_r^2u^n_m}{2}$$ resulting in the equation $$\left[1-i\cdot\frac{dz}{2}\partial_r^2\right]u_m^{n+1}=\left[1+i\cdot\frac{dz}{2}\partial_r^2\right]u_m^{n}$$ which can be solved using linear algebra.

But what happens if I add a time dependence, such that the first equation changes to $$id_zu+d_r^2u+d_t^2u=0$$ with $u(z, r, t)$? How do I then have to reformulate my approach from above, after $dt=dz\cdot n_0/c$? Or do I have to use a completely different approach?

• I don't understand what problem are you solving. How time (time scale?) comes into the first stationary equation? Or do you solve it via iterations with pseudo-time crank-nicolson? – VorKir May 5 '17 at 20:31
• @VorKir: First I solve the time-independent equation. But now I want to solve the time-dependent equation, where dz is linked with dt, and I do not know, how. – arc_lupus May 5 '17 at 21:39
• So what you have (if $n_0$ and $c$ are constants) is a second order in $z$ equation, right? Then you just need another finite-difference scheme and thus, to choose an approximation for this $u_{zz}$ term (which will lead to at least three layers in $z$ with indices, say, ${}^{m-1}, {}^{m}, {}^{m+1}$). But for second-order equation you also need an additional boundary condition in $z$. Do you have it? – VorKir May 5 '17 at 21:50
• I want to solve the equation for dz, thus I am not sure why I need boundary conditions for z? – arc_lupus May 6 '17 at 5:54

This question is confusing. At first you are speaking of a steady-state equation, and suddenly you speak of a time scale...

I will try to clarify the following. From the numerical PDEs standpoint, you could classify physical phenomena as time-dependent or time-independent. LeVeque's book is a solid reference for this. Usually, time-independent phenomena are described via elliptic partial differential equations (PDEs), which can be discretized thus yielding a system of equations, whose solution represents an approximation for the state of the simulated system in a snapshot of time.

Two notes:

1. A time-periodic dependence, yields time-independence when formulated in the frequency domain.
2. If the PDE is linear/non-linear then the arising system of equations will be linear/non-linear... In the latter, clearly "linear algebra" methods won't suffice.

Time-dependent problems require time-wise integration. The Crank-Nicolson-method is usually used for time-dependent problems. In time-dependent problems, snapshots of the system behavior in time are solved progressively, and their temporal evolution is guided by the time integration method.

Your question seems to be mixing temporal dependence concepts. If you have an elliptic PDE (let us say it is linear), then you must discretize, using any space-oriented discretization methods. This will yield a linear system of equations with properties you can leverage in order to choose your method for solving it. Non-periodical time-dependent PDEs, e.g. parabolic PDEs, will require a time integration method. However, time integration methods can be explicit or implicit, and their numerical stability must be ensured. The choice of explicit vs. implicit, depends on how hard it is to ensure this numerical stability. Other aspects matter as well: Dispersion, physics-dependent grid refinement conditions, and numerical accuracy, among others.

In your situation, I would focus on solving the elliptic problem first. Once you understand this, proceed to introduce time dependence, and study which time integration method will yield the best results.