算額(その167)
岐阜県大垣市西外側町 大垣八幡神社 天保年間
http://ryugen3.sakura.ne.jp/toukou3/wasankibousya.PDF
第17問: 外接する 2 個の円と共通接線の間に青と黒の正方形を置く,黃円の径を知って黒の正方形の一辺の長さを求めよ。
図のように青と黒の正方形の右下隅の x 座標を x1, x2,円の半径を r として,連立方程式を解く。
using SymPy
@syms r::positive, x1::positive, x2::positive;
eq1 = (r - x1)^2 + (r - 2x1)^2 - r^2
eq2 = (r - x2)^2 + (r - x2 + x1)^2 - r^2
res = solve([eq1, eq2], (x1, x2))
4-element Vector{Tuple{Sym, Sym}}:
(r/5, 2*r/5)
(r/5, 9*r/5)
(r, r)
(r, 2*r)
題意を満たすのは (r/5, 2*r/5) である。r は半径なので,黒の正方形の一辺の長さは黃円の直径の 1/10 である。
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 rect(x1, y1, x2, y2, color=:pink)
plot!([x1, x2, x2, x1, x1], [y1, y1, y2, y2, y1], color=color, linewidth=0.5, seriestype=:shape, fillcolor=color)
end;
function draw(R, more)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
r = R / 2
(x1, x2) = (r/5, 2*r/5)
plot()
println("黃径 = $R, 黒一辺 = $(x2 - x1), 青一辺 $(2x1)")
circle(r, r, r, :yellow, fill=true)
circle(-r, r, r, :yellow, fill=true)
rect(-x1, 0, x1, 2x1, :blue)
rect(x1, 0, x2, x2 - x1, :black)
rect(-x1, 0, -x2, x2 - x1, :black)
if more == true
point(r, r, "(r,r,r)", :black)
point(x1, 0, "x1", :black, :top)
point(x2, 0, "x2", :black, :top)
hline!([0], color=:black, lw=0.5)
vline!([0], color=:black, lw=0.5)
else
plot!(showaxis=false)
end
end;
draw(123, true)
黃径 = 123, 黒一辺 = 12.3, 青一辺 24.6