# How to map interval $[0, 100]$ to the interval $[100, 350]$?

I have an interval $$[0; 100]$$ and would like to map it to this new interval: $$[100;350]$$.

I thought about multiplying it by $$3.5$$, but that would give the interval $$[0;350]$$. And adding to each of these elements $$100$$ would give: $$[100;450]$$. Hence my question: is it possible to do what I want?

Note that I can settle for the interval $$[0;350]$$ : in my program, it will be enough if I exclude the numbers present in the interval $$[0;99]$$.

• how about multiplying by 2.5 instead? – Lord Shark the Unknown Oct 13 '18 at 8:41

To map from $$[a,b]$$ to $$[c, d]$$,

Consider the straight line that connects $$(a,c)$$ to $$(b,d)$$.

We have the slope $$m = \frac{d-c}{b-a},$$ we are able to recover $$m$$.

$$y=mx+C$$

To recover $$C$$, just substitute one of the value say $$(a,c)$$ and solve for $$C$$. For our example, we have $$a=0$$ and $$c=100$$.

Hence your transformation can be of the form of $$y=mx+100$$. Can you compute the $$m$$ to find what you want?

The ratio of the lengths of the intervals is $$2.5 :1,$$ the position of the left extremity is shifted by $$100.$$ So take the mapping $$f(x)=2.5x+100.$$

Since $$100\cdot t^0=100$$ for any positive $$t$$, we find $$t$$ such that $$100\cdot t^{100}=350\implies t=3.5^{0.01}$$. $$\boxed{y=100\cdot3.5^{0.01x}}$$ In general an exponential mapping from $$[a,b]$$ to $$[c,d]$$ is $$y=c\left(\frac dc\right)^{\frac{x-a}{b-a}}$$.

• Way too complicated; a simple affine transformation works. – saulspatz Oct 13 '18 at 15:21
• @saulspatz I know, since the linear transformation has already been said three times. I just wanted to give the next best approach. – TheSimpliFire Oct 13 '18 at 15:22
• But why the downvote? – TheSimpliFire Oct 13 '18 at 15:27
• I don't think the answer contributes anything positive to the discussion. – saulspatz Oct 13 '18 at 15:29
• @saulspatz My answer is an answer to the question: 'Is it possible to transform an interval into another?' What the OP specifically wanted has already been discussed many times, and I do not see any harm in adding an alternative method to perform such a transformation. – TheSimpliFire Oct 13 '18 at 15:31

You can consider $$x\mapsto ax + b\colon [0,100]\to [100,350]$$ such that $$0\mapsto 100$$ and $$100\mapsto 350$$.

Thus, $$a \cdot 0 + b = 100,\\ a\cdot 100 + b = 350,$$ and solving it gives $$a = \frac 52$$, $$b = 100$$.

In general, the same technique works for intervals $$[x_1,x_2]$$ and $$[y_1,y_2]$$:

$$ax_1 + b = y_1\\ ax_2 + b = y_2.$$

Solving it gives $$a = \frac{y_2 - y_1}{x_2 -x_1}$$ and $$b = y_1 - ax_1$$. All in all, it's a line $$y - y_1 = \frac{y_2-y_1}{x_2-x_1}(x-x_1).$$ Looks familiar?

Another method that’s a bit more general and will come in handy if you want to map arbitrary curves is to parameterize your paths. That is, find a one-to-one mapping from your first path to $$[0,1]$$, $$(0,1]$$, or so on as appropriate. Then find a one-to-one mapping from $$[0,1]$$ to your second path. (The interval $$[0,1]$$ isn’t special, just convenient.) Finally, compose them.

Let’s say you want to map $$x^2$$ over the interval $$[0,4]$$ to $$\sin x$$ over the interval $$[0,2\pi]$$. A one-to-one mapping from the parabola to the line segment, $$t: [0,4] \to [0,1]$$, is $$t = \sqrt{x}/2$$, and a mapping from $$t \in [0,1]$$ to a sine wave over $$[0,2\pi]$$ is $$\sin {2\pi t}$$. Substituting, we get $$\sin {\left( \pi \sqrt{x}\right)}$$. 