What is the equation for a 3D line? Just like we have the equation $y=mx+b$ for $\mathbb{R}^{2}$, what would be a equation for $\mathbb{R}^{3}$? Thanks. 
 A: Here are three ways to describe the formula of a line in $3$ dimensions.  Let's assume the line $L$ passes through the point $(x_0,y_0,z_0)$ and is traveling in the direction $(a,b,c)$.
Vector Form
$$(x,y,z)=(x_0,y_0,z_0)+t(a,b,c)$$
Here $t$ is a parameter describing a particular point on the line $L$.
Parametric Form
$$x=x_0+ta\\y=y_0+tb\\z=z_0+tc$$
These are basically the equations that result from the three components of vector form.
Symmetric Form
$$\frac{x-x_0}{a}=\frac{y-y_0}{b}=\frac{z-z_0}{c}$$
Here we assume $a,b,$ and $c$ are all nonzero.  All we've done is solve the parametric equations for $t$ and set them all equal.
A: You can describe a line in space as the intersection of two planes.  Thus, 
$$\{(x,y,z)\in{\mathbb R}^3: a_1x+b_1y+c_1z=d_1 \text{ and } a_2x+b_2y+c_2z=d_2\}.$$
Alternatively, you can use vector notation to describe it as
$$\vec{p}(t) = \vec{p}_0 + \vec{d}t.$$
I used this relationship to generate this picture:

This is largely a topic that you will learn about in a third semester calculus course, at least in the states.
A: When I originally asked this question, I was not expecting these seemingly indirect ways of describing a line, such as an intersection of two planes, or vector equations. Just like how $y=mx+b$ is the equation of a line in $2$D, I was expecting some sort of equation $z = f(x, y)$, where $f$ is some nice elementary function. I am writing this answer for anyone who has this same idea that I did. I want to quickly explain why the equation of a line cannot be $z = f(x, y)$, where $f$ is a nice function.
The problem is that if $f$ is a nice function, then it is probably defined for all pairs $(x, y)$, or almost all. That means that if you try to graph it, there will be a point of the graph of $f$ above almost every point of the floor, so the graph of $f$ cannot be a line.
Another way to say it is this: imagine the graph of the line. If we want an equation $f(x, y)$ for the line, the domain of $f$ can only be the shadow of the line on the $xy$ plane. But any nice function $f$ will have as a domain either all pairs $(x, y)$, or almost all of them.
With all of that being said, it is possible to cook up a function $f(x, y)$ whose graph is a line. We know that if we could take a plane, for example $g(x, y) = x+y$, and somehow restrict its domain to a line on the $xy$ plane, that would give us a line in $xyz$ space. Here is one way to do it:
$$f(x, y) = x+y+\sqrt{-(y-x)^2}$$
The expression $-(y-x)^2$ is $\le 0$ for any $x, y$ and it equals zero precisely when $y = x$. Therefore $\sqrt{-(y-x)^2}$ will only be defined precisely when $y = x$, and when $y$ does equal $x$, $f(x, y) = x+y$. Thus the graph of $f$ is a line in 3D space.
A: Ovi, I too like your answer about having initially set out looking for something of the form $z=f(x,y)$.
I think maybe I have something that tends in a similar direction, and that hopefully feels like a more generalizable extension from $\mathbb{R}^2$ to $\mathbb{R}^3$ (and beyond?).
TLDR:
In $\mathbb{R}^2$, points on a line have coordinates $(x, f(x))$.
In $\mathbb{R}^3$, points on a line have coordinates $(x, f(x), g(x))$.
($x$ needn't be $x$ here, of course, it could be $y$, $z$, $t$, whatever.)
The above wasn't obvious to me at all though, so for those who care to walk through it as I did, my thinking is as follows:
Let's put aside $y=mx+b$ for a minute, and think instead of a line in $\mathbb{R}^2$ as a collection of points whose ($x$, $y$) coordinates are of the form $(x,f(x))$. This just amounts to saying that the points' $y$ values are a function of $x$. Simply, $y = f(x)$.
That might seem tautologically obvious, but let's consider that if $x$ and $y$ weren't in this constrained relationship to one another where $y$ is determined by $f(x)$ -- in other words, if they were free to vary independently of one another, and every $x$ value could be combined with any $y$ value in a coordinate $(x,y)$ -- then you wouldn't have an object describing a line, you would have an object that describes the whole $xy$ plane itself!
Moving into $\mathbb{R}^3$, it's true, exactly as you said, that if we construct an object whose $z$ value is determined by a function $f(x,y)$ we'll have two values, $x$ and $y$, that are allowed to vary independently of one another, and will thus end up with a plane. (The only difference between this plane and the plane described in the paragraph above is that in $\mathbb{R}^3$ we have the added $z$-dimension in which the plane can be tilted, whereas in $\mathbb{R}^2$ the only possible plane is the $xy$ plane, but this is just an aside).
What if, instead of a function $f(x,y)$ which has two variables, all the points in our new 3-dimensional line object's coordinates are functions of one variable, say, $x$? In other words, if we have an object in $3$-space whose coordinates are of the form:
$$(x,y,z) = (x, f(x), g(x))$$
Then every $x$ value can only have one corresponding $y$ value and one corresponding $z$ value (if $f$ and $g$ are functions, they must have a unique output for any input value of $x$).
And if there is only one $y$ and $z$ value for every $x$ value, you know this is a line. As a counterexample, consider a linear equation in 3 variables. This describes a plane in $3$-space. For every $x$ value, $y$ and $z$ can still vary in a dependent relationship with each other, i.e. at each value of $x$ you have a slice through a plane instead of a point, which is what you'd need for it to be a line.
You can arrive at this by looking at the intersection of two planes, as shown in Mark's answer above. If you set two planes' equations equal to one another, and try to solve for the intersection, you end up with a solution (in linear algebra, a general solution or parametric solution) where two out of the three unknowns are given as functions of the third.
A: I am giving you an example. Let $A(-2,0,1),~~B(4,5,3)$ be two points in $\mathbb R^3$. And let $C$ be the end point for the vector which is drawn from the origin. In addition, we assume that this vector has the same direction as the vector $AB$. So we have its coordinates is $(4,5,3)-(-2,0,1)=(6,5,2)$. Therefore the equation of the line passing through $A$ and $B$ is $$L_{AB}: x=(-2,0,1)+t(6,5,2)$$
A: Besides the parametric form, another equation of a line in 3D to get it in the form $f(x,y,z)=0$ could be written as:
$\frac{\mathbf{r}-\mathbf{r_0}}{|\mathbf{r}-\mathbf{r_0}|} \cdot \mathbf{n} = 1$
Here $\mathbf{r}=(x,y,z)$ is a vector representing any general point on the line. $\mathbf{r_0}=(x_0,y_0,z_0)$ is a given point that lies on the line. $\mathbf{n}=(n_x,n_y,n_z)$ is a given unit vector (that has a magnitude of unity) that is parallel to the line. If two separate points $\mathbf{r_1}$ and $\mathbf{r_2}$ are given through which the line passes, then we could write $\mathbf{n} = \frac{\mathbf{r_2}-\mathbf{r_1}}{|\mathbf{r_2}-\mathbf{r_1}|}$.
Written differently, the equation would read:
$(x-x_0)n_x + (y-y_0)n_y + (z-z_0)n_z - \sqrt{(x-x_0)^2+(y-y_0)^2+(z-z_0)^2} = 0$
This is a quadratic equation in, say, $z$, in that a closed form solution could be written for $z$ in terms of $x, y$ and other given parameters. However, it is not easy to see that this equation should lead to a real solution for $z$ for only a specific subset of $x, y$ pairs on the $x-y$ plane.
A: I love your answer for a line equation in the form of z = f(x, y)...
Unfortunately calculating square roots can be impractical from the calculational standpoint and hence I really doubt any plotting software will be able to graph it correctly.
I was thinking of a little bit different approach in order to achieve this. Based on a symmetric equation of a line. However it requires some support for if ... else logic.
$$z=if\:\left(\frac{x}{2}+1=\frac{y}{3}+2\right)\:then\left(\frac{x}{5}+3\right)\:else\left(undefined\right)$$
Of course the advantage here is that it's easy to read and you can potentially define any line in $R^3$ by changing the constant parameters. In practice though, even when conditional statements are supported, for example in GeoGebra - it still fails to actually draw the line.
A: I know i am way late to the party but i was looking for an answer and came to this question and was a bit crest fallen to see it claimed that there is not a $z=f(x,y)$ form. i am not a mathamatician by any means but here is what i did to solve this problem for my immediate needs:
in the $x-y$ plane we have $y=m_yx+b_y$
in the $x-z$ plane we have $z=m_zx+b_z$
solving the second for $x$ gives $x=(z-b_z)/m_z$
shoving that into the first then gives $y=m_y(z-b_z)/m_z+b_x$
my needs were to interpolate elevation data from a route specified by lat, lon, and elevation. after smoothing the lat/lon data i needed to interpolate elevation data from the new lat/lon data points. this worked as i expected. of course there are the degenerate cases where rises or the runs are zero but those are easily detected and accounted for.
