JuliaPhysics / Measurements.jl

Error propagation calculator and library for physical measurements. It supports real and complex numbers with uncertainty, arbitrary precision calculations, operations with arrays, and numerical integration.

Home Page:https://juliaphysics.github.io/Measurements.jl/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong values when multiplication with scalar?

MichielStock opened this issue · comments

Unless I completely misunderstand how the error propagation is computed, there seems to be something wrong with the decimal points after the values when multiplying with a constant.

julia> r = 10.0 ± 0.9
10.0 ± 0.9

julia> r^2
100.0 ± 18.0

julia> π * r^2
314.0 ± 57.0

julia> π * r.val^2
314.1592653589793

I don't see why the values would be different, as Measurements should only propagate the errors?

https://juliaphysics.github.io/Measurements.jl/stable/usage/#Measurements-in-the-REPL

julia> Measurements.value(π * r^2), Measurements.uncertainty(π * r^2)
(314.1592653589793, 56.548667764616276)

But it should output 314.2 not 314.0, no?

https://juliaphysics.github.io/Measurements.jl/stable/usage/#Measurements-in-the-REPL

truncated in order to present two significant digits for the uncertainty:

The second significant digit of the uncertainty is on the unit, and so also the value is truncated at the same level. And to be extra clear, this is only related to printing value to screen to avoid showing superlong unsignificant numbers, but the actual objects retains the full precision.