算額(その157)
岐阜県大垣市西外側町 大垣八幡神社 天保年間
http://ryugen3.sakura.ne.jp/toukou3/wasankibousya.PDF
第6問: 直角三角形内に黃,赤,黒の半円を入れる。黃,赤の半円の直径を知って黒の半円の直径を求めよ。
黃,赤,黒の半円の半径を r1, r2, r3,斜辺が x 軸,y 軸と交差する点の座標を x,y と置く。関係式を解き,r3 を求める。2倍すれば直径である。
using SymPy
@syms r1::positive, r2::positive, r3::positive, x::negative, y::positive;
eq1 = 2r2 / (2r1 - r2) - (2r2 - r3) / 2r3
eq2 = (2r2 - r3)/2r3 +y/x
eq3 = (2r2 - r3)/2r3*(x + r2) + r1 + 2r2
res = solve([eq1, eq2, eq3], (r3, x, y))
1-element Vector{Tuple{Sym, Sym, Sym}}:
(2*r2*(2*r1 - r2)/(2*r1 + 3*r2), -r1^2/r2 - 3*r1/2, r1*(2*r1 + 3*r2)/(2*r1 - r2))
res[1][1] |> println # r3: 黒の半径
2*r2*(2*r1 - r2)/(2*r1 + 3*r2)
黒の直径は 4*赤*(2*黃 - 赤)/(2*黃 + 3*赤)
(2*res[1][1])(r1 => 5/2, r2 => 3/2).evalf()
2.21052631578947
術文 赤径 / 2(赤径 / (2黃径 - 赤径) + 1/4) なる式を掲げているが,たいしてきれいでもない。
res2 = 2r2 / 2(2r2 / (4r1 - 2r2)+1/4)
res2(r1 => 5/2, r2 => 3/2).evalf()
2.21052631578947
using Plots
using Printf
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(r1, r2, more)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
(r1, r2) = (r1, r2) ./ 2
(r3, x, y) = (2*r2*(2*r1 - r2)/(2*r1 + 3*r2), -r1^2/r2 - 3*r1/2, r1*(2*r1 + 3*r2)/(2*r1 - r2))
println("黃の直径 = $(2r1),赤の直径 = $(2r2),黒の直径 = $(2r3)")
plot()
circle(-r1, r1, r1, :yellow, beginangle=180, endangle=360, fill=true)
circle(-r2, r1 + r2, r2, :red, beginangle=270, endangle=450, fill=true)
circle(-r2 - r3, r1 + r3, r3, :black, beginangle=180, endangle=360, fill=true)
plot!([0, 0, x, 0], [0, y, 0, 0], color=1, lw=0.5)
if more == true
point(0, r1, " r1")
point(0, r1 + r3, " r1+r3")
point(0, r1 + r2, " r1+r2")
point(0, r1 + 2r2, " r1+2r2")
point(-r1, 0, "-r1", :green, :center, :bottom)
point(-r2, 0, "-r2", :green, :center, :bottom)
point(-r2 - 2r3, 0, "-r2-2r3", :green, :center, :bottom)
point(-2r1, 0, "-2r1", :green, :center, :bottom)
point(0, y, " y")
point(x, 0, "x ", :green, :right, :bottom)
hline!([0, r1, r1 + r3, r1 + r2, r1 + 2r2], color=:gray, linestyle=:dot, lw=0.5)
vline!([0, -r2, -r1, -r2 - 2r3, -2r1], color=:gray, linestyle=:dot, lw=0.5)
else
plot!(showaxis=false)
end
end;
draw(11, 5, false)
黃の直径 = 11.0,赤の直径 = 5.0,黒の直径 = 4.594594594594595