裏 RjpWiki

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

算額(その83)

2022年12月29日 | Julia

算額(その83)

福島県田村郡三春町平沢担橋 諏訪神社 大正15年(1926)8月
http://www.wasan.jp/fukusima/miharusuwa.html

股が六寸の直角三角形に円が 6 個収まっている。鉤の長さはいくつか。

等円の半径を r, 鉤を x とする。上の円と右の円の中心から弦への距離が r であるとして方程式を解く。

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))
end;

@syms x::positive, r::positive;
eq1 = distance(6, 0, 0, x, 7r, r) - r
eq2 = distance(6, 0, 0, x, r, 5r) - r 
solve([eq1, eq2], (r, x))

   4-element Vector{Tuple{Sym, Sym}}:
    (17/23 - sqrt(13)/23, 4)
    (sqrt(13)/23 + 17/23, 4)
    (-75*sqrt(2)*sqrt(14 - 3*sqrt(3))/2068 - 9*sqrt(6)*sqrt(14 - 3*sqrt(3))/1034 - 75*sqrt(3)/2068 + 1497/2068, 9/2 - 3*sqrt(3)/2)
    (-9*sqrt(6)*sqrt(3*sqrt(3) + 14)/1034 + 75*sqrt(3)/2068 + 75*sqrt(2)*sqrt(3*sqrt(3) + 14)/2068 + 1497/2068, 3*sqrt(3)/2 + 9/2)

2番目が適切な解である。鉤は 4 寸である。

(sqrt(13)/23 + 17/23, 4)  # r, x

   (0.8958935337158256, 4)

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; fontsize=10, mark=true)
  mark && scatter!([x], [y], color=color, markerstrokewidth=0)
  annotate!(x, y, text(string, fontsize, vertical, position, color))
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r, x) = (17/23 - sqrt(13)/23, 4)
   println("径(直径) = $(2r);  鉤 = $x")
   plot([0, 6, 0, 0], [0, 0, x, 0])
   for i in 0:3
       circle(i*2r + r, r, r)
   end
   for i in 0:2
       circle(r, i*2r + r, r)
   end
   point(r, 5r, "(r,5r)")
   point(7r, r, "(7r,r)")
   point(0, x, "   x", :green, :bottom)
   hline!([0, 2r, 4r, 6r], color=:black, lw=0.5)
   vline!([0, 2r, 4r, 6r, 8r], color=:black, lw=0.5)
end;

   径(直径) = 1.1647346716987834;  鉤 = 4

 


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

コメントを投稿

Julia」カテゴリの最新記事