TITLE: What's the equation for a line segment?
QUESTION [9 upvotes]: I already know that the standard equation for a line is $y=mx+b$, but what if I want the line to have specific endpoints and not go on forever? For example, the equation for a line beginning at $(3, 1)$ and ending at $(7, 2)$. Can you help me? 
What's the standard equation for this?

REPLY [2 votes]: In your example, the equation of a line passing from $(3,1)$ and $(7,2)$ is $$y=\frac{1}{4}x+\frac{1}{4}$$
defined for $3<x<7$ and $1<y<2$
Now let's take $3<x<7$  and split it into two inequalities $$3<x$$ and $$x<7$$, or equivalently $$x-3>0$$ and $$7-x>0$$
Now write $$\sqrt{\frac{|7-x|}{7-x}}$$ and  $$\sqrt{\frac{|x-3|}{x-3}}$$
Notice that in $$\sqrt{\frac{|7-x|}{7-x}}$$ if I plug in a value greater than $7$ the I get a complex number, this is why I included the square root, similarly   $$\sqrt{\frac{|x-3|}{x-3}}$$ becomes complex number for values of $x$ less than $3$ (note that the purpose of the absolute values is to "normalize" the term so that the only possible values that I can get are $-1$ or $1$)
Next multiply  $$\sqrt{\frac{|7-x|}{7-x}}$$ and  $$\sqrt{\frac{|x-3|}{x-3}}$$ together and multiply with $x$ in the equation of the line to get $$y=\frac{1}{4} x \sqrt{\frac{|7-x|}{7-x}} \sqrt{\frac{|x-3|}{x-3}}+\frac{1}{4}$$
and this equation describes a line segment if you include the points $(3,1)$ and $(7,2)$
This method will work for any curve.