裏 RjpWiki

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

算額(その62)

2022年12月16日 | Julia

算額(その62)

長野市篠ノ井 布制神社 文化3年(1806)
http://www.wasan.jp/nagano/fuse.html

玄が12寸,甲円の径が2寸5分のとき丙円の径を求めよ。

玄を 240,甲円の半径を 25 とし,図のように記号を定め,方程式を解く。

using SymPy
@syms x1::positive, r1::positive, x2::positive, r2::positive, y0::negative, r0::positive;
eq1 = x1^2 + (25 - r1)^2 - (25 + r1)^2;
eq2 = x2^2 + (25 - r2)^2 - (25 + r2)^2;
eq3 = (x1 - x2)^2 + (r1 - r2)^2 - (r1 + r2)^2;
eq4 = y0^2 + 120^2 - r0^2;
eq5 = x1^2 + (r1 - y0)^2 - (r0 - r1)^2;
eq6 = 50 - y0 - r0;

res = solve([eq1, eq2, eq3, eq4, eq5, eq6], (x1, r1, x2, r2, y0, r0))

   2-element Vector{NTuple{6, Sym}}:
    (600/13, 3600/169, 24, 144/25, -119, 169)
    (600/13, 3600/169, 600, 3600, -119, 169)

丙円の半径は算額では 5分7厘5毛となっているが,正しくは 5分7厘6毛(5.76)となる。

また,算額の各円の見かけの大きさは,計算結果とはかなり異なっている。

using Plots

function circle(ox, oy, r, color=:red; beginangle=0, endangle=360)
   θ = beginangle:0.1:endangle
   x = r.*cosd.(θ)
   y = r.*sind.(θ)
   plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
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=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   plot()
   (x1, r1, x2, r2, y0, r0) = (600/13, 3600/169, 24, 144/25, -119, 169)
   println("x1 = $x1, r1 = $r1\nx2 = $x2, r2 = $r2\ny0 = $y0, r0 = $r0")
   circle(0, y0, r0, :black)
   circle(0, 25, 25)
   circle(x1, r1, r1, :brown)
   circle(-x1, r1, r1, :brown)
   circle(x2, r2, r2, :green)
   plot!([-120, 120], [0, 0], color=:black, lw=0.5)
   if more
       point(0, 0, "0 ", :black, :right)
       point(0, 25, "25 ", :black, :right)
       point(120, 0, " 120", :black)
       point(x1, r1, "(x1,r1)", :brown, :center)
       point(x2, r2, "\n    (x2,r2)", :green, :center)
       point(0, y0, "y0 ", :blue, :right)
       vline!([0], color=:black, lw=0.5)
   end
end;

   x1 = 46.15384615384615, r1 = 21.301775147928993
   x2 = 24, r2 = 5.76
   y0 = -119, r0 = 169


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

コメントを投稿

Julia」カテゴリの最新記事