I am trying to prove relativistic length contraction using the following thought experiment however it does not work out. Please explain where I have gone wrong rather than directing me towards a different proof as I'd like to understand why this one in particular doesn't work. Also note that b is $\frac{v}{c}$ and $g$ is the lorentz factor.
A Light ray travels along a train of length $L$ from the point of view of the passenger. The train travels at velocity $v$ relative to an outside observer in the same direction as the light ray.
Consider the point of view of the passenger:
Distance traveled by the ray: $L$
Time the ray takes to travel: $t$
Speed of the ray: $c= \frac{L}{t}$
Consider the point of view of the observer:
Distance traveled by the ray: $L' + t'v$
Time the ray takes to travel: $t'$
Speed of the ray: $c = \frac{L'+t'v}{t'} = \frac{L'}{t'}+ v$
Equation summary:
(1) $ c = \frac{L}{t}→ t=\frac{L}{c}$
(2) $c = \frac{L'}{t'} + v$
(3) $t' = gt$
Math:
equate (1) and (2):
$ \frac{L}{t}= \frac{L'}{t'} + v $
substituting in (3):
$\frac{L}{t}= \frac{L'}{gt}+ v$
simplify:
$L = \frac{L'}{g}+ tv$
sub in (1)
$ L = \frac{L'}{g} + \frac{Lv}{c}$
$ L = \frac{L'}{g} + Lb$
$ L -Lb = \frac{L'}{g}$
$ L (1-b) =\frac{ L'}{g}$ (This is wrong)