This gist isn't mathematically rigorous so don't expect it to be as formal as something you'd find in academia.
This problem arises in various math and computer science topics where your input range needs to be transformed to fit into a different range. For example, let's say you had frequency data of a song at a particular moment in time. Each sample is a value that ranges from 0
to 255
. In interval notation, it would be written as [0, 255]
. The square brackets denote that the endpoints are inclusive - in other words, 0
and 255
are acceptable. We want to take a sample in this range and map it to a different range. Let's say our output range is [-1, 1]
. The [-1, 1]
range actually pops up a lot in various fields such as graphics programming or trigonometry. For example the range for the sine
and cosine
functions is [-1, 1]
.
So we want to take the range [0, 255]
and map it to the range [-1, 1]
. Of course, we'd want the mapping t