How can I solve this distance-time word problem with functions?

The problem is pretty simple, and its solution is too. But for some reason my suggested solution with functions doesn't work, and I can't figure out why:

The first car leaves from point $A$ towards point $B$, and the second car leaves from $B$ to $A$. The distance between $A$ and $B$ is $720 km$.
The second car is twice as fast as the first car.
After $3$ hours of driving the distance left between the cars is $270 km$. Find their speed.

The straight forward way to solve it is:
Let $x =$ speed of first car.
\begin{align}3x + 270 +3\times2x &= 720\\ x&=50\end{align}

I tried to solve it with functions and 2 equations, but that doesn't work. What am I missing here:

$f$ is the distance function for the first car, and $g$ for the second car.
\begin{align}f(t) &= xt\\ g(t) &= 720 -2xt\end{align}

1st equation:
$f(t)=g(t) =$meeting distance for a specific $t$
\begin{align}xt &= 720 -2xt\\ 3xt &= 720\\ x &= 720/3t\end{align}

2nd equation:
After $3$ hours the distance between them is $270$ km
\begin{align}g(t+3) -f(t+3) &= 270\\ 720 -2x(t+3) -x(t+3) &= 270\\ 450 &= 3x(t+3)\end{align}

\begin{align}450 &= \frac{720(t+3)}{t}\\ &= \frac{(720t+2160)}{t} \\ 450t &= 720t+2160\\ 270t &= -2160\\ t &= -8\end{align}

Which is of course the wrong answer.
How would you solve it with the distance functions? It's just more intuitive for me to get to the solution this way, even though it takes longer.

Thanks!

• Yes! That was the problem I had!! Thank you very much! Jan 18 '17 at 11:57