I need to find the coordinates of the point $P$ that divides a line segment $AB$ into a given ratio $r$. While searching for a quick formula I found two methods and I don't know wich one to use. The first formula I found it in Khan Academy and it's solved like this:
$$P(x_A+r(x_B-x_A), y_A + r(x_B-x_A))$$
And the second method that I found on my math book is:
$$P(\frac{x_A+rx_B}{1+r},\frac{y_A+ry_B}{1+r})$$
But if I use the same example as Khan Academy: $A(-1,4), C(4,-6)$ and $r = 3:5$. Using the first equation gives $B(2,-2)$ but using the second one gives $B(7/8,1/4)$.
My question is, wich one is the right one?
You could check the two answers to see which is right. Your answer from the Khan Academy formula has $B$ closer to $C$ than $A$, which cannot be right.
They are both right, but use different definitions of $r$. The Khan Academy is defining $r$ at the fraction of the distance from $A$ to $B$. You would divide the segment into pieces $\frac 38$ and $\frac 58$ of its length, so you should use $r=\frac 38$, not $r=\frac 35$ in that formula. The one from your math book is using $r=\frac 35$. As you used $r=\frac 35$ the second gave the right answer. You need to look at the definitions of the terms in the formula.