Question: Please help me coding this question. coding should be in Python (Jupyter) 5. Coding 1: For the following IVP, y' = -6y, y(0) = 1,
Please help me coding this question. coding should be in Python (Jupyter)
5. Coding 1: For the following IVP, y' = -6y, y(0) = 1, solve numerically using i) Forward Euler and ii) Heun's method. (a) Plot the solutions for cach method using h = 1/100 on the interval [0, 1]. (b) Use a loglog plot to compare the error after the first time step of the solution for h = 0.1, 0.05, 0.01, 0.005, 0.001, 0.0005, 0.0001. For Heun's method, your code can be structured in the following manner: import numpy as np def Heun(t,yold,f,h): Y=yold+ %FILL IN DETAILS ynew=yold+ %FILL IN DETAILS return ynew 5. Coding 1: For the following IVP, y' = -6y, y(0) = 1, solve numerically using i) Forward Euler and ii) Heun's method. (a) Plot the solutions for cach method using h = 1/100 on the interval [0, 1]. (b) Use a loglog plot to compare the error after the first time step of the solution for h = 0.1, 0.05, 0.01, 0.005, 0.001, 0.0005, 0.0001. For Heun's method, your code can be structured in the following manner: import numpy as np def Heun(t,yold,f,h): Y=yold+ %FILL IN DETAILS ynew=yold+ %FILL IN DETAILS return ynew
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
