Let $a$ be a positive constant. Evaluate the following definite integrals $A,\ B$.

\[A=\int_0^{\pi} e^{-ax}\sin ^ 2 x\ dx,\ B=\int_0^{\pi} e^{-ax}\cos ^ 2 x\ dx\].

[i]1998 Shinsyu University entrance exam/Textile Science[/i]
1. First, we start by evaluating the sum of the integrals \(A\) and \(B\):
   \[
   A + B = \int_0^\pi e^{-ax} \sin^2 x \, dx + \int_0^\pi e^{-ax} \cos^2 x \, dx
   \]
   Using the trigonometric identity \(\sin^2 x + \cos^2 x = 1\), we get:
   \[
   A + B = \int_0^\pi e^{-ax} (\sin^2 x + \cos^2 x) \, dx = \int_0^\pi e^{-ax} \, dx
   \]
   The integral \(\int_0^\pi e^{-ax} \, dx\) can be evaluated as:
   \[
   \int_0^\pi e^{-ax} \, dx = \left[ \frac{e^{-ax}}{-a} \right]_0^\pi = \frac{1}{a} (1 - e^{-a\pi})
   \]
   Therefore:
   \[
   A + B = \frac{1}{a} (1 - e^{-a\pi})
   \]

2. Next, we evaluate the difference of the integrals \(B\) and \(A\):
   \[
   B - A = \int_0^\pi e^{-ax} \cos^2 x \, dx - \int_0^\pi e^{-ax} \sin^2 x \, dx
   \]
   Using the trigonometric identity \(\cos^2 x - \sin^2 x = \cos(2x)\), we get:
   \[
   B - A = \int_0^\pi e^{-ax} \cos(2x) \, dx
   \]

3. To evaluate \(\int_0^\pi e^{-ax} \cos(2x) \, dx\), we use integration by parts twice. Let:
   \[
   I = \int e^{-ax} \cos(2x) \, dx
   \]
   Using integration by parts, where \(u = \cos(2x)\) and \(dv = e^{-ax} dx\), we get:
   \[
   du = -2 \sin(2x) \, dx \quad \text{and} \quad v = \frac{e^{-ax}}{-a} = -\frac{e^{-ax}}{a}
   \]
   Therefore:
   \[
   I = \int e^{-ax} \cos(2x) \, dx = -\frac{\cos(2x) e^{-ax}}{a} - \int -\frac{e^{-ax}}{a} (-2 \sin(2x)) \, dx
   \]
   Simplifying, we get:
   \[
   I = -\frac{\cos(2x) e^{-ax}}{a} + \frac{2}{a} \int e^{-ax} \sin(2x) \, dx
   \]
   Let \(J = \int e^{-ax} \sin(2x) \, dx\). Using integration by parts again, where \(u = \sin(2x)\) and \(dv = e^{-ax} dx\), we get:
   \[
   du = 2 \cos(2x) \, dx \quad \text{and} \quad v = -\frac{e^{-ax}}{a}
   \]
   Therefore:
   \[
   J = \int e^{-ax} \sin(2x) \, dx = -\frac{\sin(2x) e^{-ax}}{a} - \int -\frac{e^{-ax}}{a} (2 \cos(2x)) \, dx
   \]
   Simplifying, we get:
   \[
   J = -\frac{\sin(2x) e^{-ax}}{a} + \frac{2}{a} \int e^{-ax} \cos(2x) \, dx
   \]
   Substituting back, we get:
   \[
   J = -\frac{\sin(2x) e^{-ax}}{a} + \frac{2}{a} I
   \]
   Therefore:
   \[
   I = -\frac{\cos(2x) e^{-ax}}{a} + \frac{2}{a} \left( -\frac{\sin(2x) e^{-ax}}{a} + \frac{2}{a} I \right)
   \]
   Simplifying, we get:
   \[
   I = -\frac{\cos(2x) e^{-ax}}{a} + \frac{2 \sin(2x) e^{-ax}}{a^2} - \frac{4}{a^2} I
   \]
   Solving for \(I\), we get:
   \[
   I \left( 1 + \frac{4}{a^2} \right) = -\frac{\cos(2x) e^{-ax}}{a} + \frac{2 \sin(2x) e^{-ax}}{a^2}
   \]
   Therefore:
   \[
   I = \frac{-a \cos(2x) + 2 \sin(2x)}{a^2 + 4} e^{-ax}
   \]
   Evaluating the definite integral from \(0\) to \(\pi\), we get:
   \[
   \int_0^\pi e^{-ax} \cos(2x) \, dx = \left[ \frac{-a \cos(2x) + 2 \sin(2x)}{a^2 + 4} e^{-ax} \right]_0^\pi
   \]
   Since \(\cos(2\pi) = \cos(0) = 1\) and \(\sin(2\pi) = \sin(0) = 0\), we get:
   \[
   \int_0^\pi e^{-ax} \cos(2x) \, dx = \frac{a}{a^2 + 4} (1 - e^{-a\pi})
   \]
   Therefore:
   \[
   B - A = \frac{a}{a^2 + 4} (1 - e^{-a\pi})
   \]

4. Solving for \(B\) and \(A\), we get:
   \[
   B = \frac{1}{2} \left( \frac{1}{a} + \frac{a}{a^2 + 4} \right) (1 - e^{-a\pi})
   \]
   \[
   A = \frac{1}{2} \left( \frac{1}{a} - \frac{a}{a^2 + 4} \right) (1 - e^{-a\pi})
   \]

The final answer is \( \boxed{ B = \frac{1}{2} \left( \frac{1}{a} + \frac{a}{a^2 + 4} \right) (1 - e^{-a\pi}) } \) and \(A = \frac{1}{2} \left( \frac{1}{a} - \frac{a}{a^2 + 4} \right) (1 - e^{-a\pi})\)