1.A general ODE problem u
(t) = f (u, t), u(0) = U0, may be solved numerically by the third order Runge-Kutta method. The computational scheme reads un+1 = un + Δt 6 (k1 + 4k2 + k3) , n = 0, 1,…,Nt − 1, k1 = f (un, tn), k2 = f (un + Δt 2 , tn + Δt 2 ), k3 = f (un − Δtk1 + 2Δtk2, tn + Δt) , with u0 = U0. a) Implement the scheme in a function RK3 that takes appropriate parameters, so that it is easy to import and use whenever needed. b) Write a function compare_FE_RK3 that compares graphically the solutions produced by the Forward Euler and RK3 methods, when they solve the population growth model u
= 0.1u, with u(0) = 100. Let the total time span T = 20, and use a time step dt = 2. In the plot produced, include also the exact solution, so that the numerical solutions can be assessed. c) Suggest a reasonable asymptotic error model before you write a proper test function test_convergence_ratesthat may be used to compute and check the convergence rates of the implemented RK3 method. However, the test function should take appropriate input parameters, so that it can be used also for other ODE solvers, in particular the ode_FE implemented previously (if you already have written this test function when doing Exercise 8.15, you may prefer to import the function). Include your test function in a program, together with the two functions you defined previously (RK3 and compare_FE_RK3). Write the code with a test block, so that it gets easy to either import functions from the module, or to run it as a program. Finally, run the program (so that compare_FE_RK3 gets called, as well as test_convergence_rates for both FE and RK3) and confirm that it works as expected. In particular, does the plot look good, and do you get the convergence rates you expected for Forward Euler and RK3?

Found something interesting ?

• On-time delivery guarantee
• PhD-level professional writers
• Free Plagiarism Report

• 100% money-back guarantee
• Absolute Privacy & Confidentiality
• High Quality custom-written papers

Grab your Discount!

25% Coupon Code: SAVE25
get 25% !!