裏 RjpWiki

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

算額(その691)

2024年02月10日 | Julia

算額(その691)

神壁算法 東都本郷春木町一丁目 佐野富次郎安行 天明七年
藤田貞資(1789):神壁算法巻上

http://www.wasan.jp/jinpeki/jinpekisanpo1.pdf

楕円の中に大円 2 個,中円 2 個,小円 1 個が入っている。
楕円の長径,短径がそれぞれ 2168 寸,1084 寸のとき,大円の直径はいかほどか。

楕円の長半径と短半径を a, b
大円の半径と中心座標を r1, (x1, 0); x1 = r1 + r3
中円の半径と中心座標を r2, (0, b - r2)
小円の半径と中心座標を r3, (0, 0)
楕円と大円の共通接点の座標を (x0, y0)
とおき,以下の連立方程式を解く。

include("julia-source.txt");
# julia-source.txt ソース https://blog.goo.ne.jp/r-de-r/e/ad3a427b84bb416c4f5b73089ae813cf

using SymPy

@syms a::positive, b::positive, x0::positive, y0::positive,
     r1::positive, x1::positive,r2::positive, r3::positive
(a, b) = (2168, 1084) .// 2
x1 = r1 + r3
eq1 = (x0 - x1)^2 + y0^2 - r1^2
eq2 = -b^2*x0/(a^2*y0) - (x1 - x0)/y0
eq3 = x0^2/a^2 + y0^2/b^2 - 1
eq4 = r3 + 2r2 - b
eq5 = x1^2 + (b - r2)^2 - (r1 + r2)^2
res = solve([eq1, eq2, eq3, eq4, eq5], (x0, y0, r1, r2, r3))

   1-element Vector{NTuple{5, Sym}}:
    (-1626/7 + 2710*sqrt(57)/21, sqrt(6315926/147 + 734410*sqrt(57)/49), 271*sqrt(57)/14 + 4065/14, 3523/7 - 271*sqrt(57)/7, -3252/7 + 542*sqrt(57)/7)

大円の直径は (271√57 + 4065)/7 = 873.000733136910 寸である。
ちなみに,中円,小円の直径はそれぞれ 421.998533726179 寸,240.002932547642 寸である。

res[1][3].evalf()*2 |> println
res[1][4].evalf()*2 |> println
res[1][5].evalf()*2 |> println

   873.000733136910
   421.998533726179
   240.002932547642

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, b) = (2168, 1084) .// 2
   (x0, y0, r1, r2, r3) = (-1626/7 + 2710*sqrt(57)/21, sqrt(6315926/147 + 734410*sqrt(57)/49), 271*sqrt(57)/14 + 4065/14, 3523/7 - 271*sqrt(57)/7, -3252/7 + 542*sqrt(57)/7)
   x1 = r1 + r3
   plot()
   ellipse(0, 0, a, b, color=:orange)
   circle(x1, 0, r1)
   circle(-x1, 0, r1)
   circle(0, 0, r3, :green)
   circle(0, b - r2, r2, :blue)
   circle(0, r2 - b, r2, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
       point(a, 0, " a", :black, :left, :bottom, delta=delta)
       point(0, b, " b", :black, :left, :bottom, delta=delta)
       point(x0, y0, "(x0,y0)", :red, :left, :bottom, delta=delta)
       point(x1, 0, "大円:r1,(x1,y1)", :red, :center, delta=-delta)
       point(0, b - r2, " 中円:r2,(0,b-r2)", :black, :left, :vcenter)
       point(0, r3, " r3", :black, :left, :bottom, delta=delta)
       point(0, r3, " 小円", :black, :left, :top, delta=-delta)
   end
end;

 


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

コメントを投稿

Julia」カテゴリの最新記事