Question: 3 Python script to find the roots of a parabolic function (a) Choose a parabola with a minimum and two REAL roots (other than the

3 Python script to find the roots of a parabolic function (a) Choose a parabola with a minimum and two REAL roots (other than the ones given above). Determine its roots analytically. (b) Write a Python script to plot your chosen parabola and the coordinate set with an appropriate ordinate and abscissa range and so both roots can be seen). Your parabola should be implemented as a function in your script just as we did in the practice exercises. (c) Define variables 1), 12 and 13 to your script with I and 13 initialised to values for which (21) 0 and 12 = (x1 + 13)/2. Add if statements to the script which check that the variables are correctly initialised and warn the user if they are not. (d) Use if and else statements which update r or 13 to 12 according to whether f(x2) is greater or less than zero and print the updated values of 31 and 23 for verification. (e) Plot the new point on your parabola (12, S(x2)) in a colour different from the colour used for the parabola curve. Visualize your plot to check if the new point is displayed correctly. (1) Add a while loop to iteratively update 12 using the rule 12 = (1 +13)/2 as long as the absolute value of '(x2) is greater than a tolerance value tol, initialised to tol = 0.0001 before the while loop. If your script does not terminate in a few seconds it may be that it has an infinite while loop. To terminate it manually, interrupt it via the Notebook Kernel. (8) Add a statement which prints the values of 12 and f(+2) after the absolute value of f(12) becomes less than tol. The Python absolute value function is math.fabs (argument) called within math package. Remember to indent both the while loop and the if-else statements. (h) Run the script and check that it gives you a correct root for the parabola. Modify the script so that it will give the other root and then run it again. (i) Use the script to find how the member of steps required to find the root of the parabola depends on the value of tol by adding a variable nsteps into the while loop which is incremented by one cach time the loop is executed. Note that the variable nsteps must be initialised to zero. 6) Plot a graph of nsteps versus the logarithm of tol to the base 10. The Python log function is math.log10 (argument). (k) IMPORTANT: Graphs from (e) and (j) should be included in your report (1 point). (1) IMPORTANT: Attach the .ipynb files you generated in item (j) in addition to your report (0.5 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
