[Numpy-discussion] Re: Exact representable difference between for two arrays.

2024-12-19 Thread Andrew Nelson via NumPy-Discussion
On Fri, 20 Dec 2024 at 18:23, Andrew Nelson  wrote:

> Wow, that would be a pretty serious optimization bug to override Kahan
>> summation. Are you speaking of some theoretical future version of the
>> interpreter, or of the current state of things?
>>
>
> I just wanted to know how the current interpreter worked.
>

(For an augmentation of finite differences in scipy.optimize)
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Exact representable difference between for two arrays.

2024-12-19 Thread Andrew Nelson via NumPy-Discussion
>
> Wow, that would be a pretty serious optimization bug to override Kahan
> summation. Are you speaking of some theoretical future version of the
> interpreter, or of the current state of things?
>

I just wanted to know how the current interpreter worked.
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Exact representable difference between for two arrays.

2024-12-19 Thread matti picus via NumPy-Discussion
On Fri, Dec 20, 2024 at 4:48 AM Andrew Nelson via NumPy-Discussion
 wrote:

>
> Or is there a risk that the Python interpreter would prematurely optimize 
> that to give:
>
> ```
> dx = h
> ```
>
>
> --
> _
> Dr. Andrew Nelson


Wow, that would be a pretty serious optimization bug to override Kahan
summation. Are you speaking of some theoretical future version of the
interpreter, or of the current state of things?
Matti
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Exact representable difference between for two arrays.

2024-12-19 Thread Andrew Nelson via NumPy-Discussion
Hi all,
Let's assume we have two float arrays, `x0` and `h`, both of which have the
same shape. Let's calculate the sum of those two arrays:

```
x1 = x0 + h
```

The true representable difference between `x1` and `x0` is:

```
dx = x1 - x0
```

Is it also possible to get that exact representation by doing the following:

```
dx = (x0 + h) - x0
```

Or is there a risk that the Python interpreter would prematurely optimize
that to give:

```
dx = h
```


-- 
_
Dr. Andrew Nelson


_
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com