The sides of a trapezoid are 5, 8, 11, and 13, and its diagonals are also integer numbers; what are they?
The following program tries all six combinations of opposite sides being parallel: 5,8; 5,11; 5,13; 8,11; 8,13; and 11,13. It tries for all integral diagonals where the diagonal from bottom left to top right is less than the total of the left and the top and also less than the total of the bottom and the right, and the diagonal from top left to bottom right is less than the total of the top and right and also less than the total of the bottom and the left.
It uses the law of cosines to find the angle at the top, left and right respectively and uses that to find the altitude. If the two altitudes agree it is a trapezoid. As the bottom is not used in the calculation, the overhang of the top is calculated on each side, as well as the sum of the overhang and the top, to get what the bottom would be. The program doesn't seem to find any that match. Here's the program:
DEFDBL AZ
pi = ATN(1) * 4
DEF fnac (x) = ATN(SQR(1  x * x) / x)
CLS
top = 8: bottom = 13: left = 5: right = 11
GOSUB findEm
top = 5: bottom = 13: left = 8: right = 11
GOSUB findEm
top = 8: bottom = 11: left = 5: right = 13
GOSUB findEm
top = 8: bottom = 5: left = 13: right = 11
GOSUB findEm
top = 5: bottom = 11: left = 8: right = 13
GOSUB findEm
top = 11: bottom = 13: left = 5: right = 8
GOSUB findEm
END
findEm:
FOR d1 = 1 TO top + left  1
csn = ((top * top + left * left  d1 * d1) / (2 * top * left))
IF ABS(csn) > 1 AND ABS(csn)  1 < .000001 THEN csn = 1
IF d1 < bottom + right AND ABS(csn) <= 1 THEN
IF csn = 0 THEN
a = pi / 2
ELSE
a = fnac(csn)
END IF
alt1 = left * COS(a  pi / 2)
a1 = a: cs1 = csn
FOR d2 = 1 TO top + right  1
csn = ((top * top + right * right  d2 * d2) / (2 * top * right))
IF ABS(csn) > 1 AND ABS(csn)  1 < .000001 THEN csn = 1
IF d2 < bottom + left AND ABS(csn) <= 1 THEN
IF csn = 0 THEN
a = pi / 2
ELSE
a = fnac(csn)
END IF
alt2 = right * COS(a  pi / 2)
a2 = a: cs2 = csn
r = alt1 / alt2
IF ABS(r  1) < .00000001# THEN
o1 = left * SIN(a1  pi / 2)
o2 = right * SIN(a2  pi / 2)
b = top + o1 + o2
PRINT USING "### ### ### ### ### ### ##.##### ###.##### ###.##### ###.######"; top; bottom; left; right; d1; d2; alt1; o1; o2; b
END IF
END IF
NEXT
END IF
NEXT
RETURN
with the results
top "bot"left rt d1 d2 alt left over rt over calc bottom
8 5 13 11 9 9 8.87412 9.50000 6.50000 8.000000
8 5 13 11 11 13 10.95445 7.00000 1.00000 0.000000
11 13 5 8 8 5 3.33278 3.72727 7.27273 0.000000
The purported bottom is not used in the calculation, but the bottom is calculated (rightmost column) based on the top and the two overhangs. But in the three instances found the bottom is calculated to be negative or zero, rather than the supposed bottom length.
Perhaps there's a bug in my program.
Edited on January 17, 2005, 5:32 pm

Posted by Charlie
on 20050117 17:26:41 