裏 RjpWiki

Julia ときどき R, Python によるコンピュータプログラム,コンピュータ・サイエンス,統計学

算額(その1102)

2024年06月28日 | Julia

算額(その1102)

九十九 江刺市 雨宝堂 現中善観音堂 文政10年(1827)
山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.

http://www.wasan.jp/yamamura/yamamura.html
キーワード:円12個,外円

全円の中に,甲円,乙円,丙円,丁円,戊円を容れる。戊円の直径が 1 寸のとき,丙円の直径はいかほどか。

全円の半径と中心座標を R, (0, 0)
甲円の半径と中心座標を r1, (0, R - r1)
乙円の半径と中心座標を r2, (R - r2, 0)
丙円の半径と中心座標を r3, (x2, y3)
丁円の半径と中心座標を r4, (r5 + r4, 0)
戊円の半径と中心座標を r5, (0, 0)
とおき,以下の連立方程式を解く。

include("julia-source.txt")

using SymPy
@syms R::positive, r1::positive, r2::positive,
     r3::positive, x3::positive, y3::positive,
     r4::positive, r5::positive
R = 2r1 + r5
r4 = r1 - r2
eq1 = (R - r2)^2 + (R - r1)^2 - (r1 + r2)^2 |> expand
eq2 = x3^2 + (R - r1 - y3)^2 - (r1 + r3)^2 |> expand
eq3 = (r4 + r5)^2 + (R - r1)^2 - (r1 + r4)^2 |> expand
eq4 = (x3 - R + r2)^2 + y3^2 - (r2 + r3)^2 |> expand
eq5 = x3^2 + y3^2 - (R - r3)^2 |> expand;

println(eq1, ",  # eq1")
println(eq2, ",  # eq2")
println(eq3, ",  # eq3")
println(eq4, ",  # eq4")
println(eq5, ",  # eq5")

   4*r1^2 - 6*r1*r2 + 6*r1*r5 - 2*r2*r5 + 2*r5^2,  # eq1
   -2*r1*r3 + 2*r1*r5 - 2*r1*y3 - r3^2 + r5^2 - 2*r5*y3 + x3^2 + y3^2,  # eq2
   -2*r1^2 + 2*r1*r2 + 4*r1*r5 - 2*r2*r5 + 2*r5^2,  # eq3
   4*r1^2 - 4*r1*r2 + 4*r1*r5 - 4*r1*x3 - 2*r2*r3 - 2*r2*r5 + 2*r2*x3 - r3^2 + r5^2 - 2*r5*x3 + x3^2 + y3^2,  # eq4
   -4*r1^2 + 4*r1*r3 - 4*r1*r5 - r3^2 + 2*r3*r5 - r5^2 + x3^2 + y3^2,  # eq5

res = solve([eq1, eq3], (r1, r2))[1];

ans_r1 = res[1] |> simplify
ans_r1 |> println

   r5*(3 + 2*sqrt(3))

ans_r2 = res[2]|> simplify
ans_r2 |> println

   r5*(5 + 3*sqrt(3))/2

eq12 = eq2(r1 => ans_r1, r2 => ans_r2) |> simplify
eq14 = eq4(r1 => ans_r1, r2 => ans_r2) |> simplify
eq15 = eq5(r1 => ans_r1, r2 => ans_r2) |> simplify
res2 = solve([eq12, eq14, eq15], (r3, x3, y3))[1];

#= r3 =# res2[1] |> sympy.sqrtdenest |> simplify |> println

   r5*(sqrt(3) + 3)/2

#= x3 =# res2[2] |> sympy.sqrtdenest |> simplify |> println

   r5*(5*sqrt(3) + 9)/2

#= y3 =# res2[3] |> sympy.sqrtdenest |> simplify |> println

   2*sqrt(3)*r5 + 4*r5

丙円の半径 r3 は 戊円の半径 r5 の (√3 + 3)/2 倍である。
戊円の直径が 1 寸のとき,丙円の直径は 2.3660254037844384 寸である。

その他のパラメータは以下のとおりである。

  r5 = 0.5;  r1 = 3.23205;  r2 = 2.54904;  r3 = 1.18301;  x3 = 4.41506;  y3 = 3.73205

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r5 = 1/2
   (r1, r2, r3, x3, y3) = r5 .* (3 + 2√3, (5 + 3√3)/2, (√3 + 3)/2, (5√3 + 9)/2, 2√3 + 4)
   R = 2r1 + r5
   r4 = r1 - r2
   @printf("戊円の直径が %g のとき,丙円の直径は %g である。\n", 2r5, 2r3)
   @printf("r5 = %g;  r1 = %g;  r2 = %g;  r3 = %g;  x3 = %g;  y3 = %g\n", r5, r1, r2, r3, x3, y3)
   plot()
   circle(0, 0, R, :blue)
   circle22(0, R - r1, r1)
   circle2(R - r2, 0, r2, :green)
   circle4(x3, y3, r3, :orange)
   circle2(r5 + r4, 0, r4, :magenta)
   circle(0, 0, r5, :cyan4)
   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, R - r1, "甲円:r1,(0,R-r1)", :red, :center, delta=-delta/2)
       point(R - r2, 0, "乙円:r2,(R-r2,0)", :green, :center, delta=-delta/2)
       point(x3, y3, "丙円:r3\n(x3,y3)", :orange, :center, delta=-delta/2)
       point(r5 + r4, 0, "丁円:r4,(r5+r4,0)", :magenta, :left, :bottom, delta=delta)
       point(0, 0, "戊円:r4\n(0,0)", :cyan4, :center, delta=-3delta)
       point(R, 0, " R", :blue, :left, :bottom, delta=delta/2)
       point(0, R, " R", :blue, :left, :bottom, delta=delta/2)
   end
end;


コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« 算額(その1101) | トップ | 算額(その1103) »
最新の画像もっと見る

コメントを投稿

Julia」カテゴリの最新記事