1

I have two hypothetical graphs for which I am trying to get a mathematical function. Are there some suggestions for what mathematical function I can use? I can use piecewise functions.

enter image description here

For this graph, I am using some version of $Exp[-x]$. However, I am not being able to get the zero slope at X =1. Nor am I getting Y = 0 at X =1.

enter image description here

For the second graph, I have tried using the hyperbolic tan function but have not succeeded.

Edit

From reading the comments I understood that it is difficult to get a function which exactly fits my graph. Are there some functions where the slope can be approximately equal to what I am seeking?

  • 3
    If I understand correctly, for the first function you want $\frac{dy}{dx}$ to be $-1$ at $(0,1)$ and then slowly increase to $0$ as it approaches $(1,0)$. The problem is that this is impossible- the graph just isn’t steep enough to get to $(1,0)$. I did try and get a similar shape, but it doesn’t match the derivatives you want exactly. Here’s a picture of the graph + it’s function – Snacc Sep 01 '21 at 13:08
  • 2
    For the first one, how about $y=1-x-x^2+x^3$ for $0\le x\le1$, $y=0$ for $x\ge1$? – Gerry Myerson Sep 01 '21 at 13:41
  • @Snacc this looks perfect for the first graph. I see that it is difficult to get a function that can satisfy my criteria. – Brownian_Motion Sep 01 '21 at 14:32
  • @Gary a polynomial was what I thought too initially, but that looks good. Let me try that in my problem. – Brownian_Motion Sep 01 '21 at 14:32

1 Answers1

1

What you typically do in these situations is create precisely what you need and then develop it from there. For the first one we use signum or sign function $\operatorname{sgn}(x)$ stationed at $1$. I will explain what I am doing so it is clear.

You need $-x+1$ up to $1$ and then on $y=0$.

Notice that $$\frac{1}{2}(1 \pm \operatorname{sgn}(x))$$ is cutting off left or right side depending on the sign in $1\pm$. We need right side gone after $1$. First we need $\frac{1}{2}(1 - \operatorname{sgn}(x))$ and then we need to shift it by $1$ or

$$\frac{1}{2}(1 - \operatorname{sgn}(x-1))$$

All together the function is

$$f(x)=\frac{1}{2}(1 - \operatorname{sgn}(x-1))(1-x)$$

Now comes the part where you want to have $f'(x)=0$ at $1$. But this is somewhat tricky because if that is the first extreme value, then you have to have another one before reaching $0$ back again. So I have to assume that you need a small positive min at $1$.

Before that if you want a smoother version of $\operatorname{sgn}(x)$ you have quite some options like $\operatorname{sgn}(x)=\frac{x}{\sqrt{x^2+\epsilon}}$ for some small $\epsilon$.

Technically speaking your desired function is this one:

$$f(x)=\lim_{\epsilon \to 0} \frac{1}{2}(1 - \frac{x-1}{\sqrt{(x-1)^2+\epsilon}})(1-x)$$

without that minimum at $1$. You can stay with this one if you want.

Now for the minimum you need a function that is $1$ everywhere except at $0$ where it is $0$. That would be ideal, since we can shift it to $1$ and there we go. Similar to $\operatorname{sgn}(x)$, we could construct such a function, but let us start from something that looks like that. Now a lot of functions can be used instead but this is probably the simplest possible form

$$g(x)=\frac{x^2}{x^2+1}$$

Clear, this function is $0$ at $0$ and somewhere in its vicinity it becomes $1$. If you add $k \gg 1$ it will become as squeezed as you like around $0$.

$$g_k(x)=\frac{kx^2}{kx^2+1}$$

Do not forget that we need it shifted so now the complete function is

$$f_k(x)=\frac{1}{2}(1 - \operatorname{sgn}(x-1))(1-x)\frac{k(x-1)^2}{k(x-1)^2+1}$$

What is nice about this function is that it is smooth regardless of $\operatorname{sgn}(x)$.

Of course, this is a family of functions, but this is because you cannot have $f'(x)=0$ after some point indefinitely and function to be smooth and not constant. So constant $k$ is compensating, it will create a small bump around $1$ which you can regulate.

Notice that your function is $\lim\limits_{k \to \infty} f_k(x)$

Now comes the second function. Well you should be able to do it yourself by now, right?

First part is quite clear

$$f(x)=\frac{1}{2}(1 - \operatorname{sgn}(x-1))(1-\frac{1}{2}x)$$

You need a cut at $1$ and the slope is $-0.5$.

The rest is then the same as above, so in total the change is miniscule:

$$f_k(x)=\frac{1}{2}(1 - \operatorname{sgn}(x-1))(1-\frac1{2}x)\frac{k(x-1)^2}{k(x-1)^2+1}$$