question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :the_field_midway_between_two_charges do 4 kind :numerical 5 describes "Two point charges qA = %{charge_a} and qB = %{charge_b} are located %{apart} apart in vacuum. " \ 6 "%{field} at the midpoint O of the line AB joining the two charges, in N/C?" 7 given charge_a: "3 μC" 8 given charge_b: "-3 μC" 9 given apart: "20 cm" 10 asks field: "What is the electric field" 11 end
1 require_relative "../questions/the_field_midway_between_two_charges" 2 require_relative "../science/electric_charges_and_fields/electric_field" 3 4 solve :the_field_midway_between_two_charges , 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 11 deduce_from "the midpoint O" , o . separation ( from: a ) => a . separation ( from: b ) / 2 , 12 o . separation ( from: b ) => a . separation ( from: b ) / 2 13 deduce_from "the line AB joining the two charges" , E => o . field_of_a_charge ( by: a ) - o . field_of_a_charge ( by: b ) 14 15 field = E 16 answer field :, in: "N/C" , figures: 2 17 18 conclusion "The positive charge pushes away from A and the negative charge pulls toward B, so at the midpoint " \ 19 "both fields point the same way, from A to B, and add." 20 end
1 require_relative "../solutions/the_field_midway_between_two_charges" 2 3 play_with :the_field_midway_between_two_charges do 4 title "The Field Midway Between Two Charges" 5 end