# Why can't Mathematica solve this equation numerically? [closed]

I have a rather nasty-looking function Ratio, given by,

f[n_, t_] =
Assuming[Element[n, Integers] && n > 0 && 0 < t < Pi/2,
Integrate[Cos[x]^n, {x, Pi/2 - t, Pi/2}]];
cn[n_] = Pi^(n/2)/Gamma[n/2 + 1];
g[n_, t_] = cn[n - 1]*(Sin[(t)]^(n - 1)*Cos[(t)]/n + f[n, t]);
Ratio[n_, t_] = FullSimplify[g[n^2, t]/cn[n^2]]


Given values p_n that fall in the range from $0$ to $1/4$, I wish to solve Ratio[n,t]==p_n for values of t in the range from $0$ to $\pi/2$.

But when I run

Assuming[0 < t < Pi/2, NSolve[Ratio[2, t] == 0.250277, t, Reals]]


Mathematica doesn't seem to ever arrive at an answer. The Ratio-function looks normal enough and there should exist solutions in the given intervals:

What goes wrong? Thanks.

## closed as off-topic by march, MarcoB, m_goldberg, corey979, bbgodfreyJan 4 '17 at 1:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – march, MarcoB, m_goldberg, corey979, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

• Try FindRoot instead. NSolve is mainly for polynomial equations and equations involving some small number of elementary functions. – march Jan 3 '17 at 21:10
• @march Thanks, that worked beautifully! If you post this as an answer, I will accept it. Or should I delete this question (as it is probably a duplicate)? – Bobson Dugnutt Jan 3 '17 at 21:20

You need to tell NSolve about the bounds explicitly:
NSolve[Ratio[2, t] == 0.250277 && 0 < t < Pi/2, t, Reals]

• @Lovsovs: See under "Details" in the NSolve documentation for the kinds of things you can put there; there are a lot of possibilities. – Rahul Jan 3 '17 at 23:26