Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CHW8.3. Dynamical Systems: Springs Revisited Earlier in the semeaster, we looked at finding the equilibrium positions of masses attached to springs. However, you can also
CHW8.3. Dynamical Systems: Springs Revisited Earlier in the semeaster, we looked at finding the equilibrium positions of masses attached to springs. However, you can also use linear algebra to model the motion of a spring itself. Let's have a spring with spring constant k and a mass m attached to it. Recall that a Hooke's Law spring obeys the equation F(t) = kz(t) where F'is the force exerted on the spring and x is the distance from equilibrium. If 1!{f) is the velocity of the mass at time then we know that F(t) = mu'(t) and so combining these gives v'(t) = _km{t] " This, combined with the fact that v(t) = m"{t] gives us a system of linear differential equations: x'(t) = vlt). o (8) = ~=a(t) Mow, let's look at the phase space of this system. At each point in time, this system is determined completely by two quantities, the velocity at which the mass is moving and the position of the mass at that time. That is, it x(t) wlt) ) . This differential eguation can then be written as a matrix () =) In this assignment, you will be asked to write a function spring_state: is determined by the state vector & = ( equation: a. It should have four arguments (in this order): k m. an initial state s, (an array with an initial position and velocity) and a time &, . b. It should return the state vector s; for the system at time . Your code will be tested on multiple values of m and k and with different initial states. Your code snippet should define the following: Name Type Description spring_state function Returns the state vector at specified time under given conditions user_code.py u dmport numpy &s np impert numpy.linalg as la -+ def spring_state(k, m, sa, t): #complete the function 1 2 3 4 5 & return Restore original file The following irrelevant functions cannot be used: inv(), pinv(), det(), orth(), matrix_rank(), null_space(). norm(), Istsq(), matrix_power(), fractional_matrix_power(), lu(), lu_solve(). Save & Grade Unlimited attempts Save only
Step 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