question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :a_test_charge_at_the_midpoint do 4 kind :numerical 5 describes "Two point charges qA = %{charge_a} and qB = %{charge_b} are located %{apart} apart in vacuum. A " \ 6 "negative test charge of magnitude %{test} is placed at the midpoint O of the line AB joining the two " \ 7 "charges. %{force}, in newtons?" 8 given charge_a: "3 μC" 9 given charge_b: "-3 μC" 10 given apart: "20 cm" 11 given test: "1.5e-9 C" 12 asks force: "What is the force experienced by the test charge" 13 end
1 require_relative "../questions/a_test_charge_at_the_midpoint" 2 require_relative "../science/electric_charges_and_fields/electric_field" 3 4 solve :a_test_charge_at_the_midpoint , using: ElectricField do 5 objects :a , :b , :o 6 7 take charge_a: a . charge 8 take charge_b: b . charge 9 take apart: a . separation ( from: b ) 10 take test: o . charge 11 12 deduce_from "the midpoint O" , o . separation ( from: a ) => a . separation ( from: b ) / 2 , 13 o . separation ( from: b ) => a . separation ( from: b ) / 2 14 deduce_from "the line AB joining the two charges" , E => o . field_of_a_charge ( by: a ) - o . field_of_a_charge ( by: b ) 15 16 force = o . force_of_the_field 17 answer force :, in: "N" , figures: 2 18 19 conclusion "The two fields add at the midpoint, and a charge there feels the field times its charge; being " \ 20 "negative, it is pushed against the field, toward A." 21 end
1 require_relative "../solutions/a_test_charge_at_the_midpoint" 2 3 play_with :a_test_charge_at_the_midpoint do 4 title "A Test Charge at the Midpoint" 5 end