0

Consider two lamps with the same maximum brightness but: the first lamp has a dial accepting discrete values ranging from 0 (off) to 360 (full brightness), and the second lamp has a dial accepting discrete values from 0 to 100.

Given any value for the first dial, how do I calculate the closest new value for the first dial such there exists a value for the second dial that results in exactly the same brightness?

For example, a value of 40 for the first lamp can be reduced to 36 so that the equivalent value of the second lamp is exactly 10.

  • Well, clearly you will have to multiply the number by $3.6$, but then you would do some rounding. I interpret that you want to round it towards the starting number. So the simplest way to put this is $$ \text{second dial} = \begin{cases} \lfloor 3.6 \cdot \text{first dial} \rfloor & \text{going up} \ \lceil 3.6 \cdot \text{first dial} \rceil & \text{going down} \ \end{cases}
    $$ where $\lfloor \dots \rfloor$ is the floor function, and $\lceil \dots \rceil$ is the ceiling function.
    – Matti P. Aug 07 '20 at 12:49
  • @MattiP. The second dial only has numbers in the range of [0, 100]. 360 * 3.6 > 100 – Richie Bendall Aug 07 '20 at 13:07

1 Answers1

1

The relationship between the first lamp $a$ and the second lamp $b$ is:

$$ a = \frac{360}{100}b = 3.6b $$

Clearly, the lowest whole-number multiple of 3.6 is 18 ($36 \times 5$). Thus, we must round to the nearest compatible interval of 18, which we can compute like so:

$$f_b(a) = 18[\frac{a}{18}]$$

where $[x]$ is the round function.

This function satisfies the aforementioned requirements:

$$f_b(40) = 36$$ $$\frac{f_b(40)}{360} = \frac{\frac{f_b(40)}{3.6}}{100}$$