Start with the given equation:
\(\frac{\tan x + \cos x}{\tan x - \cos x} = k\)
Multiply both sides by \(\tan x - \cos x\):
\(\tan x + \cos x = k(\tan x - \cos x)\)
Substitute \(\tan x = \frac{\sin x}{\cos x}\):
\(\frac{\sin x}{\cos x} + \cos x = k \left( \frac{\sin x}{\cos x} - \cos x \right)\)
Clear the fraction by multiplying through by \(\cos x\):
\(\sin x + \cos^2 x = k(\sin x - \cos^2 x)\)
Use \(\cos^2 x = 1 - \sin^2 x\):
\(\sin x + 1 - \sin^2 x = k(\sin x - (1 - \sin^2 x))\)
Simplify the equation:
\(\sin x + 1 - \sin^2 x = k \sin x - k + k \sin^2 x\)
Rearrange terms to gather like terms on one side:
\(k \sin^2 x + \sin^2 x + k \sin x - \sin x - k - 1 = 0\)
Combine like terms:
\((k+1) \sin^2 x + (k-1) \sin x - (k+1) = 0\)
This matches the required expression.