裏 RjpWiki

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

算額(その180)

2023年03月27日 | Julia

算額(その180)

中村信弥「改訂増補 長野県の算額」
http://www.wasan.jp/zoho/zoho.html
県内の算額1(56)
長野県長野市元善町 善光寺 寛政8年(1796)

第6問: 長方形内に 8 個の円を入れる。甲円の径が 17寸7分4厘 のとき,丙円の径を求めよ。

甲円の径を 100 倍して整数で取り扱う。長方形の長辺を 2x,甲円の半径は 887,乙円の半径を r1, 丙円の半径を r2 とする。以下のように連立方程式を立て,解く。

using SymPy
@syms x::positive, r2::positive, r1::positive

eq1 = (x - 887)^2 + (887 - r1)^2 - (r1 + 887)^2
eq2 = (x - 887 - r2)^2 + 887^2 - (887 + r2)^2
eq3 = r2^2 + (1774 - r1)^2 - (r1 + r2)^2
res = solve([eq1, eq2, eq3], (x, r1, r2))

   2-element Vector{Tuple{Sym, Sym, Sym}}:
    (-887*sqrt(5 + 4*sqrt(2)) + 887*sqrt(2) + 887*sqrt(10 + 8*sqrt(2)), -887*sqrt(10 + 8*sqrt(2)) + 887/2 + 2661*sqrt(5 + 4*sqrt(2))/2, -887*sqrt(5 + 4*sqrt(2)) + 887 + 1774*sqrt(2))
    (-887*sqrt(10 + 8*sqrt(2)) + 887*sqrt(2) + 887*sqrt(5 + 4*sqrt(2)), -2661*sqrt(5 + 4*sqrt(2))/2 + 887/2 + 887*sqrt(10 + 8*sqrt(2)), 887 + 1774*sqrt(2) + 887*sqrt(5 + 4*sqrt(2)))

最初の組の解が適解である。
丙円の半径 r2 は -887*sqrt(5 + 4*sqrt(2)) + 887 + 1774*sqrt(2)

直径は

2(-887*sqrt(5 + 4*sqrt(2)) + 887 + 1774*sqrt(2))

   1000.4355208571196

元の単位でいえば「10寸0分0厘あまりあり」ということである。

using Plots

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.25)
   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(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (x, r1, r2) = res[1]
   println("丙円の径 = $(2r2) = $(2r2.evalf())")
   println("乙円の径 = $(2r1) = $(2r1.evalf())")
   println("長方形の長辺 = $(2x) = $(2x.evalf())")
   plot([x, x, -x, -x, x], [-1774, 1774, 1774, -1774, -1774], color=:black, lw=0.5)
   circle(x - 887, 887, 887)
   circle(x - 887, -887, 887)
   circle(-x + 887, 887, 887)
   circle(-x + 887, -887, 887)
   circle(0, 1774 - r1, r1, :blue)
   circle(0, -1774 + r1, r1, :blue)
   circle(r2, 0, r2, :orange)
   circle(-r2, 0, r2, :orange)
   if more == true
       point(x - 887, 887, "甲円 (x-887,887)", :green, :top)
       point(0, 1774 - r1, " 1774-r1")
       point(200, 1300, "乙円", mark=false)
       point(r2, 0, " r2")
       point(r2, 300, "丙円", mark=false)
       point(x, 0, " x")
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
      plot!(showaxis=false)
   end
end;

draw(false)

   丙円の径 = -1774*sqrt(5 + 4*sqrt(2)) + 1774 + 3548*sqrt(2) = 1000.43552085712
   乙円の径 = -1774*sqrt(10 + 8*sqrt(2)) + 887 + 2661*sqrt(5 + 4*sqrt(2)) = 1383.80591988999
   長方形の長辺 = -1774*sqrt(5 + 4*sqrt(2)) + 1774*sqrt(2) + 1774*sqrt(10 + 8*sqrt(2)) = 4907.60603898119


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

コメントを投稿

Julia」カテゴリの最新記事