I am trying to solve the minimax problem that I posted below. If I set c1 to 1.0 NMinimize gives me a result as expected. If I however change it slightly, even by a miniscule amount I get error messages. One of those says that the function value is not a number at {a,b,r1} = {1.14946,0.984114,0.0875131}. If I plug these values into the max function manually though, I get a result. In other error messages it complains that the comparison of some numbers is invalid and shows values containing complex numbers and minus infinity, but I don't know how it is getting these numbers. I don't know if NMinimize generates its result differently as it would be if I just test varying parameters manually, but I cannot get it to work correctly. So why does NMinimize not work if I set c1 to a value different than 1?
ClearAll["Global`*"] r[a_, b_, u_] := {a Cos[u], b Sin[u]} chord[c_, u1_, u2_] := EuclideanDistance[r[c, 1, u1], r[c, 1, u2]] rad2D[width_, rad_] := ArcLength[r[width, 1, u], {u, 0, rad}] arc[width_, rad1_, rad2_] := ArcLength[r[width, 1, u], {u, rad1, rad2}] edge[width_, u_] := EuclideanDistance[{0, 0}, r[width, 1, u]] E0r[a_, b_, c_, r_] := edge[c, r] + arc[c, a - b + r, Pi + r] + chord[c, a - b + r, a + r] E1r[a_, b_, c_, r_] := edge[c, r] + arc[c, a + r, Pi + r] + chord[c, a + r, -a + r] E2r[a_, b_, c_, r_] := edge[c, r] + arc[c, a + r, Pi + r] + chord[c, a - b + r, a + r] + SP[a, b, c, r] + chord[c, a - b + r, a - b + SP[a, b, c, r] + r] equation[a_, b_, c_, r_, g_] := arc[c, -a + b + r, a + r] - (chord[c, -a + r, b - a + r] + arc[c, b - a - g + r, b - a + r]) SP[a_?NumericQ, b_?NumericQ, c_, r_?NumericQ] := p /. FindRoot[equation[a, b, c, r, p], {p, a - b}, Evaluated -> False] c1 := 1.1 NMinimize[{Max[E0r[a, b, c1, r1], E1r[a, b, c1, r1], E2r[a, b, c1, r1]], a > Pi/3 && Cos[a] + Cos[a - b/2] > 1}, {{a, 1.1, 1.2}, {b, 0.9, 1.0}, {r1, 0.0, Pi/2}}]
ContourPlot[E2r[a, b, 1, 1], {a, Pi/3, 4 Pi}, {b, -2 Pi, 2 Pi}]. You can save some time by not repeatedly computing arclength, but just doing it once:arcSymbolic = Simplify[ ArcLength[ {width Cos[u], Sin[u]}, {u, 0, rad}], Assumptions -> width > 0]and thenarclength = Function[{width,rad},Evaluate[arcSymbolic]]and thenarclength[1,2]will be much faster. $\endgroup$a -> semiAxis1etc. Not that it matters, but it is just helpful $\endgroup$RegionPlot[ a > Pi/3 && Cos[a] + Cos[a - b/2] > 1, {a, Pi/3, 4 Pi}, {b, -2 Pi, 2 Pi}]to be visually helpful. $\endgroup${{a, 1.1, 1.2}, {b, 0.9, 1.0}, {r1, 0.0, Pi/2} }in the documentation. What are you trying to do here? Give it initial values (if so, see Method) or give a constraint? $\endgroup$