# Logistic function as “difference of convex functions” (DC)

is there a way to express the logistic function $$\frac{1}{1+\exp(-x)}$$ as the difference of two convex functions?

Thanks

-
Can you provide some background for this question? Although your question is a good question, there is an aversion to questions in which no effort is shown. If you provide some background or, if this is a homework question, your work so far, your question may not be closed, or if it is closed, it may be able to be reopened. –  robjohn Feb 24 '14 at 10:49
To those who have voted to close: please let the author know why you have voted to close and what they can do to improve their question. If they are new to the site, they may not know about the close votes. –  robjohn Feb 24 '14 at 10:52

A convex function has an increasing derivative and we can write any function of bounded variation as a difference of two increasing functions. So let us look at the derivative \begin{align} \frac{\mathrm{d}}{\mathrm{d}x}\frac1{1+e^{-x}} &=\frac{e^{-x}}{(1+e^{-x})^2}\\ &=\frac1{(e^{x/2}+e^{-x/2})^2}\\ &=\tfrac14\,\mathrm{sech}^2(x/2) \end{align} Thus, we can break this up into the difference of two increasing functions: $$f'(x)=\left\{\begin{array}{l} \tfrac14&\text{when }x\ge0\\ \tfrac14\,\mathrm{sech}^2(x/2)\hphantom{-4}&\text{when }x\lt0 \end{array}\right.$$ and $$g'(x)=\left\{\begin{array}{l} \tfrac14-\tfrac14\,\mathrm{sech}^2(x/2)&\text{when }x\ge0\\ 0&\text{when }x\lt0 \end{array}\right.$$ Then if $$f(x)=\left\{\begin{array}{l} \tfrac14x+\tfrac12&\text{when }x\ge0\\ \tfrac12\tanh(x/2)+\tfrac12&\text{when }x\lt0 \end{array}\right.$$ and $$g(x)=\left\{\begin{array}{l} \tfrac14x-\tfrac12\tanh(x/2)&\text{when }x\ge0\\ 0&\text{when }x\lt0 \end{array}\right.$$ $f$ and $g$ are convex and $f(x)-g(x)=\frac12+\frac12\tanh(x/2)=\dfrac1{1+e^{-x}}$

-

$$\frac{d^2}{dx^2} (1+e^x)^{-1} = \frac{d}{dx} \left(-(1+e^x)^{-2}e^x\right) = e^x\left( -(1+e^x)^{-2}+2(1+e^x)^{-3}e^x \right)$$ $$= \frac{e^x (-(1+e^x)+2e^x)}{(1+e^x)^3} = \frac{ e^x(e^x-1) }{(1+e^x)^3}.$$ This is a bounded function because it is everywhere continuous and goes to $0$ as $x\to\pm\infty$.

So let $f(x) = Ax^2 + \dfrac{1}{1+e^x}$ with $A$ big enough so that the second derivative $f''$ is always positive. Then the logistic function is the difference between the convex function $f$ and the convex function $x\mapsto Ax^2$.

-
Thanks, but I meant if there was a "fundamental" way. Let me explain. For instance, consider $$g(x) \triangleq \frac{1}{t} (x)^+$$, where $t>0$ and $(\cdot)^+$ denotes the positive part. We have something similar to the logistic function by $g(x+\frac{t}{2})-g(x-\frac{t}{2})$. Is there a similar way to write the logistic (perhaps as difference of two exponential functions, just guessing)? Thanks –  Ita Atz Feb 23 '14 at 19:29
This certainly answers the question. Did you compute the minimum of $A$? –  robjohn Feb 24 '14 at 16:46

A different approach.

If $f$ is any function with continuous second derivative let $$f''_+=\max(f'',0)\quad f''_-=-\min(f'',0).$$ Then $f''_+$ and $f''_-$ are continuous, non-negative and $f''=f''_+-f''_-$. Now let $F_+$ and $F_-$ be such that $F_+''=f''_+$ and $F_-''=f''_-$. $F_+$ and $F_-$ are convex, and the constants of integration can be chosen so that $f=F_+-F_-$.

This is analogous to writing any $C^1$ function as the difference of two increasing functions.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 1, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.982925534248352, "perplexity": 169.1781699537447}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-35/segments/1440645167576.40/warc/CC-MAIN-20150827031247-00278-ip-10-171-96-226.ec2.internal.warc.gz"}