# Minimization of a function including quadratic and exponential terms

Apologies for the simple question. Is it possible to analytically minimize a function such as

$$f(x) = a^x + c x (x-1) \qquad x > 0, \quad 0 < a,c < 1$$

Nothing else can be said about the constants $a$ or $c$.

-
Mathematica says that the Lambert function is involved here, but considering your range of validity for a and c (can they be negative, for instance?), I'm still verifying the solution I got. – J. M. Sep 15 '10 at 15:10
That's a good point, I'm most interested in cases where a and c are positive. – user1910 Sep 15 '10 at 15:21
@J.M.: If c is negative, f is unbounded below; if a is negative, f is not everywhere real-valued. So your solution should be ok. Its nature draws our attention to the interesting part of this question: exactly what should be considered an "analytical" solution? – whuber Sep 15 '10 at 15:27
whuber: I carried the analysis through, and you are of course correct. :) – J. M. Sep 15 '10 at 15:47

Alright, here's my expansion of my comment.

Let's rearrange the equation in VFG's answer like so:

$$\frac{\ln\;a}{2c}=\left(\frac12-x\right)a^{-x}$$

and multiply both sides by $\sqrt{a}$:

$$\frac{\sqrt{a}\ln\;a}{2c}=\left(\frac12-x\right)a^{\frac12-x}$$

We're close to a form where we can now use the Lambert function, but let's change bases first:

$$\frac{\sqrt{a}\ln\;a}{2c}=\left(\frac12-x\right)\exp\left(\frac{\ln\;a}{2}-x\ln\;a\right)$$

We're much closer now, so we multiply both sides by a factor of $\ln\;a$

$$\frac{\sqrt{a}(\ln\;a)^2}{2c}=\left(\frac{\ln\;a}{2}-x\ln\;a\right)\exp\left(\frac{\ln\;a}{2}-x\ln\;a\right)$$

and then perform the inversion:

$$W\left(\frac{\sqrt{a}(\ln\;a)^2}{2c}\right)=\frac{\ln\;a}{2}-x\ln\;a$$

which is now easily solved for $x$:

$$x=\frac12-\frac1{\ln\;a}W\left(\frac{\sqrt{a}(\ln\;a)^2}{2c}\right)$$

Now, the Lambert function has two real branches $W(z)$ (principal branch) and $W_{-1}(z)$; one is real for $z\geq-e^{-1}$, and the other is real only in the interval $[-e^{-1},0)$. If both $a$ and $c$ are in the interval $(0,1)$, the argument of the Lambert function would be much greater than 1, and thus we can dispose of the $W_{-1}$ branch, as well as consider $W(z)$ only for $z\geq 0$, which is true for $a$ and $c$ in the interval $(0,1)$. Thus, the Lambert solution using the principal branch is valid.

-
Having derived the beastie, I would say that for numerical work, you're probably still better off using Newton-Raphson directly on the derivative of the objective function instead of using the solution I gave. – J. M. Sep 15 '10 at 16:17

I think there is no analytical solution to $f^{\prime }(x)=0$

$f^{\prime }(x)=2cx-c+\left( \ln a\right) a^{x}$.

Update: I mean no solution in elementary functions.

-