# One Written Report As A Pdf-File (Max Two Sides Of A4) & One Jupyterlab (.Ipynb) Notebook

Posted Under: Jupyter Lab / Hub

Order Now

#### Related Study Services

DESCRIPTION
Posted
Modified
Viewed 27
Someone to do my programming coursework. Fill in the template given in juptylab and write a report.

This order does not have tags, yet.

Attachments
Template Code for Cwk 1 in Mathematical Programming In [1]: from sys import exit from math import exp The physical parameters. M: the mass of the patient (kg) alpha: the dosage (mg/day) r0: the intitial rate of growth (parts per million per day) c0: the intitial concentration of bacterium X (parts per million) In [2]: # Problem parameters which can be read directly (but not overwritten) b y the functions below M = 60 alpha = 10 r0 = 3 c0 = 4 The numerical parameters. bTol: a tolerance to be used in isZero(x) to determine whether the argument is very small in magnitude. nInt: the number of intervals to be used in the Trapezium rule. In [3]: # Numerical parameters which can be read directly (but not overwritten) by the functions below bTol = 1e-9 nInt = 1000 cFunction(t): This function returns the concentration C(t) at time t. It will use the trapezium rule (with nInt intervals) on the function r(t) to numerically solve (3). In [4]: def cFunction(t): # Calculates and returns the C(t) given the t value. return concentration template about:srcdoc 1 of 3 26/11/2020, 11:28 rFunction(t): This function returns the rate of growth r(t) at time t. It will use the bisection method to find a root, r, of (2) with (2) expressed in the form of a residue function f(r)=0. This rFunction() will contain the residue function as a nested function. In [19]: def rFunction(t): def residue(r): # A nested function within rFunction() and hence only rFunction can directly access this function. # Put code in here which is the function you are trying to find the root of. # This function can read both its own argument (r) and the argu ment of its containing function (t) return value # Apply the method of bisection to find a root of residue() r = implementBisections(residue) return r trapezium(r, ta, tb, n): Returns the approximation to the integral of the function r over [ta,tb] using the Trapezium rule with n intervals. See Task 4.3 in worksheet 4. In [ ]: def trapezium(r, ta, tb, n): # Applies the trapezium rule to find the integral of r(t) from t_a to t_b using n intervals return integral template about:srcdoc 2 of 3 26/11/2020, 11:28 implementBisections(f): Returns a root of the function f, i.e. a solution to f(x) = 0. It does this by performing multiple calls to methodBisect() until a root is obtained (i.e. methodBisect() returns the string 'zero' in its output), and this implementBisections() function should return that root. It is a requirement here that a maximum limit is placed on the number of times methodBisect() is called in order to avoid an infinite loop. You should set that limit to be 1000. If the method Bisect() does not return a root after 1000 calls, then this implementBisections() function should exit the programme by calling exit(1). You are instructed to use the initial values of xa = -1 and xb = 10 in your first call to methodBisect(). In [10]: def implementBisections(f): return root methodBisect(f, xa, xb) Performs one iteration of the bisection method. See Appendix A of the coursework. In [ ]: def methodBisect(f, xa, xb): return string, xa, xb isZero(x): Returns True if x is deemed to be zero or close to zero. Otherwise returns False. The parameter bTol (initialised at the top of this notebook) is used; the tolerance for 'close to zero' is given by | x | < bTol In [ ]: def isZero(x): return res template about:srcdoc 3 of 3 26/11/2020, 11:28
0
Please find attached the completed work in a zip folder. The folder contains the written report in pdf format as well as the Jupyter lab (.ipynb) file. Thank you for giving me the opportunity to work on your project. Best Regards.
\$0.00

From 0 reviews

homeworkdoer

(0)
Unknown678

reviewed