# Math Q: Calculus, Maximization / Optimization Problem

**URL:** <https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078>\
**Category:** Factual Questions\
**Created:** [July 25, 2017, 1:43pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078 "2017-07-25T13:43:43Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 25, 2017, 6:17pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/21 "2017-07-25T18:17:42Z")

</div>

> [@Bullitt](#):
>
> This does not give one side of the rectangle on the sloped line, right?

What I mean is, if one of the sides of the rectangle is on the sloped line, then I claim the opposite side of the rectangle will be the segment joining the midpoints of the other two sides of the triangle.

I think this geometrically illustrates some sort of symmetry principle: for instance if you want to maximize the product of a bunch of positive numbers under the condition that their sum be fixed, then all of the numbers should be equal.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 25, 2017, 8:47pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/22 "2017-07-25T20:47:35Z")

</div>

[quote=“Buck\_Godot, post:11, topic:792078”]

Are you postiive that it is this way it is and that md2000 doesn’t have it right?

The problem you are posing is much harder and not what I would expect to see as a standard homework problem, although I could see it as an extra credit problem for motivated students.

[QUOTE]

I’m certain. The young boy is going into his junior year in high school but his parents have him taking this calc class at a local junior college.

> [@Buck\_Godot](#):
>
> Here is how you would do it.
> 
> Let one corner of the square be at (X,0)
> 
> based on this corner, you can find the next corner (0,Y) in terms of X by running a line from (X,0) parallel to the (4,0), (0,2) line until it hits the X axis.
> 
> The distance between these two points (in terms of X) will be the length of one side of the square. Next you find the distance between (X,0) and the (4,0), (0,2) line, using a [well known formula](https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line). That will give you the length of the second side (again in terms of X).
> 
> now multiply those two values together and you will get the area (in terms of X). Now take the derivative, set it equal to 0 to solve for X to find the maximal point. Plug it into your area equation and voila you get your answer.

Thanks. We both looked at this approach and we’re proceeding down ths path. Thank you. He has left now and I’ll check in with him by tomorrow to see how he’s doing.

Thanks again to all for all the help.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 25, 2017, 8:51pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/23 "2017-07-25T20:51:12Z")

</div>

> [@DPRK](#):
>
> What I mean is, if one of the sides of the rectangle is on the sloped line, then I claim the opposite side of the rectangle will be the segment joining the midpoints of the other two sides of the triangle.
> 
> I think this geometrically illustrates some sort of symmetry principle: for instance if you want to maximize the product of a bunch of positive numbers under the condition that their sum be fixed, then all of the numbers should be equal.

This may be the true solution, and we haven’t yet solved it (I’ll play with it tonight, hopefully solving it – it’s been a long time since I did anything like this), but this approach does not definitively prove that A is maximized. And that’s what we need.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 25, 2017, 9:19pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/24 "2017-07-25T21:19:40Z")

</div>

My comment was primarily meant in response to **Snarky\_Kong** ’s post about constructing the rectangle. To prove that it maximizes the area, let’s take it as read that a maximal-area rectangle has all of its vertices on the triangle and one of its sides along the hypotenuse of the right triangle. There are now several ways to express its area as a function of one variable, some of which may look messier than others. Hint is to let the variable be the coordinate of one of the vertices of the rectangle, as in **naita** ’s post, or you could choose the length of one of the sides of the rectangle as your variable. This is a geometry problem that involves no calculus, but it still may be potentially tripping up your student; you tell me? But, once this is done, the final step is to apply Fermat’s theorem (stated in post #2). The check is that you should probably be maximizing a simple-looking quadratic function of your variable.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 25, 2017, 9:27pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/25 "2017-07-25T21:27:25Z")

</div>

ETA the symmetry business could provide a solution along the lines of: let (x,0) and (0,y) be the two corners of the rectangle lying along the coordinate axes. Letting z = 2y, this area will be maximized exactly when the corresponding rectangle with corners (x,0) and (0,z) inscribed in an isosceles right triangle with two sides of length 4 is maximized. By symmetry x=z, and sinze x+z=4 you get x=2 and y=1.

I don’t know whether this is a more “true” solution, but symmetry is clear even without any calculus in the isosceles case.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 26, 2017, 1:29pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/26 "2017-07-26T13:29:16Z")

</div>

Okay, I think I got it. Sorry, I solved (me thinks) this last night but fell asleep before I could finish this post.

{Note: When I write √(3/5), that is = sqrt(3/5).}

> [@DPRK](#):
>
> ETA the symmetry business could provide a solution along the lines of: let (x,0) and (0,y) be the two corners of the rectangle lying along the coordinate axes. Letting z = 2y, this area will be maximized exactly when the corresponding rectangle with corners (x,0) and (0,z) inscribed in an isosceles right triangle with two sides of length 4 is maximized. By symmetry x=z, and sinze x+z=4 you get x=2 and y=1.
> 
> I don’t know whether this is a more “true” solution, but symmetry is clear even without any calculus in the isosceles case.

Hmm, not sure I follow, especially when you introduce z. I tried to minimize variables.

I followed **Buck** ’s approach, and like **naita** I did get A’(x) = 0 for x = 1. This was more painful than it needed to be because I am so rusty. Hopefully no mistakes. Please check.

In the hopes of making this easier to read and follow I will start with my answers, then follow that with my work:

A’(x) = -4√(3/5) (x₁) + 4√(3/5)  
A’(x) = 0, ⇒ x₁ = 1 and 2x₁ = 2. The two corners on the axes are (1,0) and (0,2).  
∴ A(x) = 2√(3/5)  
Here’s my work.

Following **Buck** , the two corners on the axes are (x₁,0) and (0,2x₁).

For the distance between (x₁,0) and y = -2x + 4:  
Putting y = -2x + 4 in ax + by + c = 0 form is 2x + y - 4 = 0  
From the distance formula,  
distance = |ax₀ + by₀ + c| ÷ √(a² + b²), where (x₀,y₀) = (x₁,0),  
|2x₁ + 0 - 4| ÷ √(2² + 1²) = |2x₁ - 4| ÷ √5,  
distance = (-2x₁ + 4)/√5

For the distance between (x₁,0) and (0,2x₁): √(4x₁² - x₁²) = √3(x₁)

∴ A, the area of the rectangle,  
A(x) = [(-2x₁ + 4)/√5] x √3(x₁)  
= (-2√3(x₁²) + 4√3(x₁)] ÷ √5  
= -2√(3/5) (x₁²) + 4√(3/5) (x₁)

And ∴ A’(x) = -4√(3/5) (x₁) + 4√(3/5)

A’(x) = 0, ⇒ x₁ = 1 and 2x₁ = 2. The two corners on the axes are (1,0) and (0,2).

∴ A(x) = 2√(3/5)  
Not required, but therefore the lines defining the four sides of the rectangle are:  
y = -2x + 4, the original line,  
y = -2x + 2, the parallel opposite side,  
y = ½x + 2, the “upper” end, and  
y = ½x - ½, the “lower” end  
**DPRK** , I’ll have to take a closer look at your approach. It seems quite elegant and I’ll try to follow it.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 26, 2017, 1:46pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/27 "2017-07-26T13:46:30Z")

</div>

Less verbosely, by stretching/shrinking you can reduce the problem to that for an isosceles right triangle.

This is related to stuff like the inequality between the geometric mean and arithmetic mean of two numbers, which is interesting. But the calculus is identical to what you have already written; maybe the symmetry makes things less messy.

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [July 26, 2017, 2:04pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/28 "2017-07-26T14:04:11Z")

</div>

Hint: The line through those points has the equation x/4 + y/2 = 1. Clearly both (4,0) and (0,2) satisfy that equation and two points determine a line. Assuming one corner lies on that line, you express the area as a function of x, differentiate and set the derivative to 0, which gives the unique solution.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 26, 2017, 5:25pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/29 "2017-07-26T17:25:58Z")

</div>

> [@Hari\_Seldon](#):
>
> Hint: The line through those points has the equation x/4 + y/2 = 1. Clearly both (4,0) and (0,2) satisfy that equation and two points determine a line. Assuming one corner lies on that line, you express the area as a function of x, differentiate and set the derivative to 0, which gives the unique solution.

Isn’t that what I did?

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [July 26, 2017, 5:40pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/30 "2017-07-26T17:40:52Z")

</div>

A couple of problems with your solution:

1. The slope of the line between (0,2) and (4,0) is -1/2, not -2.
2. The distance between (x₁,0) and (0,2x₁) is √(4x₁² + x₁²) not √(4x₁² - x₁²).

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [July 27, 2017, 1:00am UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/31 "2017-07-27T01:00:50Z")

</div>

> [@Bullitt](#):
>
> Isn’t that what I did?

I didn’t read your solution. You got the right answer to be sure, but all those square roots in between? I certainly didn’t have anything like that.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [July 27, 2017, 3:46am UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/32 "2017-07-27T03:46:26Z")

</div>

> [@Hari\_Seldon](#):
>
> Hint: The line through those points has the equation x/4 + y/2 = 1. Clearly both (4,0) and (0,2) satisfy that equation and two points determine a line. Assuming one corner lies on that line, you express the area as a function of x, differentiate and set the derivative to 0, which gives the unique solution.

It sounds like you’re answering the ambiguous set-up of the OP, not the clarified correct set-up he explained later.

We’re \*not \*constructing a rectangle with one vertex at the origin then proceeding counterclockwise, one at some (x,0), one at some (x,y) on the diagonal line, and the last point at (0,y).

Instead we’re constructing a rectangle contained wholly within the triangle formed by the two axes and the diagonal line. Subject to the constraint that one \*side \*of the rectangle is a segment of that diagonal line.

Rather a different problem.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 27, 2017, 1:54pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/33 "2017-07-27T13:54:38Z")

</div>

> [@markn\_1](#):
>
> A couple of problems with your solution:
> 
> 1. The slope of the line between (0,2) and (4,0) is -1/2, not -2.
> 2. The distance between (x₁,0) and (0,2x₁) is √(4x₁² + x₁²) not √(4x₁² - x₁²).

#1 – I don’t think so…?  
#2 – thanks for the correction! Somewhere, Pythagoras was rolling in his grave, watching me try to apply his theorem. 🙂

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [July 27, 2017, 2:54pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/34 "2017-07-27T14:54:44Z")

</div>

I didn’t notice the change in the problem. The OP certainly allowed that configuration as well as the original one. Simply find the largest rectangle contained within that triangle. This allows the possibility that the edges of the rectangle do not lie along any of the edges of the triangle (although it is clear that its vertices must lie on the triangle). A problem so broadly stated might not even have a minimum (Cf. The Kakeya needle problem: [Kakeya set - Wikipedia](https://en.wikipedia.org/wiki/Kakeya_set)). At any rate the question is a variational one, far beyond elementary calculus.

So that leaves two separate questions. Find the largest rectangle with two edges on the axes and vertex on the line and the largest rectangle with an edge along that line and vertices on the axes. Very curiously, both problems have the same answer: 2 square units. I would conjecture that that is the answer to the more general question too.

Incidentally, the second form of the question is considerably more complicated than the first. It is not, in principle, beyond what an elementary calculus student might do, but it is complicated. You have to assume a point (t,0) on the x-axis, then figure out where the line of slope 2 through that point meets the line, then the length of that segment, multiply by the length of the segment between (t,0) and (0,t/2), differentiate with respect to t, etc. To no surprise, t = 2 is the solution.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 27, 2017, 3:34pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/35 "2017-07-27T15:34:12Z")

</div>

I (mistakenly?) thought the original original problem was to find the maximum area of a rectangle inscribed in a (particular, although the particulars do not particularly matter) triangle. It is fairly clear that a maximum value exists, although there is more than one rectangle that achieves it.

The glossed-over part was to prove that a maximizing rectangle has one of its sides contained in one of the sides of the triangle. The OP later came back and said not to worry about it, that for the purposes of this exercise one could assume this.

After this step, there is a choice of which side of the triangle to pick, but I will boldly claim it makes no difference in terms of difficulty as either way you end up with maximizing a simple quadratic function of one variable. (ETA and you get the same answer as **Chronos** mentioned; there is only an issue for obtuse triangles.)

We can see that it is not so surprising that the original teenager was confused by all this, and it was not simply a case of a kid too lazy to do a bog-standard homework problem by himself.

---

<div class="post-metadata">

**Author:** ![markn\_1](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@markn\_1](https://boards.straightdope.com/u/markn_1)\
**Post date:** [July 27, 2017, 4:13pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/36 "2017-07-27T16:13:59Z")

</div>

> [@Bullitt](#):
>
> #1 – I don’t think so…?

Slope is (y[sub]2[/sub] - y[sub]1[/sub]) / (x[sub]2[/sub] - x[sub]1[/sub]).

If p[sub]1[/sub] = (0,2) and p[sub]2[/sub] = (4,0), the slope is

(0-2)/(4-0) = -1/2.

Of course it’s the same if you swap p[sub]1[/sub] and p[sub]2[/sub]:

(2-0)/(0-4) = -1/2.

---

<div class="post-metadata">

**Author:** ![Bullitt](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bullitt/32/5725_2.png) [@Bullitt](https://boards.straightdope.com/u/Bullitt)\
**Post date:** [July 28, 2017, 2:00pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/37 "2017-07-28T14:00:20Z")

</div>

> [@markn\_1](#):
>
> Slope is (y[sub]2[/sub] - y[sub]1[/sub]) / (x[sub]2[/sub] - x[sub]1[/sub]).
> 
> If p[sub]1[/sub] = (0,2) and p[sub]2[/sub] = (4,0), the slope is
> 
> (0-2)/(4-0) = -1/2.
> 
> Of course it’s the same if you swap p[sub]1[/sub] and p[sub]2[/sub]:
> 
> (2-0)/(0-4) = -1/2.

Yes it is! y = mx + b → → m = -½.  
But! Oops! (and… oh shit!) In my OP I mistakenly said the points were (0,2) and (4,0). But the problem has the points at (0,4) and (2,0)!!! I goofed and miswrote it. So sorry about the (my!) confusion! That’s why I was saying m = -2.

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [July 28, 2017, 2:38pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/38 "2017-07-28T14:38:26Z")

</div>

I love these puzzle threads where the actual puzzle finally emerges somewhere around page 2. 🙂

But boy do we have fun chasing the other version(s)’ inadvertent rabbit trails. And the rabbit trails of the rabbit trails\*. With a few contributions of pure rabbit droppings along the way for spice. 😃

======

- Would proper notation for these be rabbit[sup]2[/sup] trails, rabbit trails[sup]2[/sup], or {rabbit trails}[sup]2[/sup]?

---

<div class="post-metadata">

**Author:** ![Hari\_Seldon](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/hari_seldon/32/5173_2.png) [@Hari\_Seldon](https://boards.straightdope.com/u/Hari_Seldon)\
**Post date:** [July 28, 2017, 6:44pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/39 "2017-07-28T18:44:05Z")

</div>

> [@DPRK](#):
>
> I (mistakenly?) thought the original original problem was to find the maximum area of a rectangle inscribed in a (particular, although the particulars do not particularly matter) triangle. It is fairly clear that a maximum value exists, although there is more than one rectangle that achieves it.

Proof? I think it is true, but it is not obvious, not to me anyway.

I conjectured and have now proved that in the largest rectangle inscribed in either of two ways in any right triangle has exactly half the area of the triangle. The first way is the way I understood it at first with two edges of the rectangle along the legs and a vertex on the hypotenuse. The second way is with one edge along the hypotenuse and one vertex on each leg. In either case, the midpoint of each leg is a vertex. Could some tilted rectangle be larger? It seems unlikely, but I cannot disprove it.

---

<div class="post-metadata">

**Author:** ![DPRK](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@DPRK](https://boards.straightdope.com/u/DPRK)\
**Post date:** [July 28, 2017, 9:02pm UTC](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078/40 "2017-07-28T21:02:13Z")

</div>

> [@Hari\_Seldon](#):
>
> Proof? I think it is true, but it is not obvious, not to me anyway.

Suppose we somehow define the space of rectangles in the plane: for example, by specifying the center, length, width, and orientation as coordinates. What I care about is that the function which computes the area of a rectangle is a continuous function on this space.

Now consider any triangle; some of the rectangles will be contained in it, which may be a complicated-looking condition on the coordinates but it will define a closed and bounded subset of the space of rectangles. It follows that the area function takes on extreme values.

> [@](#):
>
> I conjectured and have now proved that in the largest rectangle inscribed in either of two ways in any right triangle has exactly half the area of the triangle. The first way is the way I understood it at first with two edges of the rectangle along the legs and a vertex on the hypotenuse. The second way is with one edge along the hypotenuse and one vertex on each leg. In either case, the midpoint of each leg is a vertex. Could some tilted rectangle be larger? It seems unlikely, but I cannot disprove it.

Well, if an inscribed rectangle has 4 or 3 or 2 of its corners in the interior of the triangle, by slightly enlarging it you can find a rectangle with strictly greater area still contained in the triangle. If a rectangle is jammed in so that only 1 vertex is in the interior, I think that by considering the parallelogram of equal area obtained by sliding the interior vertex parallel to one of the two sides of the rectangle in which it is not contained until it hits the boundary of the triangle, you can see that the resulting parallelogram is contained in a triangle strictly smaller than the original, so the tilted rectangle is again not optimal.

[Previous page](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078.md?page=1)

[Next page](https://boards.straightdope.com/t/math-q-calculus-maximization-optimization-problem/792078.md?page=3)
