Help with formula regarding dB

I know the formulas are all over google - and there are dozens of sites explaining the log function of a calcualtor.

Math was not my strong suite in high school.

My head is spinning and I just spent the last hour going down google search rabbit holes. Someone please help me.

I am trying to figure out HOW (on a calculator) to determine voltage and power gain using a simple calculator. Jesus why does this have to be so complicated and convoluted?

Voltage gain is explained as

20log10(v2/v1)

What are the order of operations here?

I already understand the obvious here - v2 is divided by v1. The result is then multiplied by... drum roll.. WHAT?!

What the hell is 20log10? How do I enter this on a darn calculator? What is being done here?

20 times log10? 20log times ten?

Whatever the heck the above equates to... * (v2 / v1), correct?

How. On. Earth. Do. I. Enter. This. On. A. Calculator?

Since I am a software engineer, I am trying to at LEAST think of this as a line of code....

20 * log(10) * (v1/v2)
or ?
 
log or log10 is the logarithm based on 10. Other frquently used logarithm is ln (natural) logarithm, not used for dB calculation.
Simply calculate the voltage ratio, then find the 10-based logarithm, and multiply by 20. Or calculate the power ratio, find the 10-based log, and this is Bels. Multiply by 10 for deciBels or dB.
 
The source of your confusion was possibly the way in which it was written. The proper way would be the following that reads something like "20 times the base-10 logarithm of the ratio of V1 to V2".

1719848952948.png


On a calculator, the base-10 logarithm is log(.) while the base-e logarithm is ln(.), pronounced log and lon respectively.

Hope that helps.
 
I'm a software engineer, so I will type out here the way I have come to understand it (seems to match the math I see online)...

$dBv = 20 * ( log( ($vOut / $vIn), 10 ) );

I finally figured it out on the calculator, too. But.. at the end of the day, the above makes more sense to me.
 
Or another way, think of the bel as the log-base-10 of the power ratio:

* bels = log10(Pout/Pin)

Then the other bits are embelishments on this basic relationship,

* decibels = 10 x bels. [ decibel is a tenth of a bel ]

* Pout/Pin = (Vout/Vin)^2 [ power ratio = square of voltage ratio (or square of current ratio) - for a fixed load impedance. ]

The confusing bit may be the factor twenty. This is due to the relationship:
* log(x^2) = 2 x log(x)

So combining the last three equations gives.
* decibels = 20 x log10(Vout/Vin)
 
And if you like to know the result.

Code:
#include <iostream>
#include <math.h>
double v1 = 101;
double v2 = 199;
double dB;
int main() {
    dB = 20 * log10(v2/v1);
    std::cout << dB;
    return 0;
}

And the advantage of expressing a ratio in dB is?
 
  • Like
Reactions: witwald
Indeed perception of sound loudness (and light brightness come to that) is roughly logarithmic. And in dB its easy to figure out overall gain as you only have to add, not multiply.

dB is basically essential in RF world, RF signal powers vary from nanowatts or less up towards megawatts for large transmitters, no-one wants to handle that many orders of magnitude without a logarithmic scale.
 
  • Like
Reactions: witwald