We know that for a complex number to lie on the line \( y = x \), the real part and the imaginary part of the complex number must be equal. Let the complex number \( z \) be: \[ z = \frac{2 + i}{\lambda + i} \] Multiply both the numerator and denominator by the conjugate of the denominator: \[ z = \frac{(2 + i)(\lambda - i)}{(\lambda + i)(\lambda - i)} = \frac{2\lambda + 1 + i(\lambda - 2)}{\lambda^2 + 1} \]
Thus, the real part is \( \frac{2\lambda + 1}{\lambda^2 + 1} \) and the imaginary part is \( \frac{\lambda - 2}{\lambda^2 + 1} \).
For the complex number to lie on the line \( y = x \), the real part and imaginary part must be equal: \[ \frac{2\lambda + 1}{\lambda^2 + 1} = \frac{\lambda - 2}{\lambda^2 + 1} \] Cancel the denominator: \[ 2\lambda + 1 = \lambda - 2 \] Solve for \( \lambda \): \[ \lambda = -3 \] Thus, the value of \( \lambda \) is \( \boxed{-3} \).