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

Inconsistency in arithmetic expressions?

heitorPB opened this issue · comments

Is this expected?

julia> (1234 ± 1) / (1234 ± 1)
1.0 ± 0.0011

julia> (1234 ± 1) - (1234 ± 1)
0.0 ± 1.4

julia> x = (1234 ± 1)
1234.0 ± 1.0

julia> x / x
1.0 ± 1.1e-19

julia> x - x
0.0 ± 0.0

Yes, this is expected and actually a desired behaviour: it allows us to distinguish between two different measurements that share by chance the same value and uncertainty (the first case in your example) from two quantities that are actually the same measurement (the second case in your example).

This is also explained in the documentation, see https://juliaphysics.github.io/Measurements.jl/stable/usage/#Usage-1 (in particular the "Note" box and the "Correlation Between Variables" section)