Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A function with vectorized intervals does not provide correct answers for 1D line segment #448

Open
bigm128 opened this issue Apr 28, 2022 · 0 comments

Comments

@bigm128
Copy link

bigm128 commented Apr 28, 2022

I was trying to compute a function with multiple intervals but it keeps failing or gives wrong answers. Here is an example:

val, err = quadpy.c1.integrate_adaptive(
    lambda x: x,
    [[0.0, 0.0, 0.0], [1.0, 2.0, 3.0]]
)

which returns:

Traceback (most recent call last):
  File "C:\...\test_quadpy.py", line 11, in <module>
    val, err = quadpy.quad(lambda x: x, [0.0, 0.0, 0.0], [1.0, 2.0, 3.0])
  File "C:\...\quadpy\_scipy_compat.py", line 55, in quad
    val, err = integrate_adaptive(
  File "C:\...\quadpy\c1\_adaptive.py", line 141, in integrate_adaptive
    good_values_sum = good_values_sum.reshape(orig_shape)
ValueError: cannot reshape array of size 1 into shape (3,)

But if I specify the domain_shape and range_shape in the function call like this:

val, err = quadpy.c1.integrate_adaptive(
    lambda x: x,
    [[0.0, 0.0, 0.0], [1.0, 2.0, 3.0]],
    domain_shape=(3,),
    range_shape=(3,)
)

the function returns [1.87082869 3.74165739 5.61248608] with error estimates [7.75540290e-20 1.55108058e-19 2.32662087e-19] which are not the correct answers (should be [0.5, 0.333, 1.5]).

I'm using numpy version 1.22.3 and scipy version 1.8.0.

Thank you so much.

@bigm128 bigm128 changed the title A function with vectorized intervals do not provide correct answers for 1D line segment A function with vectorized intervals does not provide correct answers for 1D line segment Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant