算額(その761)
山形県鶴岡市羽黒町 出羽三山神社 文政6年(1823)
http://www.wasan.jp/yamagata/haguro.html
教材アーカイブス/算数・数学/文献/算額
http://www.s-soarer.jp/?plugin=attach&refer=%E6%95%99%E6%9D%90%E3%82%A2%E3%83%BC%E3%82%AB%E3%82%A4%E3%83%96%E3%82%B9%2F%E7%AE%97%E6%95%B0%E3%83%BB%E6%95%B0%E5%AD%A6%2F%E6%96%87%E7%8C%AE%2F%E7%AE%97%E9%A1%8D&openfile=DSCN1420.JPG
楕円内に2本の斜線と大円(半円)と甲円,乙円,丙円を入れる。乙円と丙円の直径がそれぞれ 3 寸と 2 寸(注)のとき,甲円の直径はいかほどか。
注:前者の URL では数字が判然とせず,検索の結果後者がヒットし,数字が確定できた。
楕円の長半径と短半径を a, b
甲円の半径と中心座標を r1, (0, b - r1)
乙円の半径と中心座標を r2, (0, r2 - b)
丙円の半径と中心座標を r3, (a - r3, 0)
半円の半径と中心座標を r0, (0, b - r0)
とおき,以下の連立方程式を解く。
include("julia-source.txt");
using SymPy
@syms a::positive, b::positive, r0::positive,
r1::positive, r2::positive, r3::positive,
x1::positive, x2::positive,
y1::positive, y2::positive
eq1 = eq1 = r0^2/a^2 + (b - r0)^2/b^2 -1
eq2 = (a - r3)^2 + (b - r0)^2 - (r0 + r3)^2
eq3 = distance(x1, y1, -x2, -y2, 0, b - r1) - r1^2
eq4 = distance(x1, y1, -x2, -y2, 0, r2 - b) - r2^2
eq5 = distance(x1, y1, -x2, -y2, a - r3, 0) - r3^2
eq6 = x1^2/a^2 + y1^2/b^2 - 1
eq7 = x2^2/a^2 + y2^2/b^2 - 1
eq8 = 2r2 + r0 - 2b
using NLsolve
function nls(func, params...; ini = [0.0])
if typeof(ini) <: Number
r = nlsolve((vout, vin) -> vout[1] = func(vin[1], params..., [ini]), ftol=big"1e-40")
v = r.zero[1]
else
r = nlsolve((vout, vin)->vout .= func(vin, params...), ini, ftol=big"1e-40")
v = r.zero
end
return Float64.(v), r.f_converged
end;
function H(u)
(a, b, r0, r1, x1, x2, y1, y2) = u
return [
-1 + (b - r0)^2/b^2 + r0^2/a^2, # eq1
(a - r3)^2 + (b - r0)^2 - (r0 + r3)^2, # eq2
-r1^2 + (x1*(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2) - (x1 + x2)*(-b*y1 - b*y2 + r1*y1 + r1*y2 + x1^2 + x1*x2 + y1^2 + y1*y2))^2/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2)^2 + (b - r1 - (b*y1^2 + 2*b*y1*y2 + b*y2^2 - r1*y1^2 - 2*r1*y1*y2 - r1*y2^2 - x1^2*y2 + x1*x2*y1 - x1*x2*y2 + x2^2*y1)/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2))^2, # eq3
-r2^2 + (x1*(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2) - (x1 + x2)*(b*y1 + b*y2 - r2*y1 - r2*y2 + x1^2 + x1*x2 + y1^2 + y1*y2))^2/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2)^2 + (-b + r2 - (-b*y1^2 - 2*b*y1*y2 - b*y2^2 + r2*y1^2 + 2*r2*y1*y2 + r2*y2^2 - x1^2*y2 + x1*x2*y1 - x1*x2*y2 + x2^2*y1)/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2))^2, # eq4
-r3^2 + (x1 + x2)^2*(a*y1 + a*y2 - r3*y1 - r3*y2 - x1*y2 + x2*y1)^2/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2)^2 + (a - r3 - ((a - r3)*(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2) - (y1 + y2)*(a*y1 + a*y2 - r3*y1 - r3*y2 - x1*y2 + x2*y1))/(x1^2 + 2*x1*x2 + x2^2 + y1^2 + 2*y1*y2 + y2^2))^2, # eq5
-1 + y1^2/b^2 + x1^2/a^2, # eq6
-1 + y2^2/b^2 + x2^2/a^2, # eq7
-2*b + r0 + 2*r2, # eq8
]
end;
(r2, r3) = (3, 2) .// 2
iniv = BigFloat[14, 7, 12, 6, 15, 6, 2, 7]
res = nls(H, ini=iniv)
([10.772733743669523, 6.13102420004887, 9.26204840009774, 4.383884823343673, 10.493949340307568, 5.4542418519895035, 1.3857702087399792, 5.287131918198976], true)
乙円と丙円の直径がそれぞれ 3 寸と 2 寸のとき,甲円の直径は 8.76777 寸となった。
「答」では「甲円の直径は十一寸零三分八厘六毛四一九有奇」となっており,計算結果と合わない。連立方程式に使った条件式のどれかが不適切なのかもしれない。
その他のパラメータは以下のとおりである。
甲円の直径 = 8.76777; 乙円の直径 = 3; 丙円の直径 = 2
a = 10.7727; b = 6.13102; r0 = 9.26205; r1 = 4.38388; x1 = 10.4939; x2 = 5.45424; y1 = 1.38577; y2 = 5.28713
function draw(more=false)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
#(r2, r3) = (0.17, 0.12)
(a, b, r0, r1, x1, x2, y1, y2) = res[1]
@printf("甲円の直径 = %g; 乙円の直径 = %g; 丙円の直径 = %g\n", 2r1, 2r2, 2r3)
@printf("a = %g; b = %g; r0 = %g; r1 = %g; x1 = %g; x2 = %g; y1 = %g; y2 = %g\n", a, b, r0, r1, x1, x2, y1, y2)
plot()
ellipse(0, 0, a, b, color=:red)
circle(0, b - r1, r1, :blue)
circle(0, r2 - b, r2, :green)
circle2(a - r3, 0, r3, :magenta)
circle(0, b - r0, r0, :orange, beginangle=0, endangle=180)
segment(-r0, 2r2 - b, r0, 2r2 - b, :orange)
segment(x1, y1, -x2, -y2)
segment(-x1, y1, x2, -y2)
if more
delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3 # size[2] * fontsize * 2
hline!([0], color=:gray80, lw=0.5)
vline!([0], color=:gray80, lw=0.5)
point(0, b - r1, " 甲円:r1\n (0,b-r1)", :blue, :left, :vcenter)
point(0, r2 - b, " 乙円:r2\n (0,r2-b)", :green, :left, :vcenter)
point(r0, b - r0, "(r0,b-r0)", :orange, :right, :bottom, delta=delta/2)
point(a - r3, 0, "丙円:r3\n(a-r3,0)", :black, :right, delta=-delta/2)
point(a, 0, " a", :red, :left, :vcenter)
point(0, b, " b", :red, :left, :bottom, delta=delta)
point(x1, y1, "(x1,y1) ", :black, :right, :bottom, delta=delta)
point(x2, -y2, " (x2,-y2)", :black, :left, :vcenter)
end
end;