Maximize function involving $\textrm{erf}(\cdot)$

217 Views Asked by At

I want to maximize the following function in $x$ subject to $0<x<\sqrt{2}$: $$f(x) = \frac{x^2}{2}\left[1 - \textrm{erf}\left(\frac{cx^2}{\sqrt{2}}\right)\right],$$ where $c$ is a constant. Is there someway i can obtain an explicit or approximate solution to the problem in terms of $c$. I know that $\textrm{erf()}$ is not a convex function, so i don't know what to do in this case.

2

There are 2 best solutions below

0
On BEST ANSWER

This is a non-convex (and non-concave) optimization problem, for which I think the only reliable way of getting a solution fr positive $c$ is by applying a "rigorous" global optimization solver, such as a branch and bound solver, to numerically perform the optimization.

Here is a program in YALMIP, using its BMIBNB global optimizer, and using default optimality gap tolerance (which could be tightened) and the results for integer values of c from -3 to 50. The columns are $c$, optimal x, maximum f(x)

for c=-3:50
  x=sdpvar;
  Obj=x^2/2*(1-erf(c*x^2/sqrt(2))); 
  optimize(0<=x<=sqrt(2),-Obj,sdpsettings('solver','bmibnb','verbose',0)); 
  disp([c value(x) value(Obj)])
end

  -3.000000000000000   1.414213279530439   1.999999198027036
  -2.000000000000000   1.414212148864674   1.999932657499150
  -1.000000000000000   1.414213301744288   1.954498936103806
                   0   1.414213562373095   1.000000000000000
   1.000000000000000   0.867059142975441   0.169971207479903
   2.000000000000000   0.613103429828933   0.084985603739951
   3.000000000000000   0.500596885362942   0.056657069159965
   4.000000000000000   0.433529645616029   0.042492801869971
   5.000000000000000   0.387760726093716   0.033994241495975
   6.000000000000000   0.353975515355711   0.028328534579976
   7.000000000000000   0.327717666322975   0.024281601068548
   8.000000000000000   0.306551884044641   0.021246400934964
   9.000000000000000   0.289022540669026   0.018885689714784
  10.000000000000000   0.274191185122473   0.016997120742092
  11.000000000000000   0.261431349745961   0.015451927946127
  12.000000000000000   0.250301760512696   0.014164267282706
  13.000000000000000   0.240482440814156   0.013074708259702
  14.000000000000000   0.231734956159698   0.012140800525598
  15.000000000000000   0.223877505563722   0.011331413822613
  16.000000000000000   0.216768722902053   0.010623200457413
  17.000000000000000   0.210296803436546   0.009998306311564
  18.000000000000000   0.204372003123553   0.009442844848508
  19.000000000000000   0.198921302275294   0.008945853013279
  20.000000000000000   0.193884772553261   0.008498560361099
  21.000000000000000   0.189212391598071   0.008093867009250
  22.000000000000000   0.184862315924978   0.007725963962091
  23.000000000000000   0.180799133705201   0.007390052484125
  24.000000000000000   0.176992623454012   0.007082133629286
  25.000000000000000   0.173416854904914   0.006798848282781
  26.000000000000000   0.170049415549653   0.006537354116760
  27.000000000000000   0.166870841765926   0.006295229888879
  28.000000000000000   0.163864081217455   0.006070400248855
  29.000000000000000   0.161014276311922   0.005861076100803
  30.000000000000000   0.158308151504580   0.005665706896100
  31.000000000000000   0.155734050840069   0.005482942156170
  32.000000000000000   0.153281577031039   0.005311600212442
  33.000000000000000   0.150941306558982   0.005150642629926
  34.000000000000000   0.148705329731572   0.004999153138461
  35.000000000000000   0.146565749246576   0.004856320190295
  36.000000000000000   0.144515951270381   0.004721422405878
  37.000000000000000   0.142549827445021   0.004593816393553
  38.000000000000000   0.140661835789860   0.004472926487103
  39.000000000000000   0.138846945426578   0.004358236062914
  40.000000000000000   0.137100541299260   0.004249280159953
  41.000000000000000   0.135418421333310   0.004145639179110
  42.000000000000000   0.133796753606340   0.004046933482941
  43.000000000000000   0.132231975304239   0.003952818749491
  44.000000000000000   0.130720857494969   0.003862981958388
  45.000000000000000   0.129260417037842   0.003777137913339
  46.000000000000000   0.127847847435310   0.003695026218188
  47.000000000000000   0.126480605044799   0.003616408637691
  48.000000000000000   0.125156315554814   0.003541066789692
  49.000000000000000   0.123872778099728   0.003468800119121
  50.000000000000000   0.122627942825427   0.003399424115350

As can be seen, for any $c \le 0$, the optimal value of $x = \sqrt{2}$. That is because, in that case, both $x^2/2$ and $(1-\text{erf}(cx^2/\sqrt{2}))$ are individually maximized and nonnegative at $x = \sqrt{2}$, and therefore their product must be maximized at $x = \sqrt{2}$.

0
On

$\newcommand{gae}[1]{\newcommand{#1}{\operatorname{#1}}}\gae{maximize}\gae{erf}\newcommand{subj}{\text{subject to}}\gae{erfc}$I'll call $\erfc(x)=1-\erf(x)$ to save notation length. If $c=0$, the maximum is clearly $1$. I agree with user MarkL.Stone that you should work with $0\le x\le \sqrt2$. If $c\ne0$, make the substitution $t=\frac{\lvert c\rvert x^2}{\sqrt 2}$, so that your original problem $(A_c)$ becomes equivalent to:

  • if $c>0$, \begin{align}\maximize&\quad \frac{t}{\lvert c\rvert\sqrt2}\erfc (t)&(B_c)\\\subj&\quad0\le t\le \lvert c\rvert\sqrt2\end{align}

  • if $c<0$, \begin{align}\maximize&\quad \frac{t}{\lvert c\rvert\sqrt2}\erfc (-t)&(D_c)\\\subj&\quad0\le t\le \lvert c\rvert\sqrt2\end{align}

Now, $(D_c)$ is easy to evaluate because $t\erfc(-t)$ is increasing on $[0,\infty)$ and therefore the maximum is for $t=\lvert c\rvert\sqrt2$. Hence the solution is $\erfc(-\lvert c\rvert\sqrt2)=\erfc(c\sqrt2)$.

$(B_c)$ is essentially an evaluation of what and where the maximum of $t\erfc( t)$ on $[0,\infty)$ is, and whether or not it is in the interval $[0,\lvert c\rvert\sqrt2]$. It turns out that the maximum of $t\erfc( t)$ is at $t=\alpha\approx 0.531597$ and that the value is $L=\alpha\erfc(\alpha)\approx 0.240376$: however, given the fact that $t\erfc( t)$ is $0$ in $t=0$, it increases for a while and then it decreases to $0$, approximating $\alpha$ and $L$ should not be a challenge. The bottom line is that the solution to $(B_c)$ ends up being $\erfc(c\sqrt 2)$ if $0<c\le\frac\alpha{\sqrt2}$, and $\frac{L}{c\sqrt2}$ if $c>\frac\alpha{\sqrt2}$.

Putting it all together the "exact" solution to $(A_c)$ is:

  • $\erfc\left(c\sqrt 2\right)$ if $c\le\frac\alpha{\sqrt2}$; this maximum is attained at $x=\sqrt2$.

  • $\frac{L}{c\sqrt2}$ if $c>\frac\alpha{\sqrt2}$; this maximum is attained at $x=\sqrt{\frac{\sqrt2\alpha}{c}}$.

Where $\alpha=\operatorname{argmax}_{x\ge0} x\erfc (x)$ and $L=\max_{x\ge 0}x\erfc (x)$.