Commit acea33e8 authored by Julien Puydt's avatar Julien Puydt

Imported Upstream version 2.8.1


Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

This diff is collapsed.
QUIET_CC = @echo ' ' CC ' ' $@;
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard ../*.h)
TEST_HEADERS = $(wildcard *.h)
OBJS = $(patsubst %.c, $(BUILD_DIR)/$(MOD_DIR)_%.o, $(SOURCES))
LOBJS = $(patsubst %.c, $(BUILD_DIR)/%.lo, $(SOURCES))
TEST_SOURCES = $(wildcard test/*.c)
TESTXX_SOURCES = $(wildcard test/*.cpp)
PROF_SOURCES = $(wildcard profile/*.c)
TUNE_SOURCES = $(wildcard tune/*.c)
TESTS = $(patsubst %.c, $(BUILD_DIR)/%$(EXEEXT), $(TEST_SOURCES)) \
$(patsubst %.cpp, $(BUILD_DIR)/%$(EXEEXT), $(TESTXX_SOURCES))
TESTS_RUN = $(patsubst %, %_RUN, $(TESTS))
VALGRIND_RUN = $(patsubst %, %_VALGRIND_RUN, $(TESTS))
PROFS = $(patsubst %.c, $(BUILD_DIR)/%$(EXEEXT), $(PROF_SOURCES))
TUNE = $(patsubst %.c, %$(EXEEXT), $(TUNE_SOURCES))
all: shared static
shared: $(MOD_LOBJ)
static: $(OBJS)
profile: $(PROFS)
-include $(patsubst %, %.d, $(PROFS))
$(BUILD_DIR)/profile/%$(EXEEXT): profile/%.c $(BUILD_DIR)/../profiler.o
$(QUIET_CC) $(CC) $(ABI_FLAG) -O2 -std=c99 -g $(INCS) $< $(BUILD_DIR)/../profiler.o -o $@ $(LIBS) -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"
$(AT)$(foreach prog, $(TUNE), $(CC) $(CFLAGS) $(INCS) $(prog).c -o $(BUILD_DIR)/$(prog) $(LIBS) || exit $$?;)
-include $(OBJS:.o=.d)
$(BUILD_DIR)/$(MOD_DIR)_%.o: %.c
$(QUIET_CC) $(CC) $(CFLAGS) $(INCS) -c $< -o $@ -MMD -MP -MF "$(BUILD_DIR)/$(MOD_DIR)_$*.d" -MT "$(BUILD_DIR)/$(MOD_DIR)_$*.d" -MT "$@"
$(QUIET_CC) $(CC) $(ABI_FLAG) -Wl,-r $^ -o $@ -nostdlib
-include $(LOBJS:.lo=.d)
$(BUILD_DIR)/%.lo: %.c
$(QUIET_CC) $(CC) $(PIC_FLAG) $(CFLAGS) $(INCS) -c $< -o $@ -MMD -MP -MF "$(BUILD_DIR)/$*.d" -MT "$(BUILD_DIR)/$*.d" -MT "$@"
rm -rf $(BUILD_DIR) $(MOD_LOBJ)
tests: $(TESTS)
check: tests $(TESTS_RUN)
valgrind: tests $(VALGRIND_RUN)
-include $(patsubst %, %.d, $(TESTS))
ifeq ($(ARB_SHARED), 0)
$(BUILD_DIR)/test/%$(EXEEXT): $(BUILD_DIR)/../../libarb.a
$(BUILD_DIR)/test/%$(EXEEXT): test/%.c
$(QUIET_CC) $(CC) $(CFLAGS) $(INCS) $< -o $@ $(LIBS) -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"
$(BUILD_DIR)/test/%$(EXEEXT): test/%.cpp $(BUILD_DIR)/../../test_helpers.o
$(QUIET_CC) $(CXX) $(CFLAGS) $(INCS) $< -o $@ $(LIBS) -MMD -MP -MF $@.d -MT "$@" -MT "$@.d"
%_RUN: %
valgrind --track-origins=yes --leak-check=full --show-reachable=yes --log-file="$*.valgrind" $<
.PHONY: profile tune clean check tests all shared static valgrind %_RUN %_VALGRIND_RUN
# Arb
Arb is a C library for arbitrary-precision interval arithmetic.
It has full support for both real and complex numbers.
The library is thread-safe, portable, and extensively tested.
![arb logo](
Development updates:
Author: Fredrik Johansson <>
Bug reports, feature requests and other comments are welcome
in private communication, on the GitHub issue tracker, or on the FLINT mailing list <>.
## Code example
The following program evaluates `sin(pi + exp(-10000))`. Since the
input to the sine function matches a root to within 4343 digits,
at least 4343-digit (14427-bit) precision is needed to get an accurate
result. The program repeats the evaluation
at 64-bit, 128-bit, ... precision, stopping only when the
result is accurate to at least 53 bits.
#include "arb.h"
int main()
slong prec;
arb_t x, y;
arb_init(x); arb_init(y);
for (prec = 64; ; prec *= 2)
arb_const_pi(x, prec);
arb_set_si(y, -10000);
arb_exp(y, y, prec);
arb_add(x, x, y, prec);
arb_sin(y, x, prec);
arb_printn(y, 15, 0); printf("\n");
if (arb_rel_accuracy_bits(y) >= 53)
arb_clear(x); arb_clear(y);
The output is:
[+/- 6.01e-19]
[+/- 2.55e-38]
[+/- 8.01e-77]
[+/- 8.64e-154]
[+/- 5.37e-308]
[+/- 3.63e-616]
[+/- 1.07e-1232]
[+/- 9.27e-2466]
[-1.13548386531474e-4343 +/- 3.91e-4358]
Each line shows a rigorous enclosure of the exact value
of the expression. The program demonstrates how the user
can rely on Arb's automatic error bound tracking to get an output
that is guaranteed to be accurate -- no error analysis
needs to be done by the user.
For several other example programs, see:
## General features
Besides basic arithmetic, Arb allows working with univariate
polynomials, truncated power series, and matrices
over both real and complex numbers.
Basic linear algebra is supported, including matrix multiplication,
determinant, inverse, nonsingular solving and matrix exponential.
Support for polynomial and power series is quite extensive,
including methods for composition, reversion, product trees,
multipoint evaluation and interpolation, complex root isolation,
and transcendental functions of power series.
Arb has partial support for automatic differentiation (AD), and includes
rudimentary functionality for rigorous calculus based on AD
(including real root isolation and complex integration).
## Special functions
Arb can compute a wide range of transcendental and special functions,
including the gamma function, polygamma functions,
Riemann zeta and Hurwitz zeta function, polylogarithm,
error function, Gauss hypergeometric function 2F1, confluent
hypergeometric functions, Bessel functions, Airy functions,
Legendre functions and other orthogonal polynomials,
exponential and trigonometric integrals, incomplete gamma function,
Jacobi theta functions, modular functions, Weierstrass elliptic function,
complete elliptic integrals, arithmetic-geometric mean,
Bernoulli numbers, partition function, Barnes G-function.
## Speed
Arb uses a midpoint-radius (ball) representation of real numbers.
At high precision, this allows doing interval arithmetic without
significant overhead compared to plain floating-point arithmetic.
Various low-level optimizations have also been implemented
to reduce overhead at precisions of just a few machine
words. Most operations on polynomials and power series
use asymptotically fast FFT multiplication.
For basic arithmetic, Arb should generally be around as fast
as MPFR (, though it can be a bit slower
at low precision, and around twice as fast as MPFI
Transcendental functions in Arb are quite well optimized and
should generally be faster than any other arbitrary-precision
software currently available. The following table
compares the time in seconds to evaluate the Gauss
hypergeometric function `2F1(1/2, 1/4, 1, z)` at
the complex number `z = 5^(1/2) + 7^(1/2)i`, to a given
number of decimal digits (Arb 2.8-git and mpmath 0.19 on
an 1.90 GHz Intel i5-4300U, Mathematica 9.0 on a 3.07 GHz Intel Xeon X5675).
| Digits | Mathematica | mpmath | Arb |
| -------:|:------------|:-----------|:----------|
| 10 | 0.00066 | 0.00090 | 0.00011 |
| 100 | 0.0039 | 0.0017 | 0.00075 |
| 1000 | 0.23 | 1.5 | 0.019 |
| 10000 | 42.6 | 98 | 1.2 |
## Dependencies, installation, and interfaces
Arb depends on FLINT (, either
GMP ( or MPIR (,
and MPFR (
See for instructions
on building and installing Arb directly from the source code.
Arb might also be available (or coming soon) as a package for
your Linux distribution.
SageMath <> will include Arb as a standard package
in an upcoming version, including a high-level Python interface
to Arb as part of the SageMath standard library.
Nemo <> is a computer algebra package for
the Julia programming language which includes a high-level
Julia interface to Arb. The Nemo installation script will
create a local installation of Arb along with other dependencies.
This diff is collapsed.
This file is part of ARB.
ARB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
ARB is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ARB; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2015 Fredrik Johansson
#include "acb.h"
acb_acos(acb_t res, const acb_t z, slong prec)
if (acb_is_one(z))
acb_t t;
acb_asin(res, z, prec);
acb_const_pi(t, prec);
acb_mul_2exp_si(t, t, -1);
acb_sub(res, t, res, prec);
This file is part of ARB.
ARB is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by