Linear, Squared and Logarithmic scales with given input domain and output range

523 Views Asked by At

The input domain is $[12,24]$ and the output range is $[0,720]$.

Now I know that with using linear scaling the value $16$ of the input range is mapped to $240$; with using sqrt scaling the same value is mapped to $268.9056992603583$ while with using log scaling the value is mapped to $ 298.82699948076737$.

To be more specific this is done with D3 JS library as follows:

var x = d3.scale.linear() 
 .domain([12, 24]) 
 .range([0, 720]); 

x(16); // 240 


var x = d3.scale.sqrt() 
            .domain([12, 24]) 
            .range([0, 720]); 

x(16); // 268.9056992603583 


var x = d3.scale.log() 
  .domain([12, 24]) 
  .range([0, 720]);

x(16); // 298.82699948076737 

is anybody able to deduce what formulas are being used for the mapping from the input domain to the output range in the different cases?

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Part 1: Set $f(x) = a\sqrt{x}+b.$ Then you have solve $$a\sqrt{12}+b=0,\quad a\sqrt{24}+b=720$$ with the solution $$a= \frac{720}{\sqrt{24}-\sqrt{12}}\approx 501.784866$$ $$b= -\sqrt{12}a\approx -1738.2337649$$ and $f(16)\approx 268.90569926035815289065471834$

Part 2: Set $g(x) = a\ln x+b.$ Then you have solve $$a\ln(12) +b=0,\quad a\ln(24)+b=720$$ with the solution $$a= \frac{720}{\ln(24)-\ln(12)}\approx 1038.740429$$ $$b= -\ln(12)a\approx -2581.17300$$ and $g(16)\approx 298.82699948076754935330796035$