question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_body_in_shm do 4 kind :numerical 5 describes "A body oscillates with SHM according to the equation x = (5 m) cos[(2π rad/s) t + π/4]. At t = %{time}, " \ 6 "%{speed}, in m/s?" 7 given time: "1.5 s" 8 asks speed: "what is the speed of the body" 9 end
1 require_relative "../questions/a_body_in_shm" 2 require_relative "../science/oscillations/simple_harmonic_motion" 3 4 solve :a_body_in_shm , using: SimpleHarmonicMotion do 5 objects :body 6 axes :x 7 body . goes ( :oscillating ) 8 9 take time: oscillating . time_taken 10 11 deduce_from "(5 m) cos" , body . amplitude => "5 m" 12 deduce_from "(2π rad/s) t" , body . angular_frequency => "1 rev/s" 13 deduce_from "+ π/4" , body . phase_constant => "45 deg" 14 15 speed = body . final_velocity . magnitude 16 answer speed :, in: "m/s" , figures: 3 17 18 conclusion "The speed is the amplitude times the angular frequency times the sine of the phase, " \ 19 "largest as the body passes the middle." 20 end
1 require_relative "../solutions/a_body_in_shm" 2 3 play_with :a_body_in_shm do 4 title "A Body in SHM" 5 end