A little trick which can be used in programming, to reduce the CPU load, if the value of a Hypotenuse is being Compared.

A scenario which often happens in computing is, that there exists a quantity, call that (a), which will result accurately by squaring the quantities (x), (y) and (z) first, and then computing the square root of the sum. It could then also be said, that the following explicit function has been defined:


F(x, y, z) := sqrt(x^2 + y^2 + z^2)

Further, the idea exists in Computing, that when all one wants to compute, is (x2) for example, it takes fewer CPU cycles actually to compute (x*x), than it takes, to compute a real power function.

But, the object of the exercise could actually be, not to derive (a) from (x), (y) and (z), but rather, to compare two instances of F(x, y, z).

The biggest issue as such, with actually computing F(x, y, z), is, that to compute the square root, is even slower, than it was to compute (x2), (y2) and (z2). Therefore, if one has the luxury of knowing what (a) is in advance, what one can do, for real-number comparisons, is just to square (a), and then, not to compute the square root, which should exist within the function F(). Therefore, when two known quantities are simply being compared, the following way to do it, will run slightly faster:


a^2 < (x^2 + y^2 + z^2)

In Modern Computing, what is often done is, that actual CPU usage is ignored, to make the task of writing complex code easier, and, the situation may not always be recognizable, that two values are going to be compared, which would both have been computed as the square root of one other value. And so, to avoid having to stare at some code cross-eyed, the practice can be just as valid, to compute two instances of F(x, y, z), but, to compute them with the square root function in each case, and somewhere later in the code execution, just to compare the two resulting values.

 

Dirk

 

The Relationship between Voltage and Energy

Energy is proportional to voltage squared. If we make the assumption that a variable voltage is being fed to a constant load-resistor, then with voltage, current would increase, and current would get multiplied by voltage again, to result in energy.

Sound energy is proportional to sound pressure squared. With increasing sound pressure, minute displacement / compression of air results, which causes displacement to rise, and displacement times pressure is again – energy.

The decibel scale is in energy units, not pressure units. Therefore, if a voltage increases by the square root of two, and if that voltage is fed to a constant load, then energy doubles, which is loosely expressed as a 3db relationship. A doubling of voltages would result in a quadrupling of energy units, which is loosely described as a 6db relationship.

Something similar happens to digitally sampled sound. The amplitudes of the samples correspond roughly to the Statistical concept of Standard Deviation, while the Statistical concept of Variance, corresponds to signal-energy. Variance equals Standard Deviation squared…

Dirk

I should add that this applies to small-signal processing, but not to industrial power-transmission. In the latter case, the load resistances are intentionally made to scale with voltages, because the efficiency-gains that stem from voltage-increases, only stem from keeping current-levels under control. Thus, in the latter case, higher amounts of power are transmitted, but without involving higher levels of current. And so here, voltages tend to relate to power units more-or-less linearly.

Continue reading The Relationship between Voltage and Energy