Question: Please write a program in Python! Suppose you are given a vector containing the momenta of an oscillating particle. Write a function revTime(times, momenta) that

Please write a program in Python!Please write a program in Python! Suppose you are given a vector

Suppose you are given a vector containing the momenta of an oscillating particle. Write a function revTime(times, momenta) that calculates the revolution time of this particle. times is a vector containing the times at which the momenta, stored in the vector momenta are given. The output should be a vector containing the revolution times for each revolution. Here, we assume that a new revolution starts when the momentum changes sign (e.g. negative to positive), such that a full revolution is performed when the sign changes again in the same manner. Hint: First, you need to identify the timesteps between which the sign change in the momentum occurs. You can do that by comparing the sign of the momentum. Then, to exactly determine the revolution time, use linear interpolation. Consider the time tn to be the last one with negative momentum pn and tn+1 the first one with positive momentum pn+1. Then, the linear interpolation for the momentum is p(t)=httnpn+1+htn+1tpn, and the equation for the exact time of crossing t(p(t)=0) is t=pn+1pntnpn+1tn+1pn

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!