The answer is 4, for a=b=2.
The following program will run in QB4.5 or QB64, producing a first quadrant colored yellow where x*y>x+y and blue where x*y<x+y, overlaid with hyperbolae for different values of x*y, and the value 4 is tangent to the boundary of the yellow and the blue areas. Also the line for x=y is shown:
SCREEN 12 ' 640 x 480
DEFDBL A-Z
xmax = 5#: xmin = 0#: xr = xmax - xmin: sc = 640 / xr
ymin = xmin
' Color yellow areas where x*y>x+y and blue where x*y<x+y (black if equal)
FOR x = xmin TO xmax STEP 1 / sc
FOR y = ymin TO ymin + 479 / sc STEP 1 / sc
IF x * y > x + y THEN
COLOR 14
ELSEIF x * y = x + y THEN
COLOR 0
ELSE
COLOR 9
END IF
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
NEXT
NEXT
COLOR 0
' Draw hyperbolae for values of x*y (i.e., xy) and line y=x
FOR xy = 1# TO 5 STEP .5
FOR x = xmin + 1 / sc TO xmin + 639 / sc STEP 1 / sc
y = xy / x
IF y > ymin AND y <= ymin + 479 / sc THEN
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
END IF
y = x
IF y > ymin AND y <= ymin + 479 / sc THEN
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
END IF
NEXT
NEXT
DO: LOOP UNTIL INKEY$ > ""
A finer-grained view near the point of tangency is provided with:
SCREEN 12 ' 640 x 480
DEFDBL A-Z
xmax = 2.2#: xmin = 1.8#: xr = xmax - xmin: sc = 640 / xr
ymin = xmin
' Color yellow areas where x*y>x+y and blue where x*y<x+y (black if equal)
FOR x = xmin TO xmax STEP 1 / sc
FOR y = ymin TO ymin + 479 / sc STEP 1 / sc
IF x * y > x + y THEN
COLOR 14
ELSEIF x * y = x + y THEN
COLOR 0
ELSE
COLOR 9
END IF
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
NEXT
NEXT
COLOR 0
' Draw hyperbolae for values of x*y (i.e., xy)
FOR xy = 3.9# TO 4.101# STEP .05
FOR x = xmin + 1 / sc TO xmin + 639 / sc STEP 1 / sc
y = xy / x
IF y > ymin AND y <= ymin + 479 / sc THEN
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
END IF
y = x
IF y > ymin AND y <= ymin + 479 / sc THEN
PSET ((x - xmin) * sc, (479 - (y - ymin) * sc))
END IF
NEXT
NEXT
DO: LOOP UNTIL INKEY$ > ""
|
Posted by Charlie
on 2013-04-12 12:40:29 |