• Stars
    star
    11
  • Rank 1,640,391 (Top 34 %)
  • Language
    Julia
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Error-free transformations are used to get results with extra accuracy.

ErrorfreeArithmetic.jl

Error-free transformations are used to get results with extra accuracy.

Copyright © 2016-2022 by Jeffrey Sarnoff. Released under the MIT License.


Build Status Stable Documentation


exports

  • The number that begins a function name always matches the number of values returned.
    • the values returned are of descending magnitude and non-overlapping when added.
  • The number that begins a function name often matches the number of arguments expected.
    • two_inv and two_sqrt are single argument functions returning two values

These are error-free transformations.

  • two_sum, two_diff, two_prod
  • two_square, two_cube
  • three_sum, three_diff, three_prod
  • two_fma, three_fma
  • four_sum, four_diff

These are error-free transformations with magnitude sorted arguments.

  • two_hilo_sum, two_lohi_sum
  • two_hilo_diff, two_lohi_diff
  • three_hilo_sum, three_lohi_sum
  • three_hilo_diff, three_lohi_diff
  • four_hilo_sum, four_lohi_sum
  • four_hilo_diff, four_lohi_diff

These are least-error transformations, as close to error-free as possible.

  • two_inv, two_sqrt
  • two_div

naming

The routines named with the prefix two_ return a two-tuple holding (high_order_part, low_order_part).

Those named with the prefix three_ return a three-tuple holding (high_part, mid_part, low_part).

introduction

Error-free transformations return a tuple of the nominal result and the residual from the result (the left-over part).

Error-free addition sums two floating point values (a, b) and returns two floating point values (hi, lo) such that:

  • (+)(a, b) == hi
  • |hi| > |lo| and (+)(hi, lo) == hi abs(hi) and abs(lo) do not share significant bits

Here is how it is done:

function add_errorfree(a::T, b::T) where T<:Union{Float64, Float32}
    a_plus_b_hipart = a + b
    b_asthe_summand = a_plus_b_hipart - a
    a_plus_b_lopart = (a - (a_plus_b_hipart - b_asthe_summand)) + (b - b_asthe_summand)
    return a_plus_b_hipart, a_plus_b_lopart
end

a = Float32(1/golden^2)                           #   0.3819_6602f0
b = Float32(pi^3)                                 #  31.0062_7700f0
a_plus_b = a + b                                  #  31.3882_4300f0

hi, lo = add_errorfree(a,b)                       # (31.3882_4300f0, 3.8743_0270f-7)

a_plus_b == hi                                    # true
abs(hi) > abs(lo) && hi + lo == hi                # true

The lo part is a portion of the accurate value, it is (most of) the residuum that the hi part could not represent.
The hi part runs out of significant bits before the all of the accurate value is represented. We can see this:

a = Float32(1/golden^2)                           #   0.3819_6602f0
b = Float32(pi^3)                                 #  31.0062_7700f0

hi, lo = add_errorfree(a,b)                       # (31.3882_4300f0, 3.8743_0270f-7)

a_plus_b_accurate = BigFloat(a) + BigFloat(b)
lo_accurate  = Float32(a_plus_b_accurate - hi)

lo == lo_accurate                                 # true

use

This package is intended to be used in the support of other work.
All routines expect Float64 or Float32 or Float16 values.

references

[LO2020] Marko Lange and Shin'ichi Oishi A note on Dekker’s FastTwoSum algorithm Numerische Mathematik (2020) 145:383–403 https://doi.org/10.1007/s00211-020-01114-2

[BGM2017] Sylvie Boldo, Stef Graillat, and Jean-Michel Muller On the robustness of the 2Sum and Fast2Sum algorithms ACM Transactions on Mathematical Software, Association for Computing Machinery, 2017 https://hal.inria.fr/ensl-01310023

[GMM2007] Stef Graillat, Valérie Ménissier-Morain Error-Free Transformations in Real and Complex Floating Point Arithmetic International Symposium on Nonlinear Theory and its Applications (NOLTA'07), Sep 2007, Vancouver, Canada. Proceedings of International Symposium on Nonlinear Theory and its Applications (NOLTA'07), pp.341-344. https://hal.archives-ouvertes.fr/hal-01306229

[ORO2006] Takeshi Ogita, Siegfried M. Rump, and Shin'ichi Oishi Accurate Sum and Dot Product SIAM J. Sci. Comput., 26(6), 1955–1988. Published online: 25 July 2006 DOI: 10.1137/030601818

[D1971] T.J. Dekker A floating-point technique for extending the available precision. Numer. Math. 18, 224–242 (1971). https://doi.org/10.1007/BF01397083

More Repositories

1

RollingFunctions.jl

Roll a window over data; apply a function over the window.
Julia
98
star
2

NamedTupleTools.jl

some utilities for working with NamedTuples
Julia
74
star
3

ArbNumerics.jl

extended precision math, accurate and performant
Julia
68
star
4

SaferIntegers.jl

These integer types use checked arithmetic, otherwise they are as system types.
Julia
54
star
5

TimesDates.jl

Nanosecond resolution for Time and Date, TimeZones
Julia
31
star
6

TypedDelegation.jl

Easily apply functions onto fields' values. Use a struct's fields as operands for operations on values of that type.
Julia
25
star
7

AngleBetweenVectors.jl

An accurate and stable calculation of the angle separating two vectors.
Julia
25
star
8

FastRationals.jl

Arithmetic with small and with very large rationals is made fast.
Julia
20
star
9

CatmullRom.jl

Centripetal Catmull-Rom curves for interpoint traversal
Julia
13
star
10

SortingNetworks.jl

Sort 1..25 values with conditional swaps
Julia
12
star
11

FastRounding.jl

Faster directed rounding for inline arithmetic
Julia
11
star
12

WindowedFunctions.jl

successor to RollingFunctions.jl
Julia
9
star
13

BitsFields.jl

Bitfields are made much easier to use
Julia
8
star
14

CardinalDicts.jl

Fast fixed-size dicts wth eraseable entries for keys that are or that map to sequential indicies.
Julia
8
star
15

IEEEFloats.jl

Standard conformant constants for Float64, Float32, Float16
Julia
3
star
16

Readables.jl

makes extended precision numbers readable
Julia
3
star
17

CompoundPeriods.jl

enhances Dates.CompoundPeriod
Julia
3
star
18

GUI.jl

Interfaces for Julia that are gooey to the touch.
Julia
3
star
19

LowLevelFloatFunctions.jl

Manipulate sign, exponent, significand of Float64, Float32, Float16 values.
Julia
2
star
20

DirectedRoundings.jl

round floating point arithmetic as you direct
Julia
2
star
21

JuliaCon2022meetup

My presentation "Using Julia Well"
2
star
22

XFloats.jl

Precision-doubled floating point types nearly as performant as hardware floats.
Julia
2
star
23

InfinityInts.jl

Integer types that support infinity
Julia
2
star
24

QNaNs.jl

Use of quiet NaNs carrying different payloads.
Julia
2
star
25

TimeDates.jl

Provides TimeDate, a nanosecond resolved DateTime type.
Julia
2
star
26

FiniteFloats.jl

Floats with neither Infinities nor NaNs nor signed zeros.
Julia
2
star
27

UsingSollya

Information and code examples to assist using Sollya.
Python
1
star
28

TwoFloats.jl

Julia
1
star
29

UsingJuliaWell

Jeffrey A. Sarnoff Uses Julia Well
1
star
30

TimeSeries2.jl

Julia
1
star
31

Abstractions.jl

abstract, union, and simplifying types
Julia
1
star
32

RollOverData_Jan2023.jl

A more capable `RollingFunctions.jl`.
Julia
1
star
33

RollingWindows.jl

apply functions to windows moving over data sequences
Julia
1
star
34

DatesPlus.jl

Experimental Dates stdlib to support TimesDates.jl v2
Julia
1
star
35

ComparisonsWithJulia

see https://discourse.julialang.org/t/julia-fn-clearer-than-c-fortran-examples-sought/50739
1
star