2
$\begingroup$

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

enter image description here

$\endgroup$
  • $\begingroup$ 10^(amplitudeIndB/20.) $\endgroup$ – andre314 Aug 8 '18 at 16:14
  • $\begingroup$ Hello @andre, I am looking for a built-in function that does the same thing. $\endgroup$ – Gennaro Arguzzi Aug 8 '18 at 16:17
  • 1
    $\begingroup$ 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. $\endgroup$ – Michael E2 Aug 8 '18 at 17:27
  • 1
    $\begingroup$ @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 $\endgroup$ – xzczd Aug 8 '18 at 17:48
  • 1
    $\begingroup$ @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." $\endgroup$ – Michael E2 Aug 8 '18 at 18:38
6
$\begingroup$

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]
(* {"Signal`Utils`decibelQ", "Signal`Utils`decibelQ$", \
"CalculateUnits`UnitCommonSymbols`DecibelsMuUnit", \
"CalculateUnits`UnitCommonSymbols`CalculateUnits`UnitCommonSymbols`\
DecibelsMuUnit", "CalculateUnits`UnitCommonSymbols`DecibelsRUnit", \
"CalculateUnits`UnitCommonSymbols`DecibelsVUnit", \
"CalculateUnits`UnitCommonSymbols`DecibelsZUnit"} *)

Names["*`db*"]
(* {"Image`ColorOperationsDump`db", \
"Image`ColorOperationsDump`Image`ColorOperationsDump`db", \
"Predictions`Private`db", \
"Predictions`Private`Predictions`Private`db", \
"Statistics`Library`Dump`dbag", "Statistics`Library`Dump`dbag$", \
"PacletManager`LayoutDocsCollection`Private`dbFile", \
"System`FourierTransformDump`dbgPrintFT", \
"Charting`ChartLabelingDump`dbgstyle", \
"Charting`ChartLabelingDump`dbgstyle$", \
"Charting`ChartLabelingDump`dbox", "Charting`dbPrint", \
"Image`ColorOperationsDump`dbPrint", "Image`HumanDump`dbPrint", \
"Image`SpatialOperationsDump`dbPrint", \
"Visualization`VectorFields`VectorFieldsDump`dbPrint", \
"Wavelets`WaveletUtilities`dbPrint", \
"PacletManager`LayoutDocsCollection`Private`dbStrm", \
"PacletManager`LayoutDocsCollection`Private`dbStrm$", \
"Charting`CommonDump`dbstyle", \
"Charting`ChartLabelingDump`dbTimingReap", \
"Charting`ChartLabelingDump`dbVpp", "Charting`ParserDump`dbVpp", \
"System`ListPointPlot3DDump`dbVpp", \
"System`ListPointPlot3DDump`System`ListPointPlot3DDump`dbVpp"} *)
$\endgroup$
  • $\begingroup$ Hello @rhermans, thank you for your extremely clear answer. $\endgroup$ – Gennaro Arguzzi Aug 8 '18 at 17:06
  • $\begingroup$ "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. $\endgroup$ – xzczd Aug 8 '18 at 17:12
  • $\begingroup$ @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$ $\endgroup$ – rhermans Aug 8 '18 at 17:17
  • $\begingroup$ 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. $\endgroup$ – xzczd Aug 8 '18 at 17:25
  • 1
    $\begingroup$ UnitConvert will call Internal`MWACompute["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. $\endgroup$ – Michael E2 Aug 8 '18 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.