Question: Write a code in python given that n, t,a,v 0 ,x 0 will compute the estimate of x after t seconds. where: n is the
Write a code in python given that n, t,a,v0,x0 will compute the estimate of x after t seconds.
where: n is the number of time slices per second (used to define t) t is the total number of seconds to be simulated a is the (constant) acceleration over the period v0 is the initial velocity x0 is the initial displacement
Let xi and vi represent the simulated values of x and v after i steps (x0 and v0 represent the initial displacement and velocity, respectively). Motion is simulated using the following update rules:
Vi +1 = Vi + a t
Xi +1 = Xi + Vi t
One line containing a space separated pair of integers representing the numerator and denominator of the estimate of x(t)presented as a rational number. (This way the value will be exact, and not subject to any round off errors). The numerator and denominator should be in their lowest terms.
Sample Input 0
5 2
3 1 4
Sample Output 0
57 5
Explanation 0
The given input indicates that t=1n=15 , x0 =4 ,v0 =1 and the acceleration is 3. We use the update rules to compute Xi and Vi for each value of i over the duration of 2 seconds. (Each second has been divided into n= 5 segments, so to simulate 2 seconds, we must compute the value of x10 .)
Given the update rules, we can compute v1 and x1 from v0 and x0 respectively:
V1 = v0 + a t = 1+3 15=135= 85
x1 = x0 + v0 t = 4+1 15=415= 215
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
