# Convert decibels to amplitude - Built-in function

Is there a built-in function to convert decibels to amplitude in Mathematica? I tried with:

UnitConvert[Quantity[40, "decibels"], "amplitude"]


but it does not work.

Online I found only a widget for Wolfram Alpha:

http://www.wolframalpha.com/widgets/view.jsp?id=21e1ea77bd91aaa0fc4d01a943a654e

• 10^(amplitudeIndB/20.) – andre314 Aug 8 '18 at 16:14
• Hello @andre, I am looking for a built-in function that does the same thing. – Gennaro Arguzzi Aug 8 '18 at 16:17
• Why insist on built-in? I think answer will be no such built-in, although the external resources (databases, W|A) continue to evolve, I think. W|A does not seem currently to be able to recognize "amplitude ratio" or the ISO term "root-power quantity," which does not seem to be an ISO unit per se or have a unit name/symbol. – Michael E2 Aug 8 '18 at 17:27
• @MichaelE2 The confusing part is, the document of Quantity claims that "Supported units include all those specified by NIST Special Publication 811. " And decibel is indeed mentioned there – xzczd Aug 8 '18 at 17:48
• @xzczd Yes, I knew. I thought you would point out that UnitConvert cannot convert decibels to bels, though. It says they are incompatible (Quantity::compat), which seems an error to me. It seems an IndependentUnit[] is treated as having "no relationship to other units within a Quantity." – Michael E2 Aug 8 '18 at 18:38

There is nothing in the documentation, and bellow you can see what you can find in the internal functions, of which nothing that seems to do the job. So the answer to your question is:

No, there is no built-in function to convert decibels to amplitude in Mathematica.

## Speculation on "why"

We can only guess why the developers didn't implement this, a possible narrative may be similar to the case of the now deprecated Units Package. There the documentation said:

"The conversion of temperature units is different from most other unit conversions because it is not multiplicative. This is simply because the zeros of various systems are set at different values. For example, zero degrees Centigrade is the same as 32 degrees Fahrenheit."

So you had to use ConvertTemperature instead of Convert. How is that similar? It's similar because both cases are somehow special. Wikipedia says

The decibel (symbol: dB) is a unit of measurement used to express the ratio of one value of a physical property to another on a logarithmic scale.

dB is NOT an amount of a physical quantity, but a the logarithm of a ratio of two quantities in the same units, therefore unitless and non-linear. Also depending if the you are talking about amplitudes or power (amplitude squared) the factors are 20 or 10.

Therefore, non-linear relationship of something that arguably may not be even a unit with a potentially ambiguous definition... better leave it to the users to define their own, rather simple, solutions.

## A solution

dB2lin[x_] := N[Power[10, x/20]];
lin2dB[x_] := N[20 Log10[x]];


## Internal functions

Some functions with matching names

Names["**Decibel*", IgnoreCase -> True]
(* {"SignalUtilsdecibelQ", "SignalUtilsdecibelQ$", \ "CalculateUnitsUnitCommonSymbolsDecibelsMuUnit", \ "CalculateUnitsUnitCommonSymbolsCalculateUnitsUnitCommonSymbols\ DecibelsMuUnit", "CalculateUnitsUnitCommonSymbolsDecibelsRUnit", \ "CalculateUnitsUnitCommonSymbolsDecibelsVUnit", \ "CalculateUnitsUnitCommonSymbolsDecibelsZUnit"} *) Names["*db*"] (* {"ImageColorOperationsDumpdb", \ "ImageColorOperationsDumpImageColorOperationsDumpdb", \ "PredictionsPrivatedb", \ "PredictionsPrivatePredictionsPrivatedb", \ "StatisticsLibraryDumpdbag", "StatisticsLibraryDumpdbag$", \
"PacletManagerLayoutDocsCollectionPrivatedbFile", \
"SystemFourierTransformDumpdbgPrintFT", \
"ChartingChartLabelingDumpdbgstyle", \
"ChartingChartLabelingDumpdbgstyle$", \ "ChartingChartLabelingDumpdbox", "ChartingdbPrint", \ "ImageColorOperationsDumpdbPrint", "ImageHumanDumpdbPrint", \ "ImageSpatialOperationsDumpdbPrint", \ "VisualizationVectorFieldsVectorFieldsDumpdbPrint", \ "WaveletsWaveletUtilitiesdbPrint", \ "PacletManagerLayoutDocsCollectionPrivatedbStrm", \ "PacletManagerLayoutDocsCollectionPrivatedbStrm$", \
"ChartingCommonDumpdbstyle", \
"ChartingChartLabelingDumpdbTimingReap", \
"ChartingChartLabelingDumpdbVpp", "ChartingParserDumpdbVpp", \
"SystemListPointPlot3DDumpdbVpp", \
"SystemListPointPlot3DDumpSystemListPointPlot3DDumpdbVpp"} *)

• Hello @rhermans, thank you for your extremely clear answer. – Gennaro Arguzzi Aug 8 '18 at 17:06
• "It's not an amount of a physical quantity, but a the logarithm of a ratio of two quantities in the same units, therefore unitless. " Hmm… but UnitConvert[Quantity[40, "AngularDegrees"], "Radians"] works. – xzczd Aug 8 '18 at 17:12
• @xzczd remember that with the Units package "The conversion of temperature units is different from most other unit conversions because it is not multiplicative. This is simply because the zeros of various systems are set at different values. For example, zero degrees Centigrade is the same as 32 degrees Fahrenheit." so you had to use ConvertTemperature instead of Convert. Is not that there are no ways around, but these are special cases. And radians is closer to the idea of a units, as they are amounts of $\pi$ – rhermans Aug 8 '18 at 17:17
• Well, "AngularDegrees" isn't a unit for temperature, it's a unit for angle, which is dimensionless. With this example I just want to illustrate that dimensionless or unitless doesn't seem to be a reason for the "failure" of Mathematica. – xzczd Aug 8 '18 at 17:25
• UnitConvert will call InternalMWACompute["MWAToQuantity", name] to use WolframAlpha to assist with units when the unit name is not among the built-in ones. Now W|A can convert between decibels and bels, but UnitConvert cannot. So the call to W|A might only result in an IndependentUnit[] that cannot be converted. – Michael E2 Aug 8 '18 at 18:36