# Interval arithmetic and implicit function inside test

I has implicit function and square region. I need to check this region for presence of part of curve, with interval arithmetic only.

My attempt:

ClearAll["Global*"];
f[a_Interval, b_Interval] := Sin[a + b] - Cos[a*b] + 1;
s = 1.1;(*Square size*)
cx = -3.9; (*Square center x*)
cy = -1.2; (*Square center y*)

x = Interval[{cx - s/2, cx + s/2}];
y = Interval[{cy - s/2, cy + s/2}];

IntervalMemberQ[f[x, y], 0]


Does this code are correctly solve the problem?

Update: I need to get a false if the curve is guaranteed not in the specified square(include inner area). But true value cannot guaranteed the opposite

• BTW, AroundReplace[ Sin[a + b] - Cos[a*b] + 1, {a -> Around[-3.9, 0.55], b -> Around[-1.2, 0.55]}] performs a worser result Around[2,2.5]. Nov 22, 2019 at 20:19
• The implicit curve is given by f[a,b]==0? And you want to determine whether f[square1,square2] hits zero? Nov 23, 2019 at 16:17
• The above code giving False is sufficient but not necessary condition for the square in question to contain no zero. Changing s to 2.0, for example, will give a result of True when in fact this larger square still contains no zero. Nov 24, 2019 at 16:55
• @DanielLichtblau I need to get a false if the curve is guaranteed not in the specified square(include inner area). But true value cannot guaranteed the opposite. Nov 24, 2019 at 17:02
• A False is a guarantee of no intersection. So if that is all you require, the code is fine for that purpose. Nov 24, 2019 at 17:04

Likely correctly in view of

NMinimize[{Sin[a + b] - Cos[a*b] + 1, a >= -3.9 - 0.55&& a <= -3.9 + 0.55 && b >= -1.2 - 0.55 &&
b <= -1.2 + 0.55}, {a, b}]


{0.38735,{a->-4.45,b->-1.4593}}

The function does not achieve a zero within the square (as is supported byNMinimize.

reg = ImplicitRegion[Abs[x + 3.9] < 0.55 &&Abs[y + 1.2] < 0.55, {{x, -5, 0}, {y, -2, 0}}];
Show[ContourPlot[f[x, y] == 0, {x, -5, 0}, {y, -5, 0}],RegionPlot[reg]]


Or it can be seen by plotting region and plane z=0:

{m, w} = NMinimize[f[x, y], {x, y} \[Element] reg];
pnt = {Sequence[x, y], m} /. w;
Show[Plot3D[{f[x, y], 0}, {x, y} \[Element] reg, Mesh -> None],
Graphics3D[{Red, PointSize[0.02], Point[{-3.9, -1.2, f[-3.9, -1.2]}],
Green, Point[pnt]}]]
`

• I updated my question, please take a look Nov 24, 2019 at 17:18