Question: use Python 1. Carry out the following in IDLE: 7.8+0.2+8.9-2.1. What is the answer from Python? What is the exact answer? To get to the

use Python

use Python 1. Carry out the following in IDLE: 7.8+0.2+8.9-2.1. What isthe answer from Python? What is the exact answer? To get tothe bottom of this, compute the machine epsilon: EM Defn: em, is

1. Carry out the following in IDLE: 7.8+0.2+8.9-2.1. What is the answer from Python? What is the exact answer? To get to the bottom of this, compute the machine epsilon: EM Defn: em, is the smallest float, which added to 1, gives a float greater than 1. Write a program to compute en. Start with em = 1. In each iteration of the loop, halve em, add it to 1 and test the result. If the result is different from 1, continue looping The utility of machine epsilon is that it allows us to estimate the distance between any two adjacent float values in lecture). 2. Floating point operations need to be done with care. An example of a simple computation when things go awry: The Verhulst equation arises from popula- tion modelling studies Here we examine compute with the Verhulst equation in two ways: (We will explore this equation in later labs). p(n+1) = p(n) +r.p(n)-(1-p(n)) Evaluate the equation in two ways: (i) As written above. (ii) p(n + 1) = (1+r).p(n) - r.pin)? User = 3 and use p0) = 0.01 as the initial condition. Print the two columns side-by-side with their difference in the third column. Formatted printing. Formatting floats, allows us to specify the number of digits before and after the decimal point: The new version of the for- mat string for floats in Python: Assume p, q are floats declared in your program. The formatted string: print('p is : {0: 12.10f}, q is: {1:8.3f}'.format(p, q)) prints argument 0 (p) in 12 digits with 10 digits after the decimal and argument 1 (g) with 8 digits, 3 of them after the decimal. The 'f' tells the interpreter to print the number as a 'float Print p(n) calculated the two ways specified with 12 digits after the deci- mal. When (i.e. at what iteration) do the values start to differ? Run your program for 50 iterations and observe the difference in the two output answers. The point of this exercise is that the interactions of the slight round-off errors in floating points can be magnified by propagation of the error. 3. In this lab exercise you will re-visit projectile motion (motion in 2-D), plotting the trajectory with a slightly different method. The vector equations of motion governing the projectile are:(a - acceleration, v(t) - velocity; 8 - displacement, t - time): 7 = +*+ (1) 3= 5+++++ + ** (2) The motion resolved into components is: .2-component y-component Uz = No * cos + 0,*t Uy = 00 * sin + ay *t 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!