Forgot password?
 Create new account
Search
View: 121|Reply: 5

[几何] 5个矩形的面积相同 求正方形的边长

[Copy link]

3151

Threads

8383

Posts

610K

Credits

Credits
65393
QQ

Show all posts

hbghlyj Post time 2024-2-14 06:16 |Read mode
本帖最后由 hbghlyj 于 2024-2-14 19:17 编辑 Solving a simple geometric puzzle in CLPQ/R (Prolog)
给定三个约束:
  • 所有矩形(A、B、C、D 和 E)的面积相同;
  • 它们构成了一个正方形;
  • A的高度为2。
求正方形的边长。
A B C D E

3151

Threads

8383

Posts

610K

Credits

Credits
65393
QQ

Show all posts

 Author| hbghlyj Post time 2024-2-14 06:17
Mathematica
  1. domain = a >= 1 && b >= 1 && c >= 1 && d >= 1 && e >= 1 && ah == 2.0 && a == b == c == d == e && aw >= 1 && bw >= 1 && cw >= 1 && dw >= 1 && ew >= 1
  2. rectangles = (a == ah*aw && b == bh*bw && c == ch*cw && d == dh*dw && e == eh*ew)
  3. FindMinimum[{eh,
  4.   domain && rectangles &&
  5.   ((bw + cw ) == aw && dw == cw && (ah + bh) == eh && (ch + dh) == bh && (aw + ew) == eh)},
  6.   {a, b, c, d, e, ah, aw, bh, bw, ch, cw, dh, dw, eh, ew}]
Copy the Code


Answers:

{8., {a -> 12.8, b -> 12.8, c -> 12.8, d -> 12.8, e -> 12.8,
      ah -> 2., aw -> 6.4, bh -> 6., bw -> 2.13333, ch -> 3.,
      cw -> 4.26667, dh -> 3., dw -> 4.26667,
      eh -> 8., ew -> 1.6}}

3151

Threads

8383

Posts

610K

Credits

Credits
65393
QQ

Show all posts

 Author| hbghlyj Post time 2024-2-14 06:17
SWI-Prolog
?- pack_install(clpBNR).
:- use_module(library(clpBNR)).
  1. solve_(Eh) :-
  2.   Vs = [A,B,C,D,E, Aw,Bw,Cw,Dw,Ew, Ah,Bh,Ch,Dh,Eh],
  3.   Vs::real(1,100),
  4.   { Ah == 2,
  5.     A is Ah * Aw,
  6.     B is Bh * Bw,
  7.     C is Ch * Cw,
  8.     D is Dh * Dw,
  9.     E is Eh * Ew,
  10.     A == B,
  11.     B == C,
  12.     C == D,
  13.     D == E,
  14.     (Bw + Cw) == Aw,
  15.      Dw == Cw,
  16.     (Ah + Bh) == Eh,
  17.     (Ch + Dh) == Bh,
  18.     (Aw + Ew) == Eh
  19.   },
  20.   solve(Vs).
Copy the Code

?- solve_(Eh).
::(Eh, ...( 8.000000)) .

9

Threads

348

Posts

2806

Credits

Credits
2806

Show all posts

睡神 Post time 2024-2-15 01:34 From the mobile phone
正方形的边长为8?为什么很容易就算出了答案?是不是我没理解题目?

Comments

把 $E$ 扔掉, 剩下图形的高度是 $A$ 高度的 $4$ 倍. 也就是正方形的边长($8$).  Post time 2024-2-15 15:30
除了不懂,就是装懂

3151

Threads

8383

Posts

610K

Credits

Credits
65393
QQ

Show all posts

 Author| hbghlyj Post time 2024-2-15 02:57
睡神 发表于 2024-2-14 17:34
为什么很容易就算出了答案?

很容易就算出了答案只是测试 prolog clpBNR

手机版|悠闲数学娱乐论坛(第3版)

2025-3-6 11:27 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list