World's most popular travel blog for travel bloggers.

# The number of operations of Explicit and Implicit Euler for 1D hear equation

, ,
Problem Detail:

I'm studying with "Numerical Solution of Partial Differential Equations by K.W.Morton and D.F.Mayers". On page 25, it says "2(add) + 2(multiply) operations per mesh point for the explicit algorithm (2.19)", but it seems 3(add) + 2(multiply) to me, how did I get wrong?

(2.19) $U_j^{n+1}=U_j^{n}+\mu(U_{j+1}^{n}-2U_j^{n}+U_{j-1}^{n})$

My counting is

2(add) and 1(multiply) inside the bracket

1(multiply) for $\mu$ and the brackets

1(add) for $U_j^{n}$ and the rest

###### Answered By : Tom van der Zanden

Note that

$U^n_j + \mu (U^n_{j+1}-2U^n_j+U^n_{j-1}) = (1-2\mu)U^n_j+\mu(U^n_{j+1}+U^n_{j-1})$

$1-2\mu$ may be precomputed.