Work: Hooke’s Law In this example, we use Python to calculate the amount of work done in moving a spring using Hooke’s Law. Suppose it takes 10 Joules of work to move a spring from its natural length of 10cm to a length of 15cm. We want to know how much work it would take to move the spring from a length of 15cm to a length of 20cm. As always, we start by explaining how we would solve the problem by hand. The key formula is F=k*x. The steps to solve this problem are: 1) Since we are given the amount of work, integrate the force over the given interval (integrate) 2) Solve W=10 for k (solve) 3) Substitute this value of k into the force equation (subs) 4) Integrate the new force over the desired interval. (integrate) We begin as always by importing the sympy package. Since we have two unknowns, x and k, we define both to be symbolic variables and define F to be k*x. Step 1, we integrate, but must be careful as x represents the displacement IN METERS FROM the spring’s natural length. So our interval is from x=0 to x=0.05. For step 2, we check our solutions by printing them out first, and see that we only obtain one solution, so we put the 0th index at the end. Step 3, we substitute this value into F, again printing the result to make sure it was done correctly. Finally, we integrate this new function from x=0.05 to x=0.10, and print our result with explanatory text.