Suppose that you want to calculate the single period return. Let
p0 be the initial price and
p1 be the final price over the period.
The most common formula is
(p1 - p0) / p0
But I also sometimes see people use
(p1 / p0) - 1
Algebraically, both forms are equivalent. However, when you are writing computer code, is there any difference?
From a performance perspective, both forms involve 1 division and 1 subtraction, so they should have similar performance. (Perhaps the first form only needs 3 registers while the second needs 4?)
From an accuracy perspective, is there any difference? Does one form have lower floating point error than the other? Assume that a 64 bit floating point type is being used (e.g. numpy float64 or Java double).
I am not sure whether the language used matters, but if you think it might, I now typically use Python (Pandas), R, or Java. And if I am using Pandas or R, the return is usually calculated as a vector operation.