question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :pushed_back_for_twenty_five_seconds do 4 kind :numerical 5 describes "A body of mass %{mass} moving initially with a constant speed of %{speed} to the north is subject to a " \ 6 "constant force of %{force} directed towards the south for 30 s. Take the instant the force is " \ 7 "applied to be t = 0, and the position of the body at that time to be x = 0. %{position} at t = %{time}, " \ 8 "in kilometres?" 9 given mass: "0.40 kg" 10 given speed: "10 m/s" 11 given force: "8.0 N" 12 given time: "25 s" 13 asks position: "What is its position" 14 end
1 require_relative "../questions/pushed_back_for_twenty_five_seconds" 2 require_relative "../science/laws_of_motion/newtons_second_law" 3 4 solve :pushed_back_for_twenty_five_seconds , using: NewtonsSecondLaw do 5 objects :body , :pusher 6 axes :x 7 instants :applied , :later 8 body . goes ( :so_far , during: applied .. later ) 9 10 take mass: body . mass 11 take speed: body . velocity ( at: applied ) 12 take force: body . force ( by: pusher ). magnitude 13 take time: so_far . time_taken 14 15 deduce_from "directed towards the south" , body . force ( by: pusher ). direction => - x 16 deduce_from "x = 0" , body . position ( at: applied ) => "0 m" 17 18 position = body . position ( at: later ) 19 answer position :, in: "km" , figures: 1 20 21 conclusion "The force pulls the body back the whole time: it stops, turns round and is soon far to the " \ 22 "south of where the force first caught it." 23 end
1 require_relative "../solutions/pushed_back_for_twenty_five_seconds" 2 3 play_with :pushed_back_for_twenty_five_seconds do 4 title "Pushed Back for Twenty-Five Seconds" 5 end