Max distance between a line and a parabola I am suppose to use calculus to find the max vertical distance between the line $y = x + 2$ and the parabola $y = x^2$ on the interval $x$ greater then or equal to $-1$ and less then or equal to $2$.
I really have no idea what to do. I found the critical numbers and that didn't help at all. I guess all the integers and that didn't help either.
 A: Clearly, $P(t,t^2)$ is any point of the parabola.
The distance of the line: $y=x+2$ from $P(t,t^2)$ is $$\left|\frac{t-t^2+2}{\sqrt{1^2+1^2} }\right|=\frac{|t-t^2+2|}{\sqrt2}$$
Let $f(t)=t-t^2+2$
so, $f'(t)=1-2t$
For the extreme values of $f(t), f'(t)=0\implies t=\frac12$
Now, $f''(t)=-2<0$
So, $f(t)$ will be maximum at $t=\frac12$
$$f(t)_{max}=\frac12-\left(\frac12\right)^2+2=\frac94$$
So, the maximum distance is $\frac{\frac94}{\sqrt 2}$ unit $=\frac 9{4\sqrt2}$ unit and $P$ being $(\frac12, \left(\frac12\right)^2)$ or $(\frac12,\frac14)$
The maximum value of $f(t)$ can also be derived in the following way.
Let $y=t-t^2+2\implies t^2-t+2-y=0$ which is a quadratic equation in $t$.
As $t$ is real, the discriminant $(-1)^2-4(y-2)\ge 0\implies y\le \frac94$
A: Note: The following solves the problem of maximizing the distance between two points, one on a line and one on a parabola, subject to a constraint. This is what the question above asks, although comments from the OP suggest that the intent was to maximize the difference of the $y$ values for a given $x$.
Here is another way:
Let $(x_1,x_1+2)$ be a point on the line and $(x_2,x_2^2)$ be a point on the parabola. Maximizing the distance is equivalent to maximizing the square of the distance, and the square is more tractable. So, we want to maximize $f(x_1,x_2) = (x_1-x_2)^2+(x_1+2-x_2^2)^2$, subject to $ x_1, x_2 \in [-1,2]$.
First, notice that the function $x_1 \mapsto f(x_1,x_2)$ is always a convex quadratic (ie, a quadratic in $x_1$, and the square term has a non-negative multiplier), regardless of the value of $x_2$. A convex quadratic on a closed interval takes its extreme value at the boundary of the interval. In this case, that gives, $\max(f(-1,x_2),f(2,x_2)) \geq f(x_1,x_2)$. Hence we may presume that $x_1 \in \{-1,2\}$. To find a solution we can maximize $f$ with $x_1$ set to $-1$, and again with $x_1=2$ and pick the maximum value.
Let  $f_1(x_2) = f(-1,x_2), f_2(x_2) = f(2,x_2)$. Expanding these gives $f_1(x_2) = (1-x_2^2)^2+(1+x_2)^2$, $f_2(x_2) = (4-x_2^2)^2+(x_2-2)^2$.
We have $f_1'(x_2) = 2(x_2+1)(2x_2^2-2 x_2+1)$. The latter factor has no real roots, hence $f_1$ is non-negative, and is monotonic on the intervals $(-\infty,-1]$ and $[-1,\infty)$. Hence the maximum of $f_1$ on $[-1,2]$ is $f_1(2) = 18$.
$f_2'(x_2)= 2(x_2-2)(x_2+1-\frac{1}{\sqrt{2}})(x_2+1+\frac{1}{\sqrt{2}})$. Hence $f_2$ is monotonic on the intervals $(-\infty, -1-\frac{1}{\sqrt{2}}]$, $[-1-\frac{1}{\sqrt{2}},-1+\frac{1}{\sqrt{2}}]$, $[-1+\frac{1}{\sqrt{2}}, 2]$ and $[2,\infty)$. A moment's thought shows that $f_2$ is maximized at $x_2=-1+\frac{1}{\sqrt{2}}$ on the interval $[-1-\frac{1}{\sqrt{2}}, 2]$, and $f_2(-1+\frac{1}{\sqrt{2}}) = \frac{71+\sqrt{128}}{4} > 18$.
Hence the maximum distance is $\sqrt{\frac{71+\sqrt{128}}{4}}$ and it occurs at $x_1 = 2, x_2 = -1+\frac{1}{\sqrt{2}}$.
Addendum: Here is a solution to the actual problem I think the OP is trying to ask (with apologies to @Git Gud):
First, you should draw a picture.

Solve $\max_{x \in [-1,2]} |x+2-x^2|$. First note that $x+2 \geq x^2$ if and only if  $x \in [-1,2]$, so the problem becomes $\max x+2-x^2$. Setting the derivative to zero gives $x=\frac{1}{2}$, hence the maximum value is $\frac{9}{4}$ which occurs at $x=\frac{1}{2}$.
A: This question is old but I just came across it and I'd like to share what I believe is the easiest way to solve it. The question is from the book "Calculus Early Trascendentals" 7th ed. ISBN: 978-0-538-49790-9 p. 331 q. 4.7.5
You're looking for a point $a$ where the vertical distance, lets call it $ D $ between two functions on a closed interval is greatest:
$ -1 \le x \le 2 $
You have two functions
$ f(x) = x + 2 $
$ g(x) = x^2 $
If you draw these out, you'll see that the $f$ function is higher on that interval. So what you need to do is to just remove the function value of the $g$ function from the $f$ function at all possible $x$ values. You can do this with a few iteration of x values, or use calculus. Lets use calculus.
$ D(x) = f(x) - g(x) $
$ D(x) = x + 2 - x^2 $
This will give you the vertical distance of any x value between f and g.
Now if you were to derive this new equation and looks for when the derivative = 0, you'd find the local maximum.
$ D' = -2x + 1 $
$ -2x + 1 = 0 $
$ x = 1/2 $
Insert this value in the original D equation and get the point a where the vertical distance between f and g is the greatest.
$ D( 1/ 2) = 1/2 + 2 - (1/2)^2 = 9/4 $
A: Hint. See the Math Java Applet in 
http://www.ies.co.jp/math/java/conics/draw_parabola/draw_parabola.html
for a geometry ideia.
