Largest square that can fit into region. Let $R$ be the region bounded by the lines $y=cx+b$ and $y=cx+d$. Find the sides of largest square, with sides parallel to the $x$ and $y$ axis in $R$.
Here is what I know. The distance between the two lines is $\frac{|b-d|}{ \sqrt{c^2+1}}$. Without the requirement, this is the side length. What trips me up is the requirement that the sides be parallel to the $x$ and $y$ axis how do I deal with this? 
 A: Suppose without loss of generality that $b> d$, so that line $l_1: y=cx+b$ lies above line $l_2:y=cx+d$. Moreover, in this answer we will assume that $c>0$, but the solution can be easily adapted to the case $c<0$. The case $c=0$ is trivial.
Choose any point on $l_1$, say $A=(0,b)$. Our square will be $ABCD$. We will find the point opposite $A$, that is, $C$. To this end, notice that the diagonal $AC$ will make an angle of $135^\circ$ with the $x$-axis, and that $C$ will lie on $l_2$. That is, $AC$ belongs to the line $r(t)=(0,b)+t\cdot(1,-1)$, in parametric equation. In choosing $(1,-1)$ we have used that $c>0$, and we will hence have $t>0$ in the intersection. If we had $c<0$, we'd need to choose $(-1,-1)$ for the same effect.
To find the intersection we solve
$$b-t=tc+d\implies t(1+c)=b-d\implies t=\frac{b-d}{1+c}$$
Hence, $C=\left(\frac{b-d}{1+c},\frac{bc+d}{1+c}\right)$. We have that
$$AC={\lVert C-A\rVert}={\left\lVert\left(\frac{b-d}{1+c},\frac{bc+d}{1+c}\right)-(0,b) \right\rVert}={\left\lVert\left(\frac{b-d}{1+c},-\frac{b-d}{1+c}\right) \right\rVert}=\frac{b-d}{1+c}\sqrt{2}.$$
Since $AC=e\sqrt{2}$, where $e$ is the length of the side of the square, we get that
$$e=\frac{b-d}{1+c}$$

If $c$ were negative, we'd have $r:y=(0,b)+t\cdot(-1,-1)$ so that $b-t=-tc+d$ and hence $t=\frac{b-d}{1-c}$. Then $C=\left(\frac{b-d}{1-c},\frac{d-bc}{1-c}\right)$ and $AC=\frac{b-d}{1-c}\sqrt{2}$, so that $e=\frac{b-d}{1-c}$.
Hence, in general, we have
$$e=\frac{|b-d|}{1+|c|}$$
Notice that this also works for when $c=0$, ie, $l_1$ and $l_2$ are vertical.
A: Hints: Start with a picture.  I like having $c>0$ and $b>d$.  
Then pick a point on the lower line $y=cx+d$.  Call it $(r,s)$.
Take this as the lower right corner of a maximal square.
Then, the opposite corner must line on a line with slope $-1$ through $(r,s)$ and lie on the line $y=cx+b$.  Solve for this point, and show that the side length can be expressed in terms of $c, b,$ and $d$.  Note that the side length is simply the difference between the $x$ coordinate of this corner and $r$.
