Two semicircles touch the side of the rectangle, each other and the segment drawn in it as in the figure. What part of the whole rectangle is filled?
[img]https://cdn.artofproblemsolving.com/attachments/3/e/70ca8b80240a282553294a58cb3ed807d016be.png[/img]
1. **Identify the radii and height of the rectangle:**
   Let \( r_1 \) and \( r_2 \) be the radii of the two semicircles, with \( r_1 > r_2 \). The height of the rectangle is given by \( 2\sqrt{r_1 r_2} \) using the Pythagorean theorem.

2. **Reflect the upper triangular region:**
   Reflect the upper triangular region about the upper side of the rectangle to form an isosceles triangle with an inradius of \( r_1 \) and base length \( 2\sqrt{r_1 r_2} \). Let the height of this triangle be \( x \).

3. **Calculate the sides of the isosceles triangle:**
   The other sides of the isosceles triangle are \( \sqrt{x^2 + r_1 r_2} \).

4. **Determine the semiperimeter and area of the triangle:**
   The semiperimeter \( s \) of the triangle is:
   \[
   s = \sqrt{x^2 + r_1 r_2} + \sqrt{r_1 r_2}
   \]
   The area \( A \) of the triangle is:
   \[
   A = x \sqrt{r_1 r_2}
   \]

5. **Set up the equation for the inradius:**
   Using the formula for the inradius \( r \) of a triangle, we have:
   \[
   r_1 = \frac{A}{s} = \frac{x \sqrt{r_1 r_2}}{\sqrt{x^2 + r_1 r_2} + \sqrt{r_1 r_2}}
   \]
   Simplifying, we get:
   \[
   r_1 \left( \sqrt{x^2 + r_1 r_2} + \sqrt{r_1 r_2} \right) = x \sqrt{r_1 r_2}
   \]
   \[
   \frac{x}{r_1} = 1 + \sqrt{\frac{x^2}{r_1 r_2} + 1}
   \]

6. **Substitute variables:**
   Let \( u = \frac{x}{r_1} \) and \( w = \frac{r_1}{r_2} \). Then:
   \[
   u = 1 + \sqrt{u^2 w + 1}
   \]
   Squaring both sides:
   \[
   u^2 - 2u + 1 = u^2 w + 1
   \]
   Simplifying:
   \[
   u(u(1 - w) - 2) = 0
   \]
   Solving for \( u \):
   \[
   u = \frac{2}{1 - w}
   \]
   Therefore:
   \[
   x = \frac{2 r_1 r_2}{r_2 - r_1}
   \]

7. **Calculate the area of the filled region:**
   The filled region consists of the two semicircles. The area of the semicircles is:
   \[
   \text{Area of semicircles} = \frac{1}{2} \pi r_1^2 + \frac{1}{2} \pi r_2^2 = \frac{\pi}{2} (r_1^2 + r_2^2)
   \]
   The area of the rectangle is:
   \[
   \text{Area of rectangle} = 2\sqrt{r_1 r_2} \times (r_1 + r_2)
   \]

8. **Determine the fraction of the rectangle filled:**
   The fraction of the rectangle filled by the semicircles is:
   \[
   \text{Fraction filled} = \frac{\frac{\pi}{2} (r_1^2 + r_2^2)}{2\sqrt{r_1 r_2} \times (r_1 + r_2)}
   \]

The final answer is \( \boxed{ \frac{\frac{\pi}{2} (r_1^2 + r_2^2)}{2\sqrt{r_1 r_2} \times (r_1 + r_2)} } \).