using System; using L=Science.Physics.GeneralPhysics; namespace Serway.Chapter23 { /// /// Example04: Find the Charge on the Spheres /// Two identical small charged spheres, each having /// a mass of 3.0 \times 10^{-2} kg, hang in equilibrium /// as shown in Figure. The length of each string is 0.15 m, /// and the angle \theta is 5^{\circle}. Find the magnitude /// of the charge on each sphere. /// q = 4.4 \times 10^{-8} C /// public class Example04 { public Example04() { } private string result; public string Result { get{return result;} } public void Compute() { L.Calculus.Function f = new L.Calculus.Function(func); double[] x = {-4.0E-5,0.0}; double[] min = L.Calculus.MinimumOfFunction(f, x, 1.0E-5); result+=min[0].ToString()+"\r\n"; result+=min[1].ToString()+"\r\n"; result += min[2].ToString() + "\r\n"; } private double func(double[] x) { L.ElectricCharge q = new L.ElectricCharge(); q.C = x[0]; L.Mass m = new L.Mass(); m.kg = 3.0*0.01; L.Length l = new L.Length(); l.m = 0.15; L.Position r1 = new L.Position(); r1.X = -l.m*Math.Sin(5.0*Math.PI/180.0); L.Position r2 = new L.Position(); r2.X = l.m*Math.Sin(5.0*Math.PI/180.0); L.ElectricForce F = new L.ElectricForce(q,r1,q,r2); double zero = Math.Tan(5.0*Math.PI/180.0) - F.N / m.kg / L.Constant.AccelerationOfGravity; return zero*zero + x[1]*x[1]; } } } /* 4.42330990334865E-08 3.49907990470398E-10 1.22438972653187E-19 */