題:找到面積為84平方單位的三角形,且邊長都為整數。
解:
我們知道直角三角形的面積是最好計算的。
當m,n都為整數,且m>n,則「m²-n²,m²+n²,2mn」可以成為一組勾股數。
則找出一系列勾股數:
m | n | 直角三角形的三邊長度 | 面積 | ||
m²-n² | 2mn | m²+n² | |||
2 | 1 | 3 | 4 | 5 | 6 |
3 | 1 | 8 | 6 | 10 | 24● |
3 | 2 | 5 | 12 | 13 | 30 |
4 | 1 | 15 | 8 | 17 | 60● |
4 | 2 | 12 | 16 | 20 | 96 |
4 | 3 | 7 | 24 | 25 | 84★ |
則發現上面有一個面積直接就是84:
另有兩個加起來等於84:
不過還漏掉了一組勾股數,是「3,4,5」的三倍:「9,12,15」,它的面積是54,跟「5,12,13」的面積30加起來,正好可以得到84:
update at 2024-03-06:
一位數學高手又找到了一個這樣的三角形:8,29,35。
m | n | 直角三角形的三邊長度 | 面積 | ||
m²-n² | 2mn | m²+n² | |||
5 | 2 | 21 | 20 | 29 | 420 |
它跟(3,4,5)*7即「21,28,35」都共有一個「21」,且面積相減(21*28-21*20)/2=84。
這個三角形,如果手工計算,而不依靠電腦,是難以發現的。
/*
One requires
that a + b > c > 0
and that b + c > a > 0
and that c + a > b > 0.
Since c >= b >= a > 0, one needs only to require that
a + b > c > 0.
The area of the triangle is given by
area = sqrt (p * (p - a) * (p - b) * (p - c)),
in which p = (a + b + c) / 2.
Squaring both sides yields
area * area * 16 == (a + b + c) * (b + c - a) * (c + a - b) * (a + b - c)
Note that a + b + c, b + c - a, c + a - b
are automatically positive,
so one does not have to check
whether a + b - c > 0 separately,
since the left-hand side is always positive,
and a positive number (> 0) can never equal a nonpositive number (<= 0).
*/
for (let a = 1, area = 84; a <= area; a -= -1) {
for (let b = a; b <= area; b -= -1) {
for (let c = b; c <= area; c -= -1) {
if (area * area * 16 == (a + b + c) * (b + c - a)
* (c + a - b) * (a + b - c)) {
console.log(a, b, c) ;}}}}