Page 1 of 1

Super simple math problem

Posted: Mon Apr 04, 2011 6:35 pm
by Thenior
This is bugging me - I am working on a coding project, and can't figure it out. I know this is simple math, but it is escaping me. Maybe it's cuz I have a headache right now.

Anyways

I have two X & Y coordinates: (30, 60) and (50, 30).

If you know X, how do you solve for Y? For instance, if X = 40, Y = ?

I know my slope is -3/2 - but I dunno, I am just drawing a major blank here.

Re: Super simple math problem

Posted: Mon Apr 04, 2011 6:44 pm
by sdfgeoff
Find the formulae for the slope. It will be Y=Gradient X + Constant

The gradient is -3 over 2 (you said it)
the constant will be the point at which the line intersects the Y axis.

Then insert X into the completed formulae, and it will give you Y

Re: Super simple math problem

Posted: Tue Apr 05, 2011 12:14 pm
by dissent
your function is a line, I take it ... :wink:

like geoff said, y = m * x + b, where m = (y2 - y1)/(x2 - x1)


you still need to find "b", so substitute in one of your points for x and y, determining b = 105

then for your line y = [(60 - 30)/(30 - 50)] * x + 105

y = -3/2 * x + 105