Processing math: 100%

 

 

 

Parts of Code for the Crank-Nicolson Scheme

We can code in an efficient way the Crank-Nicolson algortihm by first multplying the matrix ˜Vj1=(2ˆIαˆB)Vj1, with our previous vector Vj1 using the matrix-vector multiplication algorithm for a tridiagonal matrix, as done in the forward-Euler scheme. Thereafter we can solve the equation (2ˆI+αˆB)Vj=˜Vj1, using our method for systems of linear equations with a tridiagonal matrix, as done for the backward Euler scheme.