Download or view RelativisticKineticEnergyTest.frink in plain text format
/** This is a test to evaluate the numerical accuracy of the relativistic
kinetic energy equation, which does not work well for small velocities.
See:
http://www.mrelativity.net/MBriefs/Relativistic%20Escape%20Velocity%20using%20Special%20Relativity.htm
A threshold seems to be about 0.0256 c. Below this, the Taylor
series is more reliable. Above this, the naive evaluation is more
reliable.
*/
use sqrtWayne.frink
precision = 40
//setPrecision[precision]
m0 = 1 kg
//for v = 0.000 c to 0.300 c step .00005 c
for v = 1 m/s to 10 m/s step 1 m/s
{
setPrecision[20]
naive = (c^2 m0) (1/sqrt[1-v^2/c^2] - 1)
taylor = 1. * m0 ( (v^2 / 2) + (3 v^4 / (8 c^2)) + (5 v^6 / (16 c^4)) + (35 v^8 / (128 c^6)) + (63 v^10 / (256 c^8)) + (231 v^12 / (1024 c^10)) + (429 v^14 / (2048 c^12)) + (6435 v^16 / (32768 c^14)) )
setPrecision[precision]
good = (c^2 m0) (1/sqrt[1-v^2/c^2, precision] - 1)
naiveError = good-naive
taylorError = good-taylor
print[formatSci[v, c, 8] + "\t" + format[naiveError, J, 3] + "\t" + formatSci[taylorError, J, 3] + "\t"]
if (abs[naiveError] < abs[taylorError])
println["Naive"]
else
println["Taylor"]
}
Download or view RelativisticKineticEnergyTest.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20139 days, 7 hours, 59 minutes ago.