# Normalize $X$ to $0$ to $10$ scale with asymptotes at either end

I am trying to find a scaling function that mimics the gas gauge in a car. I would like to map a value to a $0$ to $10$ scale, on which I have two known points. For example:

$X_1 = 2$, $Y_1 = 2.5$, $X_2 = 4$, $Y_2 = 7.5$, $X_3 =$ __

The known points, $X_1$ and $X_2$ should always correspond to $Y$ values of $2.5$ and $7.5.$ A simple linear equation is not sufficient, since its possible for the $X_3$ value to generate a $Y$ that is greater than $10$, or less than $0.$

Can you think of a suitable function that matches the known points, but will approach a limit at $0$ and $10$? Thanks for any guidance!

-

Hi, welcome to Math.SE. I recently edited your post - feel free to click the bottom of your post to see the revision history.  When TeXing/using numbers or variables in your post, you can denote them by with the money sign (shift+4) at the front and end of your text where you want to stop the TeXing, where .... is your number/variable, etc. Take a peak around at other posts to learn the syntax for things if you don't know! – Joe Apr 18 '12 at 3:02

## 2 Answers

You can use the arctangent function, which has horizontal asymptotes going to $\pm \infty$. As it ranges from $\frac {-\pi}2$ to $\frac \pi 2$ we need to rescale to get your range of $(0,10)$, so we want $10\left(\frac 1\pi \arctan X_{scaled} + \frac 12\right)$. Now all we have to do is figure out how to scale $X$. This is not too hard as $X_{scaled}=\pm 1$ gives $2.5, 7.5$, so $X_{scaled}=\frac {2(X-(X_1+X_2)/2)}{X_2-X_1}$. The final answer is $Y=10\left(\frac 1\pi \arctan \frac {2(X-(X_1+X_2)/2)}{X_2-X_1} + \frac 12\right)$

-

Another option is to use a function of the form $$\frac{10}{1+ae^{-bx}}$$ which is bound by 0 and 10 as required.

With the requirements of $(2,2.5),(4,7.5)$ we have

$$a e^{-2b} =3 \qquad \text{ and } ae^{-4b}=\frac{1}{3}$$ Dividing to eliminiate the $a$, we have $e^{2b}=9, b =\frac{\ln(9)}{2}$ and $a = 27$. This reduces to

$$\frac{10}{1+27(3^{-x})}$$

This has the benefit of being fairly linear through your data points as shown by the dashed line in the figure.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 35, "mathjax_display_tex": 3, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9596190452575684, "perplexity_flag": "head"}