Concept:
We use the compound angle identity \( \tan(A \pm B) = \frac{\tan A \pm \tan B}{1 \mp \tan A \tan B} \). Knowing that \( \tan(\pi/4) = 1 \), the expressions simplify to \( \frac{1 + \tan(\theta/2)}{1 - \tan(\theta/2)} \) and its reciprocal-like counterpart.
Step 1: Applying compound angle identities.
\[ \tan\left(\frac{\pi}{4} + \frac{\theta}{2}\right) = \frac{1 + \tan(\theta/2)}{1 - \tan(\theta/2)} \]
\[ \tan\left(\frac{\pi}{4} - \frac{\theta}{2}\right) = \frac{1 - \tan(\theta/2)}{1 + \tan(\theta/2)} \]
Adding the two terms using a common denominator:
\[ = \frac{(1 + \tan(\theta/2))^2 + (1 - \tan(\theta/2))^2}{(1 - \tan(\theta/2))(1 + \tan(\theta/2))} \]
Step 2: Simplifying the result.
Using the identity \( (a+b)^2 + (a-b)^2 = 2(a^2 + b^2) \):
\[ = \frac{2(1 + \tan^2(\theta/2))}{1 - \tan^2(\theta/2)} \]
Recalling the double angle formula \( \cos \theta = \frac{1 - \tan^2(\theta/2)}{1 + \tan^2(\theta/2)} \), we see our result is the reciprocal:
\[ = 2 \times \frac{1}{\cos \theta} = 2 \sec \theta \]