Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
It is my understanding that the OP wants to maximize $|x+2-x^2|$, not the distance. (I think the stated problem is educationally interesting because it requires a little thought.) – copper.hat Jan 10 '13 at 21:17
up vote 1 down vote accepted

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. enter image description here

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

share|cite|improve this answer
I have no clue what you are going on about. I can't even follow what you say at all without a dictionary. I have no idea what maximizing the square of the distance is or where it came from. I don't know what subject to means, I don't know what the E means I don't know what that arrow implies I don't know what a convex quadratic is, this makes all the math impossible to follow. – user56699 Jan 10 '13 at 20:41
Settle down. I am trying to help you by answering your question. Can you confirm that the problem is to find the maximum distance between the two curves, or did you mean to maximize the difference between the two functions? The first problem takes some effort, which I have expended, the latter is straightforward. – copper.hat Jan 10 '13 at 20:48
I am finding the max vertical distance. – user56699 Jan 10 '13 at 20:51
That is not what your question asked. – copper.hat Jan 10 '13 at 20:57
So what do I do? – user56699 Jan 10 '13 at 21:01

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$


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$

share|cite|improve this answer
Clearly? I don't understand what you mean by P(t, t^2) – user56699 Jan 10 '13 at 18:42
@user56699, have you heard parametric equation. If we put $x=t, y=x^2=t^2$ so ,any point on the parabola $y=x^2$ can be written as $(t,t^2)$ – lab bhattacharjee Jan 10 '13 at 18:44
I have never heard of a parametric equation before. – user56699 Jan 10 '13 at 20:38
This is incorrect. You are finding the maximum of the minimum distances, not the maximum. – copper.hat Jan 10 '13 at 21:04
@copper.hat, could you please elaborate a bit? – lab bhattacharjee Jan 11 '13 at 15:03

Hint. See the Math Java Applet in

for a geometry ideia.

share|cite|improve this answer

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 $

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.