question.rb
solution.rb
playground.rb
1 require_relative "../physics" 2 3 question :two_charges_apart do 4 kind :numerical 5 describes "Two charges of %{first} and %{second} are placed at (–9 cm, 0, 0) and (9 cm, 0, 0) respectively. " \ 6 "%{energy}, in joules?" 7 given first: "7 μC" 8 given second: "-2 μC" 9 asks energy: "What is the electrostatic potential energy of the system" 10 end
1 require_relative "../questions/two_charges_apart" 2 require_relative "../science/electrostatic_potential_and_capacitance/potential_energy_of_charges" 3 4 solve :two_charges_apart , using: PotentialEnergyOfCharges do 5 objects :first , :second 6 7 take first: first . charge 8 take second: second . charge 9 10 deduce_from "(–9 cm, 0, 0) and (9 cm, 0, 0)" , first . distance ( from: second ) => "18 cm" 11 12 energy = first . potential_energy ( by: second ) 13 answer energy :, in: "J" , figures: 2 14 15 conclusion "Opposite charges attract, so the pair has less energy together than apart: the energy is " \ 16 "negative, and that much work separates them." 17 end
1 require_relative "../solutions/two_charges_apart" 2 3 play_with :two_charges_apart do 4 title "Two Charges Apart" 5 end