I remember when my math would have me complete the square to solve equations. That took forever. Then they were saying how you could complete the square to the generic form of a quadratic equation to make the quadratic formula. Way easier to use.
There was another type of question that was taking me ages to do, finding the distance from a point to a line. They told me to find the line perpendicular to the original line going through the point, finding the point they intersect at, then use the distance formula to find the distance. I was thinking, why not do the same thing for this as completing the square? I thought it wouldn't take too long, and to show how long it took, I will put it here:
Equation for line:
y1 = ax1 + b1, point: (x, y) (as per Table's suggestion, I am renaming these x's and y's)
Equation of perpendicular line:
y1 = -x1/a + b2 (b2 is equal to y + x/a, but my original notes didn't insert it until later, so that's what I'll do here.)
Solving for x1:
ax1 + b1 = -x1/a + b2
x1 = a(b2 - b1)/(a2 + 1)
Now let's replace b2 with y+x/a (and call b1 b now):
a(y + x/a - b)/(a2 + 1)
(ay + x - ab)/(a2 + 1)
So, y1 is x1 times a, + b:
((ay + x - ab)/(a2 + 1))(a) + b
(a2y + ax - a2b) + a2b + b
(a2y + ax + b)/(a2 + 1)
Now, let's put this into the distance formula:
sqrt(((ay + x - ab)/(a2 + 1) - x)2 + ((a2y + ax + b)/(a2 + 1) - y)2)
Now, let's simplify that a bit, taking the x part:
(ay + x - ab)/(a2 + 1) - x
ay + x - ab - a2x - x
(a2x + ay - ab)/(a2 + 1)
And the y part:
(a2y + ax + b)/(a2 + 1) - y
a2y + ax + b - a2y - y
(ax + b - y)/(a2 + 1)
So, squaring and adding these:
((a2x + ay - ab)/(a2 + 1))2 + ((ax + b - y)/(a2 + 1))2
((a2x + ay - ab)/(a2 + 1))2
a2y2 - 2a2by - 2a3xy + a2b2 + a3xb + a4x2
((ax + b - y)/(a2 + 1))2
a2x2 + 2abx - 2axy + b2 - 2by + y2
(I'm rearranging this for the ease of future simplification)
a4x2 + a2x2 + 2a3bx + 2abx - 2a3xy - 2axy - 2a2by - 2by + a2b2 + b2 + a2y2 + y2
Now, at this point, I couldn't find a way to simplify it further. I put it in wolframalpha to figure out the simplest form of it. After I figured that out, I realized how to simplify it. First, factor all this:
a2x2(a2 + 1) + 2abx(a2 + 1) - 2axy(a2 + 1) - 2by(a2 + 1) + b2(a2 + 1) + y2(a2 + 1)
Factor out the (a2 + 1)
(a2 + 1)(a2x2 + 2abx - 2axy - 2by + b2 + y2)
If you paid attention, the second term here is the same as the square of the numerator of y1, so it turns into this:
(a2 + 1)(ax + b - y)2
Putting this back into the original equation gives us this:
sqrt(((a2 + 1)(ax + b - y)2)/(a2 + 1)2)
(sqrt(a2 + 1))(ax + b - y)/(a2 + 1)
(ax + b - y)/sqrt(a2 + 1)
EDIT: so, you need to take the absolute value of either the numerator of this or the whole answer, whichever you feel like.
So yay, a formula for the distance from a point to a line. This is way easier than the long method. I think I deserve extra math points for figuring this out on paper, and not making any mistakes. And, the sad thing is, this is probably pretty easy compared to more advanced stuff...