The travelling twin's flight consists of 4 stages; acceleration towards a distant planet for 3 lightyears, deceleration towards the planet for 3 lightyears, acceleration back to Earth for 3 lightyears, and finally, decelerating towards Earth for 3 lightyears. The absolute acceleration experienced by the travelling twin is 1 ly/yr^2 (approximately 1g).

The equations are as follows;

t = (c/a) sinh(aT/c) = sqrt[(d/c)2 + 2d/a] (time experienced by stationary twin),

d = (c2/a) [cosh(aT/c) − 1] = (c2/a) (sqrt[1 + (at/c)2] − 1) (distance travelled),

v = c tanh(aT/c) = at / sqrt[1 + (at/c)2] (velocity),

T = (c/a) asinh(at/c) = (c/a) acosh[ad/c2 + 1] (time experienced by travelling twin),

γ = cosh(aT/c) = sqrt[1 + (at/c)2] = ad/c2 + 1 (Lorentz factor).

Specifically, I'm interested in the 't' and 'T' equations. They seem to work fine for the 1st phase (acceleration towards the distant planet), but break during the 2nd phase (deceleration towards the distant planet).

I'm unsure as to whether I should plug in distance travelled or displacement from Earth for 'd', and when 'a' becomes negative (during stages 2 and 3), the acosh functions don't seem to work. Does anyone have any ideas? Any help would be appreciated!