QuadGK unexpected behavior on first degree polynomial

Domenico_Lahaye
Thu, 18 Apr 2024 09:38:22 +0000
Numerics

I constructed a tiny example on which my (naive?) use of the quadgk() fails. The example is a first order polynomial in x and y on the triangular domain with vertices (0,0), (1,0) and (0,1). Below a working and failing MWE. What do I overlook? Thx.

fooworks(x,y) = -8.0*x-8.0*y+4.0
gnuworks(y) = quadgk(x->fooworks(x,y),0,1-y)[1]
fooint = quadgk_count(y->gnuworks(y),0,1)

produces -0.66… as expected output.

# observe change in coefficient (-4 instead of -8) of the term with y
foofails(x,y) = -8.0*x-4.0*y+4.0
gnufails(y) = quadgk(x->foofails(x,y),0,1-y)[1]
fooint = quadgk(y->gnufails(y),0,1)

hangs in performing computations.

3 posts - 2 participants