Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

High precision calculation in Mathematica

  1. Nov 15, 2004 #1
    I'm trying to calculate the velocity of 10^20 eV cosmic rays, but the precision in Mathematica and Google is not high enough: both give velocities of exactly 1*c.

    I've tried putting SetAccuracy[...,1000] around all the constants and the final result, and it still doesnt work. It now gives 1.0000000000000...000*c

    I know Mathematica can do this, so what is the proper command?

  2. jcsd
  3. Nov 15, 2004 #2


    User Avatar
    Science Advisor
    Homework Helper

    Why don't you try subtracting c from the answer to find what Mathematica thinks the difference is?
  4. Nov 15, 2004 #3
    Well, I've tried N, SetAccuracy, and SetPrecision. For a precision of 1000 decimals, I subtracted c (which also has a precision of 1000 decimals) and it got zero out to all the digits.

    I'm pretty sure I'm just not using the correct command, since I've had this problem before and figured out what to do.
  5. Nov 15, 2004 #4
    Nevermind, I figured it out. You have to use SetPrecision on basically every number.

    Oh, and for the record, 10^20 eV corresponds to 0.99999999999999999999995598228313196044005099389886244069748671131566319262949728462461319064015929690c
  6. Nov 15, 2004 #5
    hmm, aren't those rays photons? aren't they supposed to move at the speed of light? or are they propagating through some medium or otherwise interacting in a way that would slow them down?
  7. Nov 15, 2004 #6
    No, they're ultra-high energy cosmic rays (most likely protons). I'm using the relativistic kinetic energy equation to get the velocity:

    Attached Files:

    Last edited: Nov 15, 2004
  8. Nov 15, 2004 #7
    I wonder if this necessary high precision is going to slow down numerical analysis, since everything will have to be out to ~30 decimals.
  9. Nov 16, 2004 #8


    User Avatar
    Science Advisor

    It's not numerically efficient to deal directly with v/c when energy is very high. You should get into the habit of using the relevant expansions. So for example,
    where [itex]\gamma=\mbox{Energy}/(mc^2)[/itex], and [itex]\beta=v/c[/itex]. Then
    [tex]\beta=\sqrt{1-1/\gamma^2}\approx 1-{1\over 2\gamma^2}[/tex]
    This gives you easily sufficient accuracy, and is very fast.
    Last edited: Nov 16, 2004
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook