We are given the equation:
\[
\tan^{-1}x + \tan^{-1}2x = \frac{\pi}{4}.
\]
Step 1: Use the identity for the sum of arctangents
The identity for the sum of arctangents is:
\[
\tan^{-1} a + \tan^{-1} b = \tan^{-1} \left( \frac{a + b}{1 - ab} \right), \quad \text{for} \quad ab < 1.
\]
Using this identity, we can write:
\[
\tan^{-1} x + \tan^{-1} 2x = \tan^{-1} \left( \frac{x + 2x}{1 - x \cdot 2x} \right) = \tan^{-1} \left( \frac{3x}{1 - 2x^2} \right).
\]
Step 2: Set the equation equal to \( \frac{\pi}{4} \)
We know that \( \tan \frac{\pi}{4} = 1 \), so we set the argument of the arctangent equal to 1:
\[
\frac{3x}{1 - 2x^2} = 1.
\]
Multiply both sides by \( 1 - 2x^2 \):
\[
3x = 1 - 2x^2.
\]
Step 3: Solve the quadratic equation
Rearrange the terms:
\[
2x^2 + 3x - 1 = 0.
\]
Solve this quadratic equation using the quadratic formula:
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a},
\]
where \( a = 2, b = 3, c = -1 \). Substituting these values:
\[
x = \frac{-3 \pm \sqrt{3^2 - 4(2)(-1)}}{2(2)} = \frac{-3 \pm \sqrt{9 + 8}}{4} = \frac{-3 \pm \sqrt{17}}{4}.
\]
Thus, the real values of \( x \) are \( \frac{\sqrt{17} - 3}{4} \).