裏 RjpWiki

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

算額(その39)

2022年11月25日 | Julia

算額(その39)

香川県三豊市豊中町 本山寺 万延元年
http://www.wasan.jp/kagawa/honzanji1.html

外円の中に 4 種類の円が収まっている。青,白の円の径はそれぞれ 69 寸,15 寸である。外円の径を求めよ。



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

using SymPy
@syms r0::positive, r1::positive, r2::positive, r3::positive, r4::positive,
     x3::positive, y3::positive, x4::positive, y4::positive;

r1 = 69
r4 = 15
eq1 = x3^2 + (2r0-r1-y3)^2 - (r1+r3)^2
eq2 = x3^2 + (r0-y3)^2 - (r0-r3)^2
eq3 = x4^2 + (r0-y4)^2 - (r0-r4)^2
eq4 = x3^2 + (y3-r2)^2 - (r2+r3)^2
eq5 = x4^2 + (r2-y4)^2 - (r2+r4)^2
eq6 = (x3-x4)^2 + (y3-y4)^2 - (r3+r4)^2
eq7 = r1 + r2 - r0;

res = solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], (r0, r2, r3, x3, y3, x4, y4));

name = ["r0", "r2", "r3", "x3", "y3", "x4", "y4"]
for i in 1:7
   println("$(name[i]) = $(res[1][i])")
end

   r0 = 115
   r2 = 46
   r3 = 690/19
   x3 = 1380/19
   y3 = 1610/19
   x4 = 60
   y4 = 35

求める外円の径 r0 は 115 である。

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)
   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")
   r1 = 69
   r2 = 15
   (r0, r2, r3, x3, y3, x4, y4) = (115, 46, 690/19, 1380/19, 1610/19, 60, 35)
   println("r0 = $r0,  r1 = $r1,  r2 = $r2,  r3 = $r3,  r4 = $r4")
   println("x3 = $x3,  y3 = $y3,  x4 = $x4,  y4 = $y4")
   plot()
   circle(0, r2, r2, :red)
   circle(0, 2r0-r1, r1, :blue)
   circle(0, r0, r0, :black)
   circle(x3, y3, r3, :brown)
   circle(-x3, y3, r3, :brown)
   circle(x4, y4, r4, :magenta)
   circle(-x4, y4, r4, :magenta)
   if more
       point(0, 2r0-r1, "2r0-r1 ", :blue, :right)
       point(0, r0, "r0 ", :black, :right)
       point(0, r2, "r2 ", :red, :right)
       point(x3, y3, "(x3,y3),r3", :brown, :center)
       point(x4, y4, "(x4,y4),r4", :magenta, :center)
       vline!([0], color=:black, linewidth=0.25)
       hline!([0], color=:black, linewidth=0.25)
   end
end;


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

コメントを投稿

Julia」カテゴリの最新記事