f(x) = 3 + x^2 + tan(pi(x/2)) , -1 < x < 1

I found the inverse and it was:

3 + y^2 + tan(pi(y/2)), -1 < y < 1

Correct me if I was wrong.

Then the question asks me to find f(f^-1(5))

And here's what I did.

f^-1 (5) = 5 = 3 + y^2 + tan(pi(y/2))

2 = y^2 + tan(pi(y/2))

f^-1 (5) = 1

f (f^-1 (5)) = f(1) = 3 + (1)^2 + tan(pi(1/2))

= 3 + 1 + 1

= 5

But the domain clearly states that x has to be between -1 and 1. What am I doing wrong?