所以我猜你误解了这个方程式。我不是物理学家,但这个公式似乎是用来计算两个轨道物体之间的平均距离的。使用公式并将代码重构为程序,我得到以下结果,它使用太阳和地球的值生成正确答案。
const double G = 6.674E-11;
Console.WriteLine("G is {0}", G);
const double massOfEarth = 5.972E+24;
const double massOfSun = 1.989E+30;
const double mass = massOfSun + massOfEarth;
Console.WriteLine("mass is {0}", mass);
// 365 days in seconds
const double period = 3.15569E+7;
Console.WriteLine("period is {0}", period);
// radius of the earth
const double radius = 6.371E+6;
Console.WriteLine("radius is {0}", radius);
double denominator = 4 * Math.Pow(Math.PI, 2.0);
Console.WriteLine("Denominator is {0}", denominator);
double numerator = G * mass * Math.Pow(period, 2.0);
Console.WriteLine("numerator is {0}", numerator);
double fraction = numerator / denominator;
Console.WriteLine("fraction is {0}", fraction);
double root = Math.Pow(fraction, 1.0 / 3.0);
Console.WriteLine("root is {0}", root);
double result = root - radius;
Console.WriteLine("final result is {0}", result);
输出为:
G is 6.674E-11
mass is 1.989005972E+30
period is 31556900
radius is 6371000
Denominator is 39.4784176043574
numerator is 1.32193760361067E+35
fraction is 3.34850706747872E+33
root is 149606480630.306
final result is 149600109630.306
其中太阳和地球之间的平均距离为1496亿米。