English subtitles

← 03-36 Seir Backwards Solution

Get Embed Code
1 Language

Showing Revision 2 created 10/24/2012 by Amara Bot.

  1. Let's start with the output of that software.
  2. For reference, this is the result of the forward Euler method with a step size of half a day.
  3. You already saw that the Euler method had step sizes of 2 or more.
  4. But there's a price to pay for the stability of the backward Euler method.
  5. The code gets really complex as opposed to the code of the forward Euler method.
  6. You really do need pencil and paper to derive these equations. That's what we're going to do now.
  7. The equation for R, the number of recovered persons, is the easiest one.
  8. We'll start with that and to save space let me write under score 1 for the current quantities
  9. and subscript 2 for the quantities of the next step.
  10. The forward Euler method would turn this into the following.
  11. The value of R one step later is the current value of R plus step size
  12. times the current rate of change, which is 1/5 days times the current value of I.
  13. I₁ in my new notation.
  14. This would be the forward Euler method but now we're concerned with the backward Euler method,
  15. which means that we have to use the rate at the end of that step meaning I₂ has to go in here.
  16. And now we're done. We know the current value of R.
  17. We have computed the next value of I in the lines before,
  18. and that's all we need to compute the next value of R.
  19. Next up is S. If we were using the forward Euler methods, this would work as follows.
  20. The next value of S is its current value plus the time step times its current rate of change
  21. meaning -5x10⁻⁹ per day and person times I at the current step and S at the current step
  22. if we were doing forward Euler.
  23. But now that we're doing backward Euler, this has to be I one step after that
  24. and S one step after that.
  25. We bring this down to the left hand side because we're interested in S₂ and we factor out S₂.
  26. So the factor of 1 times S₂ and now it's plus this coefficient times I₂ times S₂.
  27. 5x10⁻⁹ divided by day person I₂ and all that remains on the right hand side is S₁
  28. and now that is simple to solve.
  29. S₂ equals S₁ divided by the very same expression that we've got here.
  30. I'm lazy. I don't spell it out. This completes the computation of S₂ for which we need I₂.
  31. But we have computed that in the line before.
  32. And now the equation for the rate of change of I, the number of infectious persons.
  33. Those persons that is infected persons become infectious with a certain time constant
  34. and infectious persons recover with another time constant.
  35. If we were implementing forward Euler, it would be doing the following.
  36. I₂ the value of the next step equals the current value plus the time step
  37. times the current rate of change, which is 1/1 day E₁ minus 1/5 days I₁
  38. but now we want to implement the backward Euler method,
  39. which means that we have to use the values for the next time step and this rate of change.
  40. I bring this term with the I₂ over to the left hand side and factor out the I₂.
  41. This leaves me with one I₂ plus h times 1/5 days.
  42. On the right hand side, I₁ remains and h times 1/1 day and E₂ remains.
  43. And now we can divide by this expression and find I₂ equals the right hand side
  44. divided by this expression I₁ plus h times 1/1 day times E₂ divided by this expression.
  45. This completes the equation for I.
  46. The main message here is that implicit methods come at a price.
  47. Solving these equations can get very ugly.
  48. If you are convinced at this moment, you may want to skip the rest of the segment.
  49. Otherwise, stay with me to see how we can compute E₂,
  50. which by the way is needed to be able to compute I₂.
  51. A trick to find the value of E for the next time step
  52. is to look at these two differential equations and parallel.
  53. For the first one, the backward Euler method says the value for the next time step
  54. is the value for the current time step plus the time step times our estimate of the rate of change
  55. for the next time step which is 5x10⁻⁹ per day and person times I₂ S₂ backward Euler
  56. minus 1/1 day E₂ backward Euler again and not E₁.
  57. And for S the new value is the old one plus the time step times
  58. minus our coefficient 5x10⁻⁹ per day and person times I₂ S₂ backward Euler again and that's it.
  59. If you now form the sum of these two equations, you'll get E₂ plus S₂ equals E₁ plus S₁.
  60. This ugly expression cancels with that ugly expression, and we are left with h times
  61. minus 1/1 day E₂.
  62. So this is what we have reached by now. E₁ the current value is known.
  63. S₁ the current value is known. We want to determine E₂, the next value.
  64. At this point, we do not yet know S₂.
  65. But luckily enough, we derived an equation for S₂ to be for namely S₂ equals S₁ divided by
  66. 1 plus the step size times 5x10⁻⁹ divided by days and persons times I₂.
  67. And we have an equation for I₂ that says I₂ equals I₁ plus step size times 1/1 day E₂
  68. divided by 1 plus step size times 1/5 days.
  69. If you use this equation to express I₂ and then insert this result as S₂,
  70. you end up with an equation that contains E₂ and E₁ and S₁ and it can be solved for E₂.
  71. E₂ appears in three places and with a little edge ??? you can turn the resulting equation
  72. into a quadratic equation which is the standard solution formula for quadratic equations.
  73. The result is what you see in the code.
  74. Hopefully, this is now really convincing that working with implicit servers
  75. requires quite some effort with pen and paper.