Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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!
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+1pnStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started