Question: a)Define a set of 5 4x4 matrices in Python containing random floating-point numbers between 0 and 1. Use the appropriate routines in numpy.linalg and scipy.linalg
a)Define a set of 5 4x4 matrices in Python containing random floating-point numbers between 0 and 1. Use the appropriate routines in numpy.linalg and scipy.linalg to find the determinants of each matrix, in the case of numpy without using a loop. Make a quantitative comparison of the results between the two methods.
b) We want to write the above equations in matrix form as F = Kx - b .in Python. Write a function that takes the ki and Li values as inputs in 1-D arrays and returns the arrays corresponding to K and b.
c) Use the function from part b and the linalg functions to solve for the equilibrium positions of the masses (where Fi=0) for the cases
(i) k = [1 2 3 4], L = [1 1 1 1], Lw=10
(ii) k = [0 1 1 0], L = [2 2 1 1], Lw=4
d) Write the appropriate code needed to solve this system of equations using scipy.integrate.solve_ivp. (Hint: your state vector in this case should have 6 components, 3 for x_i and 3 for v_i. Your derivative function will need the vectors k and L as additional arguments). Compute the solutions using as initial values the equilibrium positions x_i for the 2 cases you computed in part 3, and v_i=0. Are the results as you might expect?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
