I have the following Mathematica code (Mathematica version 9):
DH[x_] := (0.399582 Exp[-0.501606 (-3.57699 + Log[x])^2])/x
F[n1_, n2_] := Integrate[DH[x], {x, n1, n2}];
G[n_] := Integrate[DH[x], {x, 0, n - 1}];
Cp[n1_, n2_] := Piecewise[{{F[n1, n2]*Log2[n1], n1 < n2},
{0, n1 >= n2}}];
Et[n1_, n2_] := Piecewise[{{-F[n1, n2]*Log2[F[n1, n2]], n1 < n2 },
{0, n1 >= n2}}];
H[n1_, n2_] := Piecewise[{{Cp[n1, n2] + Cp[n2, 233]- Et[n1, n2]-Et[n2, 233]-G[n1], n1 < n2},
{0, n1 >= n2}}];
I want to maximize value of H[n1,n2]
and I use the Maximize
function:
Maximize[{H[n1, n2],2<=n1<=231 && 3<=n2<=232 && n1 < n2}, {n1, n2}, Reals]
After I run the program, I obtained the solution: {2.64505, {n1 -> 11.6199, n2 -> 232.}}
and many error messages. How obtain the maximum?
DH
,Cp
,Et
in the critical cases), but you risk conflicting with built-in symbols, such asD
,C
etc.) $\endgroup$DH
definition. Please ensure your code runs properly as copied and pasted from the site. AsDH
is using reals, you might as well switch over toNMaximize
directly (Maximize
does it for you already). $\endgroup$