If \( y = x + \frac{1}{x} \), then transform the equation \( x^4 + x^3 - 4x^2 + x + 1 = 0 \) into the form \( x^2(y^2 + y - k) = 0 \). What is the value of \( k \)?

Let's think step by step and output the final answer within \boxed{}.
user