Is there a function for every possible line?

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.


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$.


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.