裏 RjpWiki

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

算額(その2115)

2024年09月25日 | Julia

算額(その2115)

百四十三 群馬県榛名町榛名山 榛名神社 明治33年(1900)
群馬県和算研究会:群馬の算額,上武印刷株式会社,高崎市,1987年3月31日.
キーワード:円15個,外円,菱形3個
#Julia, #SymPy, #算額, #和算

外円の中に菱形 3 個,等円 4 個を容れる。等円の直径が 1 寸のとき,外円の直径はいかほどか。

外円の半径と中心座標を R, (0, 0)
等円の半径と中心座標を r, (x, y)
菱形の頂点と円の接点座標を (x0, y0)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive, x::positive,
     y::positive, x0::positive, y0::positive;
y0 = sqrt(R^2 - x0^2)
eq1 = x^2 + y^2 - (R - r)^2
eq2 = dist2(-R, 0, x0, y0, x, y, r)
eq3 = y /R - (R - y0)/y0
eq4 = 2y0 - y - R;

eq1, eq3, eq4 を連立させて解き,x, y, x0 を求める。

res = solve([eq1, eq3, eq4], (x, y, x0))[1]

   (sqrt(-(sqrt(2)*R - r)*(-2*R + sqrt(2)*R + r)), R*(-1 + sqrt(2)), sqrt(2)*R/2)

eq2 の x, y, x0 に代入し,simplify する。

eq12 = eq2(x => res[1], y => res[2], x0 => res[3]) |> simplify
eq12 |> println

   -2*R^2 + 3*sqrt(2)*R^2/2 - R*r + sqrt(2)*R*r/2 - r^2/2 - sqrt(2)*r^2/4

R について解く。

ans_R = solve(eq12, R)[1] |> factor |> println

   r*(4 + 3*sqrt(2))/2

外円の半径 R は,等円の半径 r の (4 + 3√2)/2 倍である。
等円の直径が 1 寸のとき,外円の直径は (4 + 3√2)/2 = 4.121320343559643 寸である。

function draw(r, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = r*(4 + 3*sqrt(2))/2
   (x, y, x0) = (sqrt(-(sqrt(2)*R - r)*(-2*R + sqrt(2)*R + r)), R*(-1 + sqrt(2)), sqrt(2)*R/2)
   y0 = sqrt(R^2 - x0^2)
   plot([0, x0, -R, x0, 0, -x0, R, -x0, 0],
        [R, y0, 0, -y0, -R, -y0, 0, y0, R], color=:green, lw=0.5)
   circle(0, 0, R)
   circle4(x, y, r, :blue)
   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, "R", :red, :center, :bottom, delta=delta/2)
       point(x0, y0, " (x0,y0)", :green, :left, :vcenter)
       point(x, y, "等円:r,(x,y)", :blue, :center, delta=-delta/2)
   end
end;

draw(1/2, true)


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

コメントを投稿

Julia」カテゴリの最新記事