# I'm looking for a function that is continuous and monotone increasing between a and b and maps to the entire real line.

After some trial-and-error I've got this:

$$f(x;a,b)=\textrm{arctanh}\left( 2\frac{x-a}{b-a}-1 \right)$$

Illustrated here on WolframAlpha: arctanh((2*((x-a)/(b-a))-1)) where a=2 and b=12

It kind of does what I wanted, but I wonder if there are any functions like this that doesn't use trigonometric functions. Maybe something like an inverse general sigmoid function. I haven't been able to come up with anything like that.

• $\operatorname{artanh} x = \frac12\log_e\frac{1+x}{1-x}$ is a logarithmic function rather than a trigonometric function. Using $\operatorname{arctan}$ instead would be trigonometric Aug 8, 2023 at 10:22
• @Henry Thanks. Yes, it seems I was confused. I generally use sigmoid functions (0 to 1) as activation functions when I manually play around with neural networks, and just always assumed the cousin tanh (-1 to 1) was the trigonometric tan function. TIL. Aug 9, 2023 at 20:39
• Of course the actual tangent function can do that too: $\textrm{tan}(\pi\frac{x-a}{b-a}-\frac{\pi}{2})$ - this is what you didn't want. Sep 12, 2023 at 17:11

$$\frac1 {a-x}+\frac 1 {b-x}$$ is continuous and increasing on $$(a,b)$$ and its range is $$(-\infty, \infty)$$.

The derivative is $$\frac 1 {(a-x)^{2}}+\frac 1 {(b-x)^{2}} >0$$.

• @AndréChristofferAndersen the function geetha290km proposed, has $a-x$ in the first denominatior. Check this out: wolframalpha.com/… Aug 7, 2023 at 7:51
• @VeselinDimov Yes. Thanks. I noticed, and I tried to delete my comment in time, but you were too fast. I had a typo when I tested it out. This is a beautifully simple solution. Aug 7, 2023 at 7:54

Here's another one $$\ln \left( \left| \frac{x-a}{b-x} \right| \right)$$

• That was a cool one too. Here is the plot: wolframalpha.com/… Aug 7, 2023 at 7:57

Let us follow your suggestion of finding something like an inverse general sigmoid function.

Start with the sigmoid expression $$\frac{1}{1+e^{-y}}$$.

We can scale the expression by $$b-a$$, and add $$a$$ to get an expression whose values lie in $$(a,b)$$. Then we can solve the equation

$$x = a+\frac{b-a}{1+e^{-y}}$$

for $$y$$ to find an expression for the inverse function. This gives us the expression

$$y = -\ln(\frac{b-a}{x-a}-1) = \ln(\frac{x-a}{b-x})$$,

which is the same answer as Tony Mathew gave.

• Interesting, you don't actually need to take the absolute. What I like about it, is that I am very familiar with manipulating sigmoid functions. I played around with doing what you did with the full generalized logistic function on Wikipedia and got this: wolframalpha.com/… Aug 7, 2023 at 18:36
• The reason you don't need to take the absolute is because $b - x > 0$ and $x - a > 0$ implicitly since our domain is $(a,b)$. Aug 7, 2023 at 18:42
• @AndréChristofferAndersen This is btw also essentially the same function as you came up with. Just scale your function by $1/2$. I think you might be confusing the inverse trigonometric function arctan with the inverse hyperbolic function arctanh (or artanh), as arctanh(x) is just $\frac{1}{2}\ln(\frac{1+x}{1-x})$. Aug 7, 2023 at 18:45
• That is so illuminating! Why didn't I bother to check? Here is my a=2 and b=12 example with the scaling you said. Fits like a glove: wolframalpha.com/… Aug 7, 2023 at 18:58