import matplotlib.pyplot as plt import numpy as np # fj?rkonstanten k = 2 # kg/s^2 # massen m = 10 # kg # vinkelfrekvensen omega_0 = np.sqrt( k/m ) # amplitudene a_1 = 0.78 a_2 = 0.5 # fasene phi_1 = 0. phi_2 = 0. # tidsskrit dt = 0.1 # antall punkter nt = 1000 # tidslinie ts = np.arange(nt)*dt # posisjonene x1 = + a_1*np.cos( omega_0*ts - phi_1 ) \ + a_2*np.cos( np.sqrt(3)*omega_0*ts - phi_2 ) x2 = + a_1*np.cos( omega_0*ts - phi_1 ) \ - a_2*np.cos( np.sqrt(3)*omega_0*ts - phi_2) # hastighetene v1 = - a_1*omega_0*np.sin( omega_0*ts - phi_1 ) \ - a_2*omega_0*np.sin( np.sqrt(3)*omega_0*ts - phi_2 ) v2 = - a_1*omega_0*np.sin( omega_0*ts - phi_1 ) \ + a_2*omega_0*np.sin( np.sqrt(3)*omega_0*ts - phi_2 ) # plot posisjonene plt.figure() plt.plot(ts,x1,ts,x2) # plot i faserom plt.figure() plt.plot(x1,v1) plt.axis('equal')