I have this two-variable function $$f(x,y)= (8 \cos (x+y)+7)\cos \left(\frac{x}{2}\right)+\cos \frac{x-2 y}{2}+2 \cos \left(\frac{3 x}{2}\right) $$ where $0<x,y<\pi$. I want to calculate numerically the area for which the function is negative $f(x,y)<0$. I use this code
NIntegrate[
Boole[2 Cos[(3 x)/2] + Cos[1/2 (x - 2 y)] +
Cos[x/2] (7 + 8 Cos[x + y]) < 0], {x, 0, Pi}, {y, 0, Pi}]
and it gives the answer $3.49458$, but Mathematica gives the following warnings. Are there any other ways to calculate this value that is more reliable and more accurate than this method?
NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.
NIntegrate::eincr: The global error of the strategy GlobalAdaptive has increased more than 2000 times. The global error is expected to decrease monotonically after a number of integrand evaluations. Suspect one of the following: the working precision is insufficient for the specified precision goal; the integrand is highly oscillatory or it is not a (piecewise) smooth function; or the true value of the integral is 0. Increasing the value of the GlobalAdaptive option MaxErrorIncreases might lead to a convergent numerical integration. NIntegrate obtained 3.494581434480605
and 0.002397336775896384
for the integral and error estimates.
f[x, y]
is a constant rather than a function ofx
andy
. $\endgroup$u = Integrate[upperCurve, {x, 0, Pi}]
andv = Integrate[lowerCurve, {x, 0, 2 Pi/3}]
, followed byu-v
. ThelowerCurve
and theupperCurve
are defined in eyorble's post. $\endgroup$