3
$\begingroup$

I'm looking for a function that will produce a downwards sloping line, the shape of which is determined by one of the function's parameters. For example, given the function $f(x, z, n)$, where $x$ has the domain of $0$ to $n$, varrying the parametr $z$ should potentially produce the following curves:

varying z

Thus, depending on $z$, the derivative can be constant, decreasing, or increasing (but never goes above $0$). Also, the line should always start at $1$ and end at $0$, ie. $f(x=0, z, n) = 1 $ and $f(x=n, z, n) = 0 $. Is there a practical formula for such a function?

1 Answers 1

3

You could use

$\left(1-\frac xn\right)^z\;.$

In your image, you'd roughly have something like $z_1=1/2$, $z_2=1$, $z_3=2$. Here's a plot.

[Edit in response to the comment:]

Yes, you can make the curves more like quarter-circles by using

$\left(1-\left(\frac xn\right)^{1/z}\right)^z$

instead. Here's a plot for that. Then the curve for $z=1/2$ is exactly a quarter-circle (it's distorted by different scaling on the axes on the W|A plot), but the curve for $z=2$ isn't exactly the corresponding reflected quarter-circle. I think to get that to be the case with a single formula while fulfilling the other constraints would be tricky, but you can always use the above expression for $z\le1$ and then for $z\gt1$ just use the one for $1/z$ reflected; that would be

$ y=\begin{cases} \left(1-\left(\frac xn\right)^{1/z}\right)^z&z\le1\;, \\ 1-\left(1-\left(\frac {1-x}n\right)^z\right)^{1/z}&z\gt1\;. \end{cases}$

Here's a plot for that.

[Update:]

I played around with this some more. I didn't like the fact that $x$ and $y$ were playing different roles whereas the quarter-circles and the straight line seemed to indicate that the curves should ideally be symmetric with respect to interchange of $x$ and $y$. I came up with something symmetric, which also has the advantage of requiring only a square root and not arbitrary exponentiation.

I'll ignore the factor $n$ for now to keep things simple; as above, we can simply divide $x$ by $n$ in the end to get that scaling right. Now consider the coordinate transform

$s=x-y\;,$ $t=x+y-1\;,$

which rotates the coordinate system by $\pi/4$ and maps the straight blue line to the line $t=0$, $s\in[-1,1]$. A curve for which $t$ is an even function of $s$ is symmetric with respect to interchange of $x$ an $y$. In these coordinates, the circle equation $x^2+y^2=1$ becomes

$(1-s)(1+s)=t(2+t)\;.$

On the other hand, to get the extreme case $y=1$ for all $x$, we need $t=s+1$, or, to make it look more like the other equation,

$(1-s)(1+s)=t(2-t)\;.$

Now we have two equations that differ only in the coefficient $\pm1$ in one place, so we can interpolate between them by introducing a variable $\alpha$ for that coefficient:

$(1-s)(1+s)=t(2+\alpha t)\;.$

For $\alpha\to\infty$ we recover $t=0$, which is the straight blue line. Thus, the range $\alpha\in[-1,\infty]$ yields an interpolation between the straight blue line ($\alpha=\infty$), the red quarter-circle ($\alpha=1$) and the extreme case $y=1$ ($\alpha=-1$). To get a nice range and make it match up with a corresponding range for the curves below the straight line, we can transform to $z=1/(\alpha+1)$ to get the range $z\in[0,\infty]$, with $z=0$ corresponding to the straight blue line.

Putting everything together by transforming from $s,t$ back to $x,y$ and from $\alpha$ to $z$ and solving for $y$ yields

$y=f(x,z):=(x-1)(2z-1)+2\sqrt{z(1-x)(x(1-z)+z)}\;.$

Taking into account the factor of $n$ and obtaining the curves below the the straight line for $z<0$ by reflection as above, we get the final result

$ y= \begin{cases} f(x/n,z)&z\ge0\;,\\ 1 - f(1 - x/n,-z)&z<0\;, \end{cases} $

with $f$ defined as above. Here are some plots.

  • 0
    Interesting addition. It will take me a while to understand the math, but I can see that there are some useful principles contained within.2011-08-18