Find x that minimises F(x,g(x))

112 Views Asked by At

I am trying to formulate an optimisation problem (which I think I have done correctly) but am struggling in solving it when substituting in a sample function, which leads me to think that maybe the formulation is incorrect, so would like to see where my error(s) were made. Assuming the formulation is correct, is there an analytical solution?

Consider some function $$F = f(x,g(x))$$ where we wish to find the minimum.

Taking: $$F'(x) = \frac{\partial{f}}{\partial{x}} + \frac{\partial{f}}{\partial{g}} \frac{\partial{g}}{\partial{x}} = 0$$

We should be able to solve for $x$.

Now consider $$f(x,g(x)) = x-xg(x) - x g(x)^2$$ $$g(x) = \Phi(x) = {\frac {1}{\sqrt {2\pi }}}\int _{-\infty }^{x}e^{-t^{2}/2}\,dt$$ where $\Phi(x)$ is the cdf of a Normal distribution (although any cdf should work).

Attempting to calculate the partial derivatives and substituting into the above gives:

$$F'(x) = 1-g-g^2 + \left( -x(1+2g)\cdot \frac{1}{\sqrt{2\pi}} e^{-x^2/2} \right) = 0$$

where I've dropped $(x)$ from the notation for simplicity.

Assuming this is correct then I have a formula still in terms of both $x$ and $g(x)$, and no easy substitution given $g(x)$ is an integral. Is my approach totally wrong here, or is this equation more solvable than it looks?

2

There are 2 best solutions below

2
On BEST ANSWER

$$g(x) = \Phi(x) = {\frac {1}{\sqrt {2\pi }}}\int _{-\infty }^{x}e^{-t^{2}/2}\,dt=\frac{1}{2} \left(\text{erf}\left(\frac{x}{\sqrt{2}}\right)+1\right)$$ $$f(x,g(x)) = x(1-g(x)-g(x)^2)=-\frac{1}{4} x \left(\text{erf}\left(\frac{x}{\sqrt{2}}\right) \left(\text{erf}\left(\frac{x}{\sqrt{2}}\right)+4\right)-1\right)$$ $$f'(x,g(x))= \frac{e^{-\frac{x^2}{2}} x \left(\text{erfc}\left(\frac{x}{\sqrt{2}}\right)-3\right)}{\sqrt{2 \pi }}+\frac{1}{4} \left(-\left(\text{erfc}\left(\frac{x}{\sqrt{2}}\right)-6\right) \text{erfc}\left(\frac{x}{\sqrt{2}}\right)-4\right)$$ $$f''(x,g(x))= \frac{e^{-\frac{x^2}{2}} \left(x^2-2\right) \left(\text{erf}\left(\frac{x}{\sqrt{2}}\right)+2\right)}{\sqrt{2 \pi }}-\frac{e^{-x^2} x}{\pi }$$

Starting with $x_0$, Newton methods solves pretty fast $f'(x,g(x))=0$ : $$\left( \begin{array}{cc} n & x_n \\ 0 & 0 \\ 1 & 0.15666426716443753140 \\ 2 & 0.15106897311919179609 \\ 3 & 0.15106533761909824900 \\ 4 & 0.15106533761750598442 \end{array} \right)$$ At this point, $f''(x,g(x))$ is negative $(\approx -1.7003)$; so, this point is a maximum of $f(x,g(x))$.

So, the maximum of $f(x,g(x))$ is $\sim 0.0190825$.

Edit

If we plot $f(x,g(x))$ and notice that the maximum is close to $x=0$, we could avoid all these calculations building its Taylor expansion around $x=0$.

$$f(x,g(x))=\frac{x}{4}-\sqrt{\frac{2}{\pi }} x^2-\frac{x^3}{2 \pi }+O\left(x^4\right)$$ This would give the maximum $$x_*=\frac{\sqrt{19}-4}{3} \sqrt{\frac{\pi }{2}}\approx 0.149938 \quad \text{and} \quad f(x_*,g(x_*))=\frac{19 \sqrt{19}-82}{54} \sqrt{\frac{\pi }{2}}\approx 0.0190105 $$ which is quite decent.

Similarly, for more accuracy, we could use one more term for the expansion $$f(x,g(x))=\frac{x}{4}-\sqrt{\frac{2}{\pi }} x^2-\frac{x^3}{2 \pi }+\frac{x^4}{3 \sqrt{2 \pi}}+O\left(x^5\right)$$ and build the $[1,2]$ Padé approximant of $f'(x,g(x))$. This would give $$x_*=\frac{201 }{4 (420-\pi)}\sqrt{\frac{\pi }{2}}\approx 0.151080$$ $$ f(x_*,g(x_*))=\frac{201 }{1024 (420-\pi)^4}\sqrt{\frac{\pi }{2}}\left(-2404548720+20194569 \pi -67776 \pi ^2+64 \pi ^3\right)$$ which is $\approx 0.0190786$.

0
On

I haven't solved it yet but figured that the function is reasonably inspectable via plotting in this case. Some simple python code allows us to visually identify where the minimum should be, although from the answers so far no analytical solution appears forthcoming:

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm

g = norm.cdf
x = np.linspace(-1,1)

# Objective func to maximise:
f = x*(1 - g(x) - (g(x))**2)
# Cost func to minimise:
L = -f

plt.plot(x,L)
plt.grid()

From this, the minimum appears to be around 0.015. The plot produced by the above code