裏 RjpWiki

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

算額(その360)

2023年08月03日 | Julia

算額(その360)

山形県山形市鉄砲町 竜宝院勢至堂
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

二等辺三角形と甲円 2 個,乙円 2 個がある。甲円の直径が 6 寸のとき,乙円の直径はいくつか。

甲円の直径,中心座標を r1, (0, r1) および (0, 3r1)
乙円の直径,中心座標を r2, (x,y)
として,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive, x::positive, y::positive, a::positive;

eq1 = x^2 + (y - 3r1)^2 - (r1 - r2)^2
eq2 = a^2 + (4r1)^2 - (3a)^2
eq3 = 3(r1 - 2r2) - r1
eq4 = 4r1*(y - 3r1) - a*x
res = solve([eq1, eq2, eq3, eq4], (r2, a, x, y))

   1-element Vector{NTuple{4, Sym}}:
    (r1/3, sqrt(2)*r1, 4*sqrt(2)*r1/9, 29*r1/9)

乙円の半径は甲円の半径の 1/3 である。よって,甲円の直径が 6 寸なら,乙円の直径は 2 寸である。

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 6//2
   (r2, a, x, y) = (r1/3, sqrt(2)*r1, 4*sqrt(2)*r1/9, 29*r1/9)
   @printf("r2 = %g;  a = %g;  x = %g;  y = %g\n", r2, a, x, y)
   @printf("甲円の直径が %g 寸のとき,乙円の直径は %g 寸\n", 2r1, 2r2)
   plot([a, 0, -a, a], [0, 4r1, 0, 0], color=:black, lw=0.5)
   circle(0, r1, r1)
   circle(0, 3r1, r1)
   circle(x, y, r2, :blue)
   circle(-x, y, r2, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, 4r1, " 4r1", :red, :left, :bottom, delta=delta/2)
       point(0, 3r1, " 3r1", :red, :left, :vcenter)
       point(0, 2r1, " 2r1", :red, :left, :bottom, delta=delta/2)
       point(0, r1, " r1  甲円", :red, :left, :vcenter)
       point(x, y, "乙円:r2\n(x,y)", :blue, :center, delta=-delta/2)
       point(a, 0, "a ", :black, :right, :bottom, delta=delta/2)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;


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

コメントを投稿

Julia」カテゴリの最新記事