Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the function cart_makes_it_to_end() below, which considers the motion of a cart starting from rest at position x0, returning True if the cart will make
Implement the function cart_makes_it_to_end() below, which considers the motion of a cart starting from rest at position x0, returning True if the cart will make it all the way to some end position send, and False otherwise.
A frictionless cart is started from rest on a track which has a complicated shape. As a function of the cart position X, the gravitational potential energy of the cart on the track is equal to: V(x) = -x + x4 - 200x + 1500x + 2800 Run the cell below to draw a plot of the potential energy (which, in this case, is also a sketch of the track itself.) x = np.linspace(-8,8,200) def cart_V(x): return -X***5 + X**4 - 200*X**2 + 1500X + 2800 y = cart_V(x) plt.plot(x,y) plt.xlabel('x (m)') plt. y label('(x)') The track slopes up on the left-hand side, so the initial potential increases sharply if we start the cart at more negative x. On the right, the potential slopes down sharply. The track ends at x = +8 meters, at which point the cart falls off (this is a very exciting ride.) Instead of looking at the detailed motion of the cart on the track, we can use conservation of energy to ask about properties of its overall path. In particular, consider the total energy E = T(x) + V(x). Since we know V(x) in full, we can compute the kinetic energy vs. position T(x) for the cart once we know E. But kinetic energy has an important restriction that V(x) does not: kinetic energy can never be negative! In other words, if T(x) would be negative for any x, then that point is not reachable by a cart with that much energy. (Such a region is said to be "classically forbidden".) Implement the function cart_makes_it_to_end() below, which considers the motion of a cart starting from rest (So T(x0) = 0 ) at position x0, returning True if the cart will make it all the way to some end position xend, and False otherwise. (We'll often be calling the function with xend = 8 to ask if the cart makes it all the way to the end, but you should write it in a way that it gives the right answer for other input values of xend !) Remember, we don't have to worry about the details of the motion: all you need to answer is whether the cart's total energy E is large enough that T(x) will always be positive between xo and the end of the track at xend. (Hint: check out the functions np.any () or np.all() - these let you test logical conditions on a whole array like T(x).) def cart_makes_it_to_end(x0, xend, V, num_points=1000): Given the 1-d potential V(x), determines whether a cart starting from rest at position x=x0 will make it to the right end of the track. Arguments: --- XO: x-position where cart begins from rest. xend: x-position where the track ends. V: potential energy function V(x) to test num_points: number of x-points to test in the range (x0, xend) [default: 1000.] Returns: 'True' if the cart can get to xend, False' otherwise. ## YOUR CODE HERE A frictionless cart is started from rest on a track which has a complicated shape. As a function of the cart position X, the gravitational potential energy of the cart on the track is equal to: V(x) = -x + x4 - 200x + 1500x + 2800 Run the cell below to draw a plot of the potential energy (which, in this case, is also a sketch of the track itself.) x = np.linspace(-8,8,200) def cart_V(x): return -X***5 + X**4 - 200*X**2 + 1500X + 2800 y = cart_V(x) plt.plot(x,y) plt.xlabel('x (m)') plt. y label('(x)') The track slopes up on the left-hand side, so the initial potential increases sharply if we start the cart at more negative x. On the right, the potential slopes down sharply. The track ends at x = +8 meters, at which point the cart falls off (this is a very exciting ride.) Instead of looking at the detailed motion of the cart on the track, we can use conservation of energy to ask about properties of its overall path. In particular, consider the total energy E = T(x) + V(x). Since we know V(x) in full, we can compute the kinetic energy vs. position T(x) for the cart once we know E. But kinetic energy has an important restriction that V(x) does not: kinetic energy can never be negative! In other words, if T(x) would be negative for any x, then that point is not reachable by a cart with that much energy. (Such a region is said to be "classically forbidden".) Implement the function cart_makes_it_to_end() below, which considers the motion of a cart starting from rest (So T(x0) = 0 ) at position x0, returning True if the cart will make it all the way to some end position xend, and False otherwise. (We'll often be calling the function with xend = 8 to ask if the cart makes it all the way to the end, but you should write it in a way that it gives the right answer for other input values of xend !) Remember, we don't have to worry about the details of the motion: all you need to answer is whether the cart's total energy E is large enough that T(x) will always be positive between xo and the end of the track at xend. (Hint: check out the functions np.any () or np.all() - these let you test logical conditions on a whole array like T(x).) def cart_makes_it_to_end(x0, xend, V, num_points=1000): Given the 1-d potential V(x), determines whether a cart starting from rest at position x=x0 will make it to the right end of the track. Arguments: --- XO: x-position where cart begins from rest. xend: x-position where the track ends. V: potential energy function V(x) to test num_points: number of x-points to test in the range (x0, xend) [default: 1000.] Returns: 'True' if the cart can get to xend, False' otherwise. ## YOUR CODE HEREStep 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