算額(その163)
岐阜県大垣市西外側町 大垣八幡神社 天保年間
http://ryugen3.sakura.ne.jp/toukou3/wasankibousya.PDF
第14問: 2 個の紫円を黃円に入れ,その間に 4 個の赤円を入れる。紫円の直径を知って黃円の直径を求めよ。
一般性を失わず黃円の半径を 1 とする。紫円,赤円の径をそれぞれ r1, r2 として連立方程式を解く。
using SymPy
@syms r1::positive, r2::positive;
eq1 = (1 - r2)^2 + (1 - r1)^2 - (r1 + r2)^2
eq2 = r2^2 + (1 - r1)^2 - (r1 - r2)^2
res = solve([eq1, eq2], (r1, r2))
res |> println
Tuple{Sym, Sym}[(1/8 + sqrt(17)/8, 5/4 - sqrt(17)/4)]
r1 = res[1][1]
r2 = res[1][2];
1/r1 |> simplify |> println # 紫円 r1 を知って,黃円の径を得るときの倍数
-1/2 + sqrt(17)/2
r2/r1 |> simplify |> println # 紫円 r1 を知って,赤円 r2 の径を得るときの倍数
-11/4 + 3*sqrt(17)/4
1/r2 |> simplify |> println # 赤円 r2 を知って,黃円の径を得るときの倍数
sqrt(17)/2 + 5/2
r1/r2 |> simplify |> println # 赤円 r2 を知って,紫円 r1 の径を得るときの倍数
11/8 + 3*sqrt(17)/8
using Plots
function circle(ox, oy, r, color=:red; beginangle=0, endangle=360, fill=false)
θ = beginangle:0.1:endangle
x = r.*cosd.(θ)
y = r.*sind.(θ)
if fill
plot!(ox .+ x, oy .+ y, linecolor=color, linewidth=0.5, seriestype=:shape, fillcolor=color)
else
plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
end
end;
function point(x, y, string="", color=:green, position=:left, vertical=:top; mark=true)
mark && scatter!([x], [y], color=color, markerstrokewidth=0)
annotate!(x, y, text(string, 10, position, color, vertical))
end;
function draw(more)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
(r1, r2) = res[1]
println("r1 = $r1 = $(r1.evalf())\nr2 = $r2 = $(r2.evalf())")
plot()
circle(0, 0, 1, :yellow, fill=true)
circle(0, 1 - r1, r1, :orchid1, fill=true)
circle(0, r1 - 1, r1, :orchid1, fill=true)
circle(r2, 0, r2, :tomato1, fill=true)
circle(-r2, 0, r2, :tomato1, fill=true)
circle(1 - r2, 0, r2, :tomato1, fill=true)
circle(r2 - 1, 0, r2, :tomato1, fill=true)
circle(0, 1 - r1, r1, :orchid3)
circle(0, r1 - 1, r1, :orchid3)
if more == true
point(0, 1 - r1, " 1-r1", :black)
point(r2, 0, "r2", :black, :top)
point(1 - r2, 0, "1-r2", :black, :top)
point(1, 0, " 1", :black, :left, :top)
hline!([0], color=:black, lw=0.5)
vline!([0], color=:black, lw=0.5)
else
plot!(showaxis=false)
end
end;
r1 = 1/8 + sqrt(17)/8 = 0.640388203202208
r2 = 5/4 - sqrt(17)/4 = 0.219223593595585