# Parameterizing cliffs

I am looking for a function $f(x; \alpha, X_1, X_2, Y_1, Y_2)$ that has the following property: For $\alpha=0$ it behaves linearly between $(X_1, Y_1)$ and $(X_2, Y_2)$, and as $\alpha$ gets closer to 1, it approximates a sharp cliff, as in the figure below. The function needs not be defined for $\alpha=1$.

Is there a relatively "simple" function (trigonometrics, powers, logarithms and exponentials are fine) that captures this behavior?

• Let $f(x)=\dfrac{1-x}{1-\alpha x}$ for $0<x<1$.
– user856
Commented Apr 20, 2015 at 21:39
• @Rahul That works beautifully. If you post that as an answer I will accept it.
– Josh
Commented Apr 20, 2015 at 21:54

Consider the function $$f(x)=\left(1-x-\frac{1}{x} \right)(1-\alpha)^2+\frac{1-\alpha}{x}$$ on $[0,1]$. When $\alpha=0$, we have $f(x)=1-x$. As $\alpha \uparrow 1$, the graph approaches a right angle (try plotting it for yourself with Wolfram Alpha). A transformed version of this function should work for your example.

• Thanks @TorsionSquid , but I am not getting the upper-right angle. It looks very close thought. See also my update.
– Josh
Commented Apr 20, 2015 at 20:42
• Yeah, right now it approaches a right angle with the corner at $(0,0)$. You'd need to shift it around to get it in the right place. Commented Apr 20, 2015 at 20:47
• For example, (-x-1/(x-1))*(1-a)^2+(1-a)/(x-1)+1 would have the angle in the right place. Commented Apr 20, 2015 at 20:53
• Thanks @TorsionSquid, I completely understand. Unfortunately and oddly the last one does not give the angle in the right place either.
– Josh
Commented Apr 20, 2015 at 20:59
• Actually, if you restrict $0<x,y<1$ in that picture, it works Commented Apr 20, 2015 at 21:01

The linear equation is given by

$$\frac{x - x_1}{\lvert x_2 - x_1\rvert} + \frac{y - y_2}{\lvert y_1 - y_2\rvert} = 1.$$

We can get successively 'sharper' curves by using

$$\left(\frac{x - x_1}{\lvert x_2 - x_1\rvert}\right)^{k} + \left(\frac{y - y_2}{\lvert y_1 - y_2\rvert}\right)^k = 1$$ for integer $k \geq 1$, using larger $k$.

Here are the graphs for $k = 1, 2, 3, 4, 5, 6$ through the points $(0, 2)$ and $(3, 0)$:

For $k = 1$, we have the linear equation. For $k = 2$, it's one quarter of an ellipse.

Unfortunately, I'm not sure how to translate my parameter of positive integer $k$-values into the parameter $\alpha \in [0, 1)$. I'll leave this here for now, and think about it.

EDIT: It appears that using $k = \dfrac{1+ \alpha}{1 - \alpha}$ for the exponent works quite well.

Here is an image with $\alpha \in \{0, 0.05, 0.1, 0.2, 0.3, 0.5, 0.7, 0.9\}$:

And if instead you use the function

$$\left\lvert\frac{x - x_1}{x_2 - x_1}\right\rvert^{k} + \left\lvert\frac{y - y_2}{y_1 - y_2}\right\rvert^k = 1,\quad \alpha = \frac{1 + \alpha}{1 - \alpha} \in [0, 1),$$

you get something that behaves rather well, regardless of whether $x_1 < x_2$, etc. Now these are between the points $(x_1, y_1) = (0, 2)$ and $(x_2, y_2) = (3, 4)$, with some bonus points thrown in:

• Thanks @pjs36! Quick question though, the scale for the y axis does not seem to match the scale for the x axis, which is odd (the corner seems to be at x=3 and y=2).
– Josh
Commented Apr 20, 2015 at 21:01
• @Josh Yes, you're right; I used $x_1 < x_2$, unlike in your picture. Which brings me to my next point: It's quite sensitive on the ordering! It seems to only behave as desired when $x_1 < x_2$ and $y_1 > y_2$. And the scale is definitely weird; the Mac Grapher app chose those scales, and I didn't change anything. Commented Apr 20, 2015 at 21:04

The beta distribution is the uniform when $\alpha$ and $\beta$ are both equal to 1, and it gets progressivly "sharper" as the parameters change. Therefore, if you let $B(\alpha, \beta)$ represent the CDF of the beta and let $a$ be the alpha from your equation, to prevent confusion and let $y$ be $\frac{x - X2}{X1 - X2}$, the following may work: $$f(y;a, X_1, X_2, Y_1, Y_2) = \left(B\left(1 + \frac{a}{1-a}, 1\right)\biggr\rvert_0^1\cdot\frac{Y_1-Y_2}{X_1-X_2}\right)\cdot\left(X1 - X_2\right) + Y_1$$