Page 1 of 1

Lorentz factor in source codes!

Posted: 10 Jun 2010, 16:32
by csun
Hello Michael,

I try to look at the source codes, and find the calculation for relative velocity as follows in several places (such as, in code multipole.c and csbend.c ):
--------------------------------
beta0 = p/sqrt(sqr(p)+1);
-------------------------------
If I understand correctly, here, $beta0$ is the relative velocity (i.e., $v/c$), and $p$ is the Lorentz factor ( i.e., $gamma$) .
However, the correct calculation for beta0 should be
----------------------------------------
beta0 = sqrt(sqr(p)-1)/p ;
---------------------------------------
I know both formulas are very close at high energy. However, the different will be significant at low energy.
My question is why you use an approximate formula in the codes, is there a reason behind it? or I am wrong?

Thanks!
CSun

Re: Lorentz factor in source codes!

Posted: 11 Jun 2010, 08:59
by michael_borland
CSun,

The correct equation for the velocity is beta = beta*gamma/gamma = p/sqrt(p*p+1). This is what elegant uses.

Elegant uses p=beta*gamma internally, not gamma.

--Michael