question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :an_oscillator_s_amplitude_from_its_start do 4 kind :numerical 5 describes "The motion of a particle executing simple harmonic motion is described by the displacement function, " \ 6 "x(t) = A cos (ωt + φ). The angular frequency of the particle is π s–1. If the initial (t = 0) position " \ 7 "of the particle is %{position} and its initial velocity is ω cm/s, %{amplitude}, in cm?" 8 given position: "1 cm" 9 asks amplitude: "what is its amplitude" 10 end
1 require_relative "../questions/an_oscillator_s_amplitude_from_its_start" 2 require_relative "../science/oscillations/simple_harmonic_motion" 3 4 solve :an_oscillator_s_amplitude_from_its_start , using: SimpleHarmonicMotion do 5 objects :particle 6 axes :x 7 particle . goes ( :oscillating ) 8 9 take position: particle . final_position 10 11 deduce_from "initial (t = 0)" , oscillating . time_taken => "0 s" 12 deduce_from "π s–1" , particle . angular_frequency => "0.5 rev/s" 13 deduce_from "ω cm/s" , particle . final_velocity => "0.5 rev cm/s" 14 15 amplitude = particle . amplitude 16 answer amplitude :, in: "cm" , figures: 3 17 18 conclusion "At the start the position and the velocity over the angular frequency are the two sides of a " \ 19 "right angle, and the amplitude is its hypotenuse." 20 end
1 require_relative "../solutions/an_oscillator_s_amplitude_from_its_start" 2 3 play_with :an_oscillator_s_amplitude_from_its_start do 4 title "An Oscillator's Amplitude from Its Start" 5 end