SigFigs.jl

Sometimes numbers don't matter. This can help you find when that is true.
Author caseykneale
Popularity
2 Stars
Updated Last
1 Year Ago
Started In
April 2020

SigFigs.jl

Stable Dev Build Status Codecov Build Status

Overview

Significant Figures (AKA SigFigs) are a mathematical means that ensures that derived values do not possess more information then they actually do. Think about it like this:

Say you want to know how large 1/3 of the diameter of a pizza is. You measure this pizza to be 45.72(+/-0.01) cm with a meter stick. So let's do the math

julia> 45.73 * (1/3)
15.243333333333332

No! Wrong. Nope! How could we possibly say anything about how many micrometers or nanometers the pizza is with our current measuring implement? We can't! SigFigs.jl what ever shall we do?

Bah bah buh bahhhh

using SigFigs
julia> SigFigs.significantfigures( SigFig(45.73, 4) * (1/3) )
15.24

Oh whew - all is well with the universe. Thanks SigFigs.jl!

Functionality

Basic operations with SigFigs instances (+,-,*,/,%, cos, sin, asin, exp, log, sqrt, etc) and some collections (transpose, matrix multiply, etc) are currently supported. You likely will find rough patches. Report any bugs, unexpected behaviours, etc.

Is this the right tool for you?

I facetiously posted an announcement of this package in Julia Slack. Let's be honest this is a pretty underwhelming contribution. Someone replied, something to the effect of "Doesn't Measurements.jl already do this?", and offered the following snipit:

using Measurements
julia> (45.73 ± 0.01) * (1/3)
15.2433 ± 0.0033

Note: Measurements.jl will display uncertainty to 2 decimal places.

So I must say, as I always do, I love Measurements.jl! And yes, it will give the proper significant figures for most linear operations of a Measurements instance if the uncertainties are known. But, there are MANY cases where an uncertainty is not known, or requires tremendous amount of work to even ballpark estimate. Similarly, there are many cases where running Measurements.jl has a significant over-head. In those cases it may be preferred to only bother with the significant figures of a calculation. So its a pragmatic way of handling certain calculations without going deep into the weeds. If the order of magnitude estimate is off from a desired application, was it really worth tabulating all of the uncertainties in a complicated process?