# Algebra/geometry question

**URL:** <https://boards.straightdope.com/t/algebra-geometry-question/1027935>\
**Category:** Factual Questions\
**Created:** [February 24, 2026, 4:12pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935 "2026-02-24T16:12:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [February 24, 2026, 4:12pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/1 "2026-02-24T16:12:58Z")

</div>

At least I don’t _think_ resorting to Trigonometry should be necessary; but here’s hoping.

My question is related to what’s known as [the right triangle altitude theorem](https://en.wikipedia.org/wiki/Geometric_mean_theorem#), aka. the geometric mean theorem. Basically, when you have a right triangle with the hypotenuse taken as the base, the theorem relates the relationship between the hypotenuse, the vertical altitude, and the bases of the two resulting smaller similar triangles:

> If h denotes the altitude in a right triangle and p and q the segments on the hypotenuse then the theorem can be stated as h = {\sqrt {p×q}}

To give an example with all whole numbers, if you have a 3-4-5 right triangle of hypotenuse 25 with sides of 15 and 20, the altitude will be 12 and **p** and **q** will be 9 and 16.

My question is concerned with a rectangle containing the right triangle, with height the same as the altitude and a length of **p** + **q**. I want to be able to take the ratio of length to width of the rectangle as a single number, and plug that into a formula that will give the ratio **p** : **q**. This should be doable, yet my algebra skills seem insufficient. Anyone?

---

<div class="post-metadata">

**Author:** ![Topologist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/topologist/32/3208_2.png) [@Topologist](https://boards.straightdope.com/u/Topologist)\
**Post date:** [February 24, 2026, 5:59pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/2 "2026-02-24T17:59:51Z")

</div>

If I understand correctly, here’s the formula you’re looking for. If r = (p+q)/\sqrt{pq} is the ratio of length to width, then

\frac pq = \tfrac 12\left( r^2 - 2 + r\sqrt{r^2-4} \right).

The square root is OK because r\geq 2 by the arithmetic-geometric mean inequality.

Here’s how I derived it: Let x = p/q. Then

r = \frac{p+q}{\sqrt{pq}} = \sqrt{x} + \frac{1}{\sqrt x}

so

r^2 = x + 2 + \frac 1x.

Rearranging,

x^2 + (2-r^2)x + 1 = 0

and now you can write down the solutions using the quadratic formula. One of those will give you x and the other gives you 1/x.

---

<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:** [February 24, 2026, 6:02pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/3 "2026-02-24T18:02:41Z")

</div>

I don’t know if I understand the question either, but if

x = \frac{p+q}{\sqrt{pq}}

then

\frac{p}{q} = \frac{x^2+x\sqrt{x^2-4}-2}{2}.

---

<div class="post-metadata">

**Author:** ![Topologist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/topologist/32/3208_2.png) [@Topologist](https://boards.straightdope.com/u/Topologist)\
**Post date:** [February 24, 2026, 6:04pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/4 "2026-02-24T18:04:14Z")

</div>

It must be right, we both got the same formula!

Last comment while I’m in the edit window: This formula assumes p\geq q. Put another way, it gives the larger of p/q or q/p.

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [February 24, 2026, 6:15pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/5 "2026-02-24T18:15:59Z")

</div>

Got it (I think). I’ll play around with it and see if some examples give the expected answers. Thanks all!

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [February 25, 2026, 11:57pm UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/6 "2026-02-25T23:57:47Z")

</div>

> [@Topologist](#):
>
> Let x = p/q. Then
> 
> r = \frac{p+q}{\sqrt{pq}} = \sqrt{x} + \frac{1}{\sqrt x}

I’m sorry but this left me completely dead in the water. I don’t know how you derive the second half of the equation from the first half. I’m missing a step somewhere.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [February 26, 2026, 12:06am UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/7 "2026-02-26T00:06:03Z")

</div>

It might be easier to go from the right side to the left?  
\sqrt{x}+\frac{1}{\sqrt{x}}  
\sqrt\frac{p}{q}+\sqrt\frac{q}{p}  
\frac{p}{\sqrt{pq}}+\frac{q}{\sqrt{pq}}  
\frac{p+q}{\sqrt{pq}}

---

<div class="post-metadata">

**Author:** ![Topologist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/topologist/32/3208_2.png) [@Topologist](https://boards.straightdope.com/u/Topologist)\
**Post date:** [February 26, 2026, 12:14am UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/8 "2026-02-26T00:14:04Z")

</div>

Right. I left out the intermediate steps. But the key in either direction is realizing that you can rewrite the fraction

\frac{p+q}{\sqrt{pq}} = \frac{p}{\sqrt{pq}} + \frac{q}{\sqrt{pq}}.

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [February 26, 2026, 12:28am UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/9 "2026-02-26T00:28:28Z")

</div>

That much I got; but apparently if I was ever taught how to rework square roots in fractions, I’ve forgotten it.  
\sqrt\frac{q}{p} equals \frac{q}{\sqrt{pq}} ??

---

<div class="post-metadata">

**Author:** ![Topologist](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/topologist/32/3208_2.png) [@Topologist](https://boards.straightdope.com/u/Topologist)\
**Post date:** [February 26, 2026, 12:31am UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/10 "2026-02-26T00:31:52Z")

</div>

Inside the square root, multiply and divide by q:

\sqrt{\frac qp} = \sqrt{\frac{q^2}{pq}} = \frac{\sqrt{q^2}}{\sqrt{pq}} = \frac{q}{\sqrt{pq}}

Or, you can work it from right to left, first using that q = \sqrt{q^2}.

---

<div class="post-metadata">

**Author:** ![Lumpy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lumpy/32/446_2.png) [@Lumpy](https://boards.straightdope.com/u/Lumpy)\
**Post date:** [February 26, 2026, 12:57am UTC](https://boards.straightdope.com/t/algebra-geometry-question/1027935/11 "2026-02-26T00:57:41Z")

</div>

Well it’s apparent why I couldn’t come up with a formula on my own. And yet given concrete numbers for the hypotenuse and the altitude, I was calculating 𝑝 and 𝑞 fairly easily; I just couldn’t figure out how to generalize it.
