# NSolve cannot work with MinValue?

I am trying to solve the following problem: find the smallest value of $$b$$ such that the inverse of the solution u[p] given by NDSolveValue is never less than 1.

f[b_, v_] := NDSolveValue[{u''[p] + u[p] == 1/(2*(b*v)^2) + 3/2*u[p]^2,
u[0] == 0, u'[0] == 0}, u, {p, 0.1, 10}];


To do this for a given value of v, here 0.2, I have written the following code

g[q_] := MinValue[{(1/f[q, 0.2][p]), 10 > p > 0.1}, p];
NSolve[g[q] == 1, q]


The function g[q] seems to work fine, g[15] returns a number (about 7.8), but NSolve gives the following errors:

How can I take care of these?

Try

NMinimize[{q, g[q] >= 1, 5 < q < 15}, q, AccuracyGoal -> 3]
(* {9.95406, {q -> 9.95406}} *)


Here an alternativ workaround:

Normal[Plot[g[q], {q, 0, 20}, MaxRecursion -> 3,MeshFunctions -> {#2 &}, Mesh -> {{1}},MeshStyle -> {PointSize[Large]}]] /.Point[x_] :> {Point[x], Text[Style[x, 14]], Offset[{-20, 10}, x]}


• Do you also get a slew of "not a number" and "stiff system expected" errors before Mathematica gives you this plot? Copying your code I indeed get this plot but all the errors that come before the output would make me suspicious. Same for the NMinimize approach, code is taking forever to evaluate and generates lots of errors before giving output. Commented Dec 5, 2018 at 10:12
• No I get no errors (version 11.0.1. Windows 64). The calculation NMInimize lasts some time... Commented Dec 5, 2018 at 10:16
• Note that g is only meaningfully defined if q is given a value, so restrict it via g[q_?NumericQ] := MinValue[{(1/f[q, 0.2][p]), 10 > p > 0.1}, p] Then FindRoot[g[q] == 1, {q, 10}] gives a root. Commented Dec 5, 2018 at 10:46