Found a typo? Is this solution unclear? Let us know here. Please rate my easiness! It's quick and helps everyone guide their studies.
By the Taylor series expansion,
![{\displaystyle u(x,t+\Delta t)=u(x,t)+\Delta t\;u_{t}(x,t)+O((\Delta t)^{2}).\,}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/adb8180f70b989bca3906162787dc291396c50d9)
If we isolate in the above, we get that
![{\displaystyle u_{t}(x,t)={\frac {u(x,t+\Delta t)-u(x,t)}{\Delta t}}.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/c090984c41a42df91de9757bab8ebc4bd08021c5)
Similarly, by Taylor series expansion, we have
![{\displaystyle u(x+\Delta x,t)=u(x,t)+\Delta x\;u_{x}(x,t)+{\frac {(\Delta x)^{2}}{2!}}u_{xx}(x,t)+{\frac {(\Delta x)^{3}}{3!}}u_{xxx}(x,t)+O((\Delta x)^{4})}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/d886fa8c46630b6d8bf1ffed577e8f6e7c01c28f)
and
![{\displaystyle u(x-\Delta x,t)=u(x,t)-\Delta x\;u_{x}(x,t)+{\frac {(\Delta x)^{2}}{2!}}u_{xx}(x,t)-{\frac {(\Delta x)^{3}}{3!}}u_{xxx}(x,t)+O((\Delta x)^{4}).}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/f7c1689d91990510a061b5c8c4a86d2ff4559fce)
If we add the two equations above together, we get that
![{\displaystyle u(x+\Delta x,t)+u(x-\Delta x,t)=2u(x,t)+(\Delta x)^{2}u_{xx}(x,t)+O((\Delta x)^{4}).\,}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/bc26613f878a98dca494ed69d633cd81b85ea418)
If we isolate in the above, we get that
![{\displaystyle u_{xx}(x,t)={\frac {u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{(\Delta x)^{2}}}+O((\Delta x)^{2}).}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/f72d489203da9474876c295db9610356b5bb048b)
From these, we see that we can approximate by
![{\displaystyle u_{t}(x,t)\approx {\frac {u(x,t+\Delta t)-u(x,t)}{\Delta t}}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/b2331f266af772d2e0760dbf24984d69bed1f331)
and by
![{\displaystyle u_{xx}(x,t)\approx {\frac {u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{(\Delta x)^{2}}}.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/4eeffe1b14eb7e6cb05a83f316f2192427f34351)
Hence, we can approximate the equation
![{\displaystyle u_{t}=u_{x}x+t\,}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/6c3932da804208dff3dbde824e3bf83fa2a0d177)
by
![{\displaystyle {\frac {u(x,t+\Delta t)-u(x,t)}{\Delta t}}={\frac {u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)}{(\Delta x)^{2}}}+t.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/f85d4186525d876efbdb0697fc5ee382f6ad729c)
If we isolate in the above, we get that
![{\displaystyle u(x,t+\Delta t)=u(x,t)+{\frac {\Delta t}{(\Delta x)^{2}}}[u(x+\Delta x,t)-2u(x,t)+u(x-\Delta x,t)]+t\Delta t.\;\;\;{\text{(1)}}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/8c75fd391a8927a0e94e169e15e18b8306b4411f)
Next we will put mesh points in the interval . Let
![{\displaystyle x_{n}=n\Delta x\;\;{\text{for}}\;\;n=0,1,2,\cdots ,N}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/ef9fa6a52d1af8f2f2e37f6563d29ccea994b6e9)
where
![{\displaystyle \Delta x={\frac {1}{N}}.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/d575a3d8e0c2c0e7271aae48d3d927ca01cb2c9b)
Here, and . Similarly, we will let the mesh points in be
![{\displaystyle t_{k}=k\Delta t\;\;{\text{for}}\;\;k=0,1,2,\cdots }](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/53f2bdfab3edc488f4020df809bb231e70024883)
for some small time step .
At and , equation (1) becomes
![{\displaystyle u(x_{n},t_{k+1})=u(x_{n},t_{k})+{\frac {\Delta t}{(\Delta x)^{2}}}[u(x_{n+1},t_{k})-2u(x_{n},t_{k})+u(x_{n-1},t_{k})]+t_{k}\Delta t.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/53dbde6f87e3d2f68d9bdd15c0c0e6395a3622aa)
To get the above, we used
.
Using the notation , we can write the above as
![{\displaystyle u_{n}^{k+1}=u_{n}^{k}+{\frac {\Delta t}{(\Delta x)^{2}}}[u_{n+1}^{k}-2u_{n}^{k}+u_{n-1}^{k}]+t_{k}\Delta t.\;\;(2)}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/dd1aa4f97022267fcf44b51cd417688ca01c00de)
If we look at the above equation, we see that for each fixed , it gives us a scheme to compute once is known for .
For the initial condition , we set
![{\displaystyle u_{n}^{0}=0\;\;{\text{for}}\;\;n=0,1,2,\cdots ,N.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/168ce606657595be29a164d545d820de20cfdaab)
For the boundary condition , we set
![{\displaystyle u_{N}^{k}=0\;\;{\text{for}}\;\;k=1,2,3,\cdots .}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/4cdbd5f3ff95b2b2277b18ff9d3ab4ea4c04c128)
Now, for the boundary condition , there is more than one way to handle that. One possible way is to set
![{\displaystyle {\frac {u(0,t)-u(0-\Delta x,t)}{\Delta x}}=0}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/07ff32cde42a5cf25ff86afa8a5dad9224be0497)
which implies
![{\displaystyle u(0,t)=u(-\Delta x,t)\,}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/dc1b221c523cf99ee0705b2fa419f8f674d3718c)
If we allow an extra mesh point to the left of , the above gives
![{\displaystyle u_{0}^{k}=u_{-1}^{k}.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/61aeef15d8625d7ef11f26882c78a56dab104130)
Hence, for , equation (2) can be rewritten as
![{\displaystyle {\begin{aligned}u_{0}^{k+1}&=u_{0}^{k}+{\frac {\Delta t}{(\Delta x)^{2}}}[u_{1}^{k}-2u_{0}^{k}+u_{-1}^{k}]+t_{k}\Delta t\\&=u_{0}^{k}+{\frac {\Delta t}{(\Delta x)^{2}}}[u_{1}^{k}-u_{0}^{k}]+t_{k}\Delta t.\end{aligned}}}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/3315244d3c0afaaf645ffcc6bbeb35af5f3c7559)
Referring to the diagram above, to find an approximate solution to this problem, we first set the initial conditions
![{\displaystyle u_{n}^{0}=0\;\;{\text{for}}\;\;n=0,1,2,\cdots ,N}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/42f83885855bde8a50a6e4bdb5e246514324d196)
and the boundary condition
![{\displaystyle u_{N}^{k}=0\;\;{\text{for}}\;\;k=1,2,3,\cdots }](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/9848bea0aca986d169a287eb82e9233f7b3a1202)
Then, we compute from by
![{\displaystyle u_{0}^{1}=u_{0}^{0}+{\frac {\Delta t}{(\Delta x)^{2}}}[u_{1}^{0}-u_{0}^{0}]+t_{0}\Delta t}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/a9e941555ab0cbc32127b1b5c6bc05ba872d3bad)
and
![{\displaystyle u_{n}^{1}=u_{n}^{0}+{\frac {\Delta t}{(\Delta x)^{2}}}[u_{n+1}^{0}-2u_{n}^{0}+u_{n-1}^{0}]+t_{0}\Delta t\;\;{\text{for}}\;\;n=1,2,3,\cdots ,N.}](https://wiki.ubc.ca/api/rest_v1/media/math/render/svg/721ac50d34eface326914547337f4f1e46afb1ac)
Once we have , we can iterate the process to find
|