2

I'm trying to map a range:

$$0 \le x \le 1$$

non-linearly to another range:

$$0.01 \le y \le 4$$

where $x = 0.5$ must map to $y = 1$. Essentially, I have three known points:

x  0.00  0.50  1.00
y  0.01  1.00  4.00

and $y$ cannot ever be $\lt 0.01$ (I mention this explicitly because I have also toyed with quadratics in an attempt to solve this problem).

My distant high-school maths memories tell me that I need an exponential function to achieve this. To that end, I followed the instructions in $\infty+1$'s YouTube video, Write an Exponential Equation Given 3 Points, and worked from $y = ar^x + c$ to arrive at this very-close solution:

$$ y = \frac{13167}{6700}\cdot\left(\frac{100}{33}\right)^{x}-\frac{131}{67} $$

This solution satisfies $(0,0.01)$ and $(1,4)$, but not $(0.5,1)$. I guess I need to somehow “tighten” the curve such that the $y$ values for $0 \le x \le 0.5$ are lower without affecting point $(1,4)$, but I'm at a loss as to how I might do this. I guess I have chosen the wrong exponential equation to start from.

Should I be starting from another exponential equation, and should I be able to solve this with my reasonably basic maths skills of algebra and simultaneous equations (and not enough understanding to know where to start with terms like regression, monotone, and differentiable as found in answers to similar questions)?

Alex Peters
  • 123
  • 5
  • To be clear, what kind of accuracy do you expect ? You want to do the same fiting error for the three points ? – nicomezi Jan 16 '20 at 09:06
  • @nicomezi, I'm hoping to find an exactly-defined solution if this is possible. I understand that I might be able to generate approximations using online tools or Excel, but this function is going into software and any inaccuracies at the defined points—especially $(0, 0.01)$—could result in crashes. – Alex Peters Jan 16 '20 at 09:12
  • Do you mean $x=.5$ maps to $y=1$ or $x=.05$ maps to $y=1$? You say both. – saulspatz Jan 16 '20 at 09:55
  • I think that you made a few mistakes in the calculations. – Claude Leibovici Jan 16 '20 at 09:56
  • @saulspatz, the $.05$ is a typo. Sorry about that. Fixed. – Alex Peters Jan 16 '20 at 11:25
  • @ClaudeLeibovici, this is very possible. I know I made at least one significant error in my first attempt. I'm also not entirely sure that my $(0.5, 1)$ point was used directly in my calculations. It's probably a very good thing that no one's lives depend on my mathematics. – Alex Peters Jan 16 '20 at 11:31

2 Answers2

3

Using $y = ar^x + c$ and using whole numbers as you obviously did, we have three equations $$a+c=\frac{1}{100} \tag 1$$ $$a \sqrt{r}+c=1 \tag 2$$ $$a r+c=4 \tag 3$$ Subtract $(1)$ from $(2)$ and $(1)$ from $(3)$; $c$ is no more here $$a \sqrt{r}-a=\frac{99}{100}\tag 4$$ $$a r-a=\frac{399}{100} \tag 5$$ From $(5)$ $$a=\frac{399}{100 (r-1)}\tag 6$$ Plug in $(4)$ to get $$\frac{300-99 \sqrt{r}}{100 \left(\sqrt{r}+1\right)}=0 \implies \sqrt r=\frac {300}{99}=\frac{100}{33}\implies r=\frac{10000}{1089}$$ back to $a$ and $c$ $$y=\frac{3267}{6700} \left(\frac{10000}{1089}\right)^x-\frac{32}{67}$$

Edit

If you have three points $(0,y_1)$, $(0.5,y_2)$, $(1,y_3)$, the generic formulae are $$a=\frac{(y_1-y_2)^2}{y_1-2 y_2+y_3}\qquad r=\left(\frac{y_2-y_3}{y_1-y_2}\right)^2\qquad c=\frac{y_1 y_3-y_2^2}{y_1-2 y_2+y_3}$$

This can be generalized for three points $(x_1,y_1)$, $(x_2,y_2)$, $(x_3,y_3)$ if $x_2=\frac 12 (x_1+x_3)$ using as intermediate variable $t=\frac{x-x_1}{x_3-x_1}$ and the formual becomes $$y= ar^{\frac{x-x_1}{x_3-x_1}}+c$$ $(a,r,c)$ being the same as just above.

  • 1
    (+1) Slightly quicker to divide (5) by (4) to get $\surd r+1=399/99$ directly. – John Bentin Jan 16 '20 at 10:31
  • @JohnBentin. You are correct and I am stupid ! Cheers :-( – Claude Leibovici Jan 16 '20 at 10:49
  • Thank you so much, @ClaudeLeibovici. I am studying your answer, because I will shortly need to repeat this for $(0, 0.2)$ instead of $(0, 0.01)$. I am especially trying to understand “Plug in $(4)$ to get...” more clearly. – Alex Peters Jan 16 '20 at 12:10
  • @JohnBentin, thank you too. I am having some difficulty understanding the transformations in the line underneath $(6)$, but with your shortcut for determining $r$, it is perhaps not an issue. In any case, with the clear instructions in this answer I have successfully recalculated for a different initial point of $(0, 0.2)$. – Alex Peters Jan 16 '20 at 12:37
  • @ClaudeLeibovici, your edit has actually addressed a problem I didn't even know I had yet—all three $y$ values will in fact be variable. If I could give you a double upvote, I would. Thank you again. – Alex Peters Jan 17 '20 at 10:36
0

I prefer to add another answer for the problem of the curvature.

Back to the original problem with data points $(0,y)$, $(0.5,1.0)$, $(1,4)$ the parameters are given by $$a=\frac{(y-1)^2}{y+2}\qquad r=\frac{9}{(y-1)^2}\qquad c=\frac{4 y-1}{y+2}$$For $f(x)=a r^x+c$, the curvature at $x=0.5$ is given by $$\kappa=\frac{a (\log (r)+2)}{2 \sqrt{r} \left(1+a^2 r \log ^2(r)\right)^{3/2}}$$ which would give the awful $$\kappa=\frac{(1-y)^3 (y+2)^2 \left(2+\log (9)-2\log \left(1-y\right)\right)}{6 \left((y+2)^2+9 (1-y)^2 \log ^2\left(\frac{9}{(1-y)^2}\right)\right)^{3/2}}\tag 1$$ Since $y \ll 1$, we can expand as a Taylor series to get, as an approximation, $$\kappa=\frac{2 (2+\log (9))}{3 \left(4+9 \log ^2(9)\right)^{3/2}}+\frac{ (2 \log (9) (9 (\log (9)-2) \log (9)-122)-40)}{3 \left(4+9 \log ^2(9)\right)^{5/2}}y+\cdots$$ which, numerically is $$\kappa=0.0085608 -0.0120139 y$$ from which you can compute the value of $y$ for the desired curvature.

Using $(1)$, as a function of $y$, some values $$\left( \begin{array}{cc} 0.00 & 0.00856080 \\ 0.01 & 0.00844115 \\ 0.02 & 0.00832246 \\ 0.03 & 0.00820472 \\ 0.04 & 0.00808791 \\ 0.05 & 0.00797201 \\ 0.06 & 0.00785702 \\ 0.07 & 0.00774292 \\ 0.08 & 0.00762968 \\ 0.09 & 0.00751730 \\ 0.10 & 0.00740577 \\ 0.11 & 0.00729507 \\ 0.12 & 0.00718518 \\ 0.13 & 0.00707609 \\ 0.14 & 0.00696779 \\ 0.15 & 0.00686027 \\ 0.16 & 0.0067535 \\ 0.17 & 0.00664749 \\ 0.18 & 0.00654221 \\ 0.19 & 0.00643765 \\ 0.20 & 0.00633381 \end{array} \right)$$