Calculate width and height of a rectangle, given its diagonal and ratio

Solution 1:

Suppose that the unknown width and height are $x$ and $y$, and you’re given a diagonal $d$ and a ratio $m:n$ of width to height. That ratio means that the width is $\frac{m}{n}$ times the height, so you know that $x=\frac{m}{n}y$. You get a second relationship between $x$ and $y$ from the Pythagorean theorem: $x$, $y$, and $d$ are the lengths of the two legs and the hypotenuse of a right triangle, so $x^2+y^2=d^2$.

Now substitute $\frac{m}{n}y$ for $x$ in this second equation to get $\displaystyle\left(\frac{m}{n}y\right)^2 + y^2 = d^2$. Simplifying this, you get in turn: $$\frac{m^2}{n^2}y^2 + y^2 = d^2,$$ $$\left(\frac{m^2}{n^2}+1\right)y^2 = d^2,$$ $$\left(\frac{m^2+n^2}{n^2}\right)y^2=d^2,$$ and $$(m^2+n^2)y^2=d^2n^2.$$ Finally, solve for $y$: $\displaystyle y^2 = \frac{d^2n^2}{m^2+n^2}$, so $y=\displaystyle\frac{dn}{\sqrt{m^2+n^2}}$.
Once you have a numerical value for $y$, you can plug it into $x=\frac{m}{n}y$ to get a value for $x$.
(Or you can do that symbolically: $\displaystyle x=\frac{m}{n}\cdot \frac{dn}{\sqrt{m^2+n^2}} =$ $\displaystyle\frac{dm}{\sqrt{m^2+n^2}}$.)

Solution 2:

$$w^2+h^2=32^2,\\\frac wh=\frac{16}{9}.$$

Then dividing by $h^2$,

$$\frac{w^2}{h^2}+1=\frac{16^2}{9^2}+1=\frac{32^2}{h^2},$$

$$h=\frac{32\cdot9}{\sqrt{16^2+9^2}},w=\frac{16}9h.$$