I have a function which includes finding roots of an equation. the coeffs of the equation are the inputs of the function and have to be numerical before calling. NMaximize passes symbolic input into the fucntion first and causes problems and errors.
functio[a1_, b1_] :=
Max[
Abs[
x /.
{ToRules[NRoots[x^3 - a*x^2 + b*x - 1 == 0 //. {a :> a1, b :> b1}, x]]}]];
sol1 =
NMaximize[{functio[a, b], a >= 0, a <= 1, b >= 0, b <= 1}, {a, b}][[1 ;; 2]]
Error message
-1+b\ x-a\ x^2+x^3==0 is expected to be a polynomial equation in the variable x with numeric coefficients."
Does anyone know how to avoid that error.
