I need a function with a specific shape:

  • Quadratic/gaussian concave shape ($-x^2$ like)
  • Centered in $\frac{1}{2}$ where it reaches the max value 1
  • On 0 and 1 to become null

I first tried using a second-degree polynomial function and I failed.
By repeated tries on graph.tk, after I deduced on paper that $c=0$, I got $-4x^2+4x$ to be what I need.

Then I found the function $e^{-x^2}$ which have a very nice shape.
But now I have to span it in $[-0.5, 0.5]$ and add an offset.
$e^{-(x-0.5)^2}$ is centered in $\frac{1}{2}$ where it reaches 1, but it does not descend down to zero in 0 and 1.

I'm interested in either the solution to this problem and in the process of reaching that solution. How is this usually done?

If Q above is unclear:

How do I model $e^{-x^2}$ to meet the requirements in bullets above?

  • $\begingroup$ do you want it to drop sharply at $0$ and $1$ (like the quadratic does) or do you want it to go smoothly (i.e slope goes to zero at these points)? And are piecewise definitions okay? $\endgroup$ – Robert Mastragostino Apr 18 '13 at 16:46
  • $\begingroup$ I guess a 4th degree polynomial would do the trick with the right coefficients (and the right $y$ offset to make it have only 2 roots : $0$ and $1$) $\endgroup$ – Dolma Apr 18 '13 at 16:48
  • $\begingroup$ @RobertMastragostino: I need it to reach 0 (any slope). I'd prefer it in one piece. $\endgroup$ – Iulius Curt Apr 18 '13 at 16:49
  • $\begingroup$ @Dolma: I added a more concise and clear question $\endgroup$ – Iulius Curt Apr 18 '13 at 16:53
  • 1
    $\begingroup$ I'm not sure what you mean by modelling $e^{-x^2}$, but you might try a function like $$f(x) = \exp\left(4-\frac{1}{x(1-x)}\right).$$ Here's a graph: wolframalpha.com/input/… $\endgroup$ – Abel Apr 18 '13 at 16:58

Well you're almost there. You have your nice function centered on $x=\frac{1}{2}$:


Now you can compute $f(0)$ and $f(1)$ which will be equal because $f$ is symmetric around $x=\frac{1}{2}$:

$$\large f(0)=f(1)=e^{-\frac{1}{4}}$$

If you want $f(0)=f(1)=0$ you just have to write:


But now for $x=\frac{1}{2}$, your function is equal to $\large1-e^{-\frac{1}{4}}$

Just multiply it by $\large\frac{1}{1-e^{-\frac{1}{4}}}$ and here you go:

$$\large f(x)=\frac{e^{-(x-\frac{1}{2})^2}-e^{-\frac{1}{4}}}{1-e^{-\frac{1}{4}}}$$

Here's the plot of this function:

enter image description here

  • $\begingroup$ Nice, thanks. It turned out to look an awful lot like the quadratic. :) $\endgroup$ – Iulius Curt Apr 18 '13 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.