# FindMaximum error (not a real number)

For the code below, I get several error messages once I click the "Enable Dynamics" button. However, once I run the code, the output works fine, so, if that is all I wished to do, I would just live with the error. The problem is that I cannot get it to work fine when I save the output as a .cdf file, which I would like to do. So, I assume the ideal solution is to somehow get rid of the error messages altogether.

I have searched through this website and found a few answers to errors associated with FindMaximum, but the solutions are too complicated for my extremely minimal knowledge with Mathematica. If somebody knows a solution, I would be grateful.

Here is the code:

    c = 1;
Manipulate[
max1 = x /.
Last[FindMaximum[{(0.8 + x/(0.1 + (0.8*x))) - (0.8 + (c*x)),
0 <= x <= 1.6}, {x, 0}]];
max2 = x /.
Last[FindMaximum[{(0.8 + x/(0.1 + (A*x))) - (0.8 + (c*x)),
0 <= x <= 1.6}, {x, 0}]];
Labeled[Show[{Plot[{{0.8 + x/(0.1 + (0.8*x))}, {0.8 +
x/(0.1 + (A*x))}, {0.8 + (c*x)}}, {x, 0, 1.6},
PlotRange -> {0, 2.4}, AspectRatio -> 1.50,
Ticks -> {{{max1,
"E", {(0.8 + (max1)/(0.1 + (0.8*(max1))))/1.6, 0}}, {max1,
"E", {(0.8 + (max1)/(0.1 + (A*(max1))))/1.6, 0}}, {max2,
"R", {(0.8 + (max2)/(0.1 + (A*(max2))))/1.6,
0}}}, {{(0.8 + (max1)/(0.1 + (0.8*(max1)))),
"E", {(max1)/1.7, 0}}, {(0.8 + (max1)/(0.1 + (A*(max1)))),
"A", {(max1)/1.7, 0}}, {(0.8 + (max2)/(0.1 + (A*(max2)))),
"R", {(max2)/1.7, 0}}, {0.8, "     ", {1, 0.02}}}}],
Plot[{{(x/(0.1 + (0.8*x))) - (c*x)}, {(x/(0.1 + (A*x))) - (c*
x)}}, {x, 0, 1.6}, PlotRange -> {0, 2.4},
AspectRatio ->
1.5]}], {"Benefit-Cost              Benefit or Cost    ",
"Effort"}, {Left, Bottom},
RotateLabel ->
True], "ENVIRONMENTAL FEEDBACK MODEL\n\nNATURAL SITUATION\n\nGreen \
Line: Cost function\n\nBlue Line: Expected benefit (top) or net \
benefit (bottom) function\n\nRed Line: Actual benefit (top) or net \
benefit (bottom) function\n\nR: Response to feedback\n", {{A, 1.2,
"A: Actual"}, 1.2, 0.6}]

• Have you tried to isolate a minimal example? At least the error messages should be shown in the question. – Szabolcs Oct 21 '19 at 18:35
• I couldn't get the error. your code works perfectly. – Xminer Oct 21 '19 at 21:52
• Szabolcs, as neither a mathematician nor an expert in Mathematica, I do not understand what you mean by "isolate a minimal example." As for the error message, there are often several, but here is a copy of the first: "FindMaximum::nrnum: The function value 0. +0.00999999 c-0.00999999/(0.1 +0.00999999 E) is not a real number at {x} = {0.00999999}." – kwsockman Oct 22 '19 at 17:03
• Xminer, that's interesting. I just updated my version of Mathematica to the latest, and I still get the error. Are you able to generate a functional CDF version? – kwsockman Oct 22 '19 at 17:06