裏 RjpWiki

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

算額(その281)

2023年06月15日 | Julia

算額(その281)

中村信弥「改訂増補 長野県の算額」
http://www.wasan.jp/zoho/zoho.html
県内の算額(240)
長野県松本市筑摩 筑摩神社 明治6年(1873)

等脚台形に対角線を引き,時計回りに 90° 回転させ上半分だけを考える。対角線で区切られた2つの区域に対角線及び辺に接する等円を入れる。元の台形の高さ a を 12 寸,等円の径 r を 4 寸とするとき,元の台形の底辺の半分 b はいかほどか。

図のように記号を定め,連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms r::positive, a::positive, b::positive, c::positive, d::positive, y1::positive, dummy;
(r, a) = (2, 12)
eq1 = distance(0, 0, a, c, r, y1) - r^2
eq2 = distance(0, 0, a, c, a - r, r) - r^2
eq3 = distance(0, b, d, 0, r, y1) - r^2
eq4 = distance(0, b, d, 0, a - r, r) - r^2;

res = solve([eq1, eq2, eq3, eq4], (b, c, d, y1))

   3-element Vector{NTuple{4, Sym}}:
    (7, 5, 28/3, 3)
    (13/4 - sqrt(65)/4, 5, 26 - 2*sqrt(65), 3)
    (sqrt(65)/4 + 13/4, 5, 2*sqrt(65) + 26, 3)

最初の組が適解である。したがって,元の台形の底辺の半分は 7 寸である。

using Plots

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (b, c, d, y1) = res[1]
   @printf("b = %.6f;  c = %.6f;  d = %.6f;  y1 = %.6f\n", b, c, d, y1)
   # @printf("2r = %.6f\n", 2r)
   plot([0, a, a, 0, 0], [0, 0, c, b, 0], color=:black, lw=0.5)
   segment(0, 0, a, c)
   segment(0, b, d, 0)
   circle(r, y1, r, :blue)
   circle(a - r, r, r, :blue)
   if more
       point(r, y1, " (r,y1)")
       point(a - r, r, " (a-r,r)")
       point(a, 0, " a", :green, :left, :bottom)
       point(0, b, " b", :green, :left, :bottom)
       point(a, c, " (a,c)")
       point(d, 0, "  d", :green, :left, :bottom)
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;


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

コメントを投稿

Julia」カテゴリの最新記事