算額(その341)
和算で遊ぼう!! 「三春まちなか寺子屋」2017レポート
https://miharukoma.com/wp-content/uploads/2018/01/%E4%B8%89%E6%98%A5%E3%81%BE%E3%81%A1%E3%81%AA%E3%81%8B%E5%AF%BA%E5%AD%90%E5%B1%8B2017%E3%83%AC%E3%83%9D%E3%83%BC%E3%83%88.pdf
7月 高木神社
長方形の中に,春円 1 個,夏円 2 個,秋円 1 個,冬円 1 個を入れる。5 個の円の直径の和が 8 寸のとき,長方形の縦の長さ(春円の直径)を求めよ。
春円の半径,中心座標を r1, (a - r1, r1)
夏円の半径,中心座標を r2, (x2, r2), (r2, r2)
秋円の半径,中心座標を r3, (x3, r3)
冬円の半径,中心座標を r4, (x3, 2r1 - r4)
とおき,以下の連立方程式を解く。
include("julia-source.txt");
using SymPy
@syms a::positive, r1::positive, r2::positive, x2::positive, r3::positive, x3::positive, r4::positive
eq1 = r1 + 2r2 + r3 + r4 - 8//2
eq2 = (a - r1 - x2)^2 + (r1 - r2)^2 - (r1 + r2)^2 |> expand
eq3 = (a - r1 - x3)^2 + (r4 - r1)^2 - (r1 + r4)^2 |> expand
eq4 = (x2 - x3)^2 + (r2 - r3)^2 - (r2 + r3)^2 |> expand
eq5 = (x2 - x3)^2 + (2r1 - r4 - r2)^2 - (r2 + r4)^2 |> expand
eq6 = (x3 - r2)^2 + (r2 - r3)^2 - (r2 + r3)^2 |> expand
eq7 = r3 + r4 - r1;
res = solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], (a, r1, r2, x2, r3, x3, r4))
2-element Vector{NTuple{7, Sym}}:
(2 - sqrt(3), 3/2, 1/2, 1/2, 3/8, 1/2 + sqrt(3)/2, 9/8)
(2 + 2*sqrt(3), 3/2, 1/2, 1/2 + sqrt(3), 3/8, 1/2 + sqrt(3)/2, 9/8)
a = 5.4641; r1 = 1.5; r2 = 0.5; x2 = 2.23205; r3 = 0.375; x3 = 1.36603; r4 = 1.125
春円の直径 = 3; 夏円の直径 = 1; 秋円の直径 = 0.75; 冬の直円径 = 2.25
長方形の縦の長さ = 春円の直径 = 3
function draw(more)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
(a, r1, r2, x2, r3, x3, r4) = res[2]
@printf("a = %g; r1 = %g; r2 = %g; x2 = %g; r3 = %g; x3 = %g; r4 = %g\n", a, r1, r2, x2, r3, x3, r4)
@printf("春円の直径 = %g; 夏円の直径 = %g; 秋円の直径 = %g; 冬の直円径 = %g\n", 2r1, 2r2, 2r3, 2r4)
@printf("長方形の縦の長さ = 春円の直径 = %g\n", 2r1)
plot([0, a, a, 0, 0], [0, 0, 2r1, 2r1, 0], color=:black, lw=0.5)
circle(a - r1, r1, r1)
circle(x2, r2, r2, :green)
circle(r2, r2, r2, :green)
circle(x3, r3, r3, :blue)
circle(x3, 2r1 - r4, r4, :orange)
if more
point(a - r1, r1, " 春円:r1,(a-r1,r1)", :red, :center)
point(x2, r2, " 夏円:r2\n(x2,r2)", :green, :center)
point(r2, r2, " 夏円:r2\n(r2,r2)", :green, :center)
point(x3, r3, " 秋円:r3\n(x3,r3)", :blue, :center)
point(x3, 2r1 - r4, " 冬円:r4,(x3,2r1-r4)", :orange, :center)
point(a, 0, "a ", :black, :right, :bottom)
hline!([0], color=:black, lw=0.5)
vline!([0], color=:black, lw=0.5)
else
plot!(showaxis=false)
end
end;