裏 RjpWiki

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

算額(その229)

2023年05月13日 | Julia

算額(その229)

京都府京都市上京区 北野天満宮 明治12年(1879)
http://www.wasan.jp/kyoto/kitano2.html

北野天満宮の算額について,永井信一
http://www2.ttcn.ne.jp/~nagai/waseda/wasan/kitano.pdf

藤田貞資:精要算法(下巻),天明元年(1781)
http://www.wasan.jp/seiyou/seiyou.html

二等辺三角形(2つの等辺(上斜)の長さは 1014寸,底辺(下斜)の長さは 1428寸)の中に甲円が 2 個,乙円,丙円が 1 個ずつ入っている。それぞれの径を求めよ。

算額(その110)https://blog.goo.ne.jp/r-de-r/e/f9651e4698b7baef75c28a0647b16424 の愛媛県松山市の伊佐爾波神社の算額では「三角」とあり正三角形であるが,ここでは「圭」なので,二等辺三角形である。

算額(その2031)は甲円の直径のみ求めよとなっている。

甲円の半径,中心座標を r1, (x1, r1)
乙円の半径,中心座標を r2, (0, r3 + r2)
丙円の半径,中心座標を r3, (0, r3)
とおき,以下の方程式を解く。
なお,ピタゴラスの定理から,二等辺三角形の高さは sqrt(1014^2 - 714^2) = 720 である。

using SymPy

function distance(x1, y1, x2, y2, x0, y0)
   p1, p2 = sympy.Point(x1, y1), sympy.Point(x2, y2)
   l = sympy.Line(p1, p2)
   l.distance(sympy.Point(x0, y0))^2  # 二乗距離を返す!!
end;

@syms r1::positive, r2::positive, r3::positive, x1::positive;
eq1 = x1^2 + (2r3 + r2 - r1)^2 - (r1 + r2)^2
eq2 = x1^2 + (r1 - r3)^2 - (r1 + r3)^2
eq3 = distance(0, 720, 714, 0, 0, 2r3 + r2) - r2^2  # 上斜への二乗距離
eq4 = distance(0, 720, 714, 0, x1, r1) - r1^2  # 上斜への二乗距離

res = solve([eq1, eq2, eq3, eq4], (r1, r2, r3, x1))

   3-element Vector{NTuple{4, Sym}}:
    (357/2, 15232/75, 2856/25, 1428/5)
    (1447992/1315 + 205632*sqrt(61)/1315, 723996/1315 - 84966*sqrt(61)/1315, -402696/1315 + 102816*sqrt(61)/1315, 17136*sqrt(61)/263 + 308448/263)
    (111384/55 + 34272*sqrt(14)/55, -414596/275 + 113288*sqrt(14)/275, 476/11 + 952*sqrt(14)/11, 2856*sqrt(14)/11 + 17136/11)

2 番めの解が妥当なものである。すなわち甲円,乙円,丙円の直径はそれぞれ 357 寸, 30464/75 寸, 5712/25 寸 である。

   r1 = 178.5000000;  r2 = 203.0933333;  r3 = 114.2400000;  x1 = 285.6000000
   甲円径 = 357.0000000,  乙円径 = 406.1866667;  丙円径 = 228.4800000

using Plots
using Printf

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)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r1, r2, r3, x1) = res[1]
   @printf("r1 = %.7f,  r2 = %.7f;  r3 = %.7f;  x1 = %.7f\n", r1, r2, r3, x1)
   @printf("甲円径 = %.7f,  乙円径 = %.7f;  丙円径 = %.7f\n", 2r1, 2r2, 2r3)
   plot([714, 0, -714, 714], [0, 720, 0, 0], color=:blue, lw=0.5)
   circle(0, 2r3 + r2, r2, :green)
   circle(0, r3, r3, :gold)
   circle(x1, r1, r1)
   circle(-x1, r1, r1)
   if more == true
       point(0, 720, " 720", :blue, :left, :bottom)
       point(714, 0, "714", :blue, :left, :bottom)
       point(0, 2r3 + r2, " 2r3+r2", :red)
       point(0, r3, " r3", :red)
       point(x1, r1, "(x1,r1)", :red)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;


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

コメントを投稿

Julia」カテゴリの最新記事