# Is there a function for every possible line?

I'm currently in Pre-Calculus (High School), and I have a relatively simple question that crossed my mind earlier today. If I were to take a graph and draw a random line of any finite length, in which no two points along this line had the same $x$ coordinate, would there be some function that could represent this line? If so, is there a way we can prove this?

• "Line" means "straight line", right? – bof Mar 19 '16 at 0:04
• @bof Correct, although now that you mention it, I wonder if this same principle would apply to any line. – Nick Mar 19 '16 at 0:10

Yes. If the two end points of the line are $(x_1,y_1)$ and $(x_2,y_2)$ then the function is $f:[x_1,x_2]\to \mathbb R$ defined by $f(x)=\frac{y_2-y_1}{x_2-x_1}(x-x_1)+y_1$.

• Ah, I suppose I should have realized this. So your saying you could just find the slope of any random line, and use point-slope formula to construct a function? – Nick Mar 18 '16 at 23:54
• @Nick: Precisely. The only problem is when $x_1=x_2$ above. Can you guess what the problem is? – Shahab Mar 18 '16 at 23:55
• The denominator of the slope formula would be 0 when x base 2 is equal to x base 1 by the inverse property of addition, therefor making the function undefined. Am I correct? – Nick Mar 18 '16 at 23:58
• @Nick: Yes you are right. Hence the problem lies when there is the same $x$ coordinate and not when there is the same $y$-coordinate (excepting the trivial case when $x_1=x_2=y_1=y_2=0$). – Shahab Mar 19 '16 at 0:00
• If I could ask one more question that would be great. I was also wondering if this truth could be extended to higher degree functions: What if I were to draw any random parabolic curve or shape on a graph. Would there be some polynomial function that could model this line exactly? Is this true for any curvy line I draw, as long as no x coordinate repeats? – Nick Mar 19 '16 at 0:08

As an aside to supplement the answers you have already gotten, I would like to point out that a function doesn't need to have a formula to be considered a function. This is because a function is just a relation between two sets (the domain and range), with the property that you get only a single output for each input (this is the rule that there can only be one $y$ value for each $x$ value).

For instance, I can define a function $f$ from the set $\{0,1,2\}$ to the set $\{5,10,15\}$ by giving the rules

$$f(0)=10 \\f(1)=5 \\f(2)=15$$

It might be difficult or impossible to find a formula for $f$ in which you can plug in $0$, $1$, or $2$ and get the correct answer as a result, yet $f$ is a function since each input gives me a unique result.

By the same token, you can draw a straight line, or a wiggly line, a line with holes in it, or just a bunch of points, etc, and as long as you have ensured that there is no point on the graph where a single $x$ value gives more than one $y$ value you have essentially defined a function. This is true whether you can find a formula for it or not.

• So I could define a function just by stating two sets of any length, even if I have no equation that relates these two sets? I thought the function was the actual equation in which you can plug in a point from set x and get a corresponding point in set y. If not, then what do we call the actual equation (if one exists)? – Nick Mar 19 '16 at 0:23
• @Nick It's not necessary to have a single equation to express the entire function. A natural step up from your original question about lines is to look at step functions (pun not intended): en.wikipedia.org/wiki/Step_function – Irregular User Mar 19 '16 at 0:26
• @Nick The function is the rule that describes what number you will get out for any given number you put in. Sometimes (mostly always when you first start learning about functions) the rules are really nice and they can be described in one single equation, but it doesn't need to be the case. We regularly refer to the equation itself (when there is one) as the function, and it is not incorrect to say this. I just wanted to point out that some functions cannot be expressed with equations. – wgrenard Mar 19 '16 at 0:41
• @wgrenard isn't it possible to find a polynomial with real coefficients for the said points using interpolation? – jermenkoo Mar 19 '16 at 3:13
• A function is any mapping that maps each point in a domain to a value. The values don't have have any rationale or reason. Someone can define a function by rolling dice for each input value (except if the domain is all the. Real numbers you can't actually roll the dice for each real number one after the other as the reals are uncountable. But that's not the point. The point is the function itself can be totally arbitrary.) – fleablood Mar 19 '16 at 3:39

The only straight lines in the $x$-$y$ plane that are not functions are those that are perfectly vertical. Those are of the form $x=c$, where $c$ is a constant.

All other lines can be expressed in the form $y =f (x)= mx + b$ where $m$ is the slope of the line and $b$ is the $y$-intercept-- the $y$ value when $x$ is $0$.

Given any two points on the line we can find this formula, and given its formula we can find any point on the line.

Such a function is called a linear function.