Andreas Enge on Mon, 16 Aug 2021 21:05:20 +0200

 Re: Is it possible to do interval arithmetic, simulate passing intervals as function arguments, like in Giac?

• To: Neven Sajko <nsajko@gmail.com>
• Subject: Re: Is it possible to do interval arithmetic, simulate passing intervals as function arguments, like in Giac?
• From: Andreas Enge <andreas.enge@inria.fr>
• Date: Mon, 16 Aug 2021 21:05:13 +0200
• Cc: pari-users@pari.math.u-bordeaux.fr
• Delivery-date: Mon, 16 Aug 2021 21:05:20 +0200
• References: <CAL+bK4M4v_zssx5TMK2qOJ-3Z6f0ocDBmMs0GtM-XE4CmdHEiQ@mail.gmail.com>

```Hello Neven,

Am Wed, Jul 28, 2021 at 01:43:24PM +0000 schrieb Neven Sajko:
> In Giac if I do this, the result is pretty much the same as in Pari:
> sin(i[0.01, 0.02])
> But, consider this Giac command:
> sin(i[0.01, 2 * Pi + 0.02])
> The result is the entire interval [-1 .. +1].
>
> Is there a way to do something like this (for any analytic function,
> not just sin)?

you can use the ARB library for interval arithmetic:
https://arblib.org/
It is also accessible in GP through PariTwine:
http://www.multiprecision.org/paritwine/

I am not familiar with GIAC, but I suppose the first command computes sin
on the real interval between 0.01 and 0.02. In ARB, this would have to be
written as the real ball around 0.015 of radius 0.005.
Then after "make install" of PariTwine, you could do this in GP:
? \r /usr/local/share/paritwine/paritwine.gp
? acb_sin([0.015,0.005])
%110 = [0.014999250013749521048822543889400549233, 0.004999417622457258403]
? acb_sin([Pi+0.015,Pi+0.005])
%111 = [0, 1.0000000018626451492]

We only wrapped a few functions from ARB, since there are just so many,
but could easily add more. (More precisely, the acb_ functions operate
on complex rectangles, but here we did not specify any complex parts,
so work indeed with a real line segment.)

Andreas

```