裏 RjpWiki

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

算額(その96)

2023年01月11日 | Julia

算額(その96)

東京都台東区下谷池端 東淵寺 明治2年(1869)
http://www.wasan.jp/tokyo/tobuti.html

大円2個,地円3個,人円3個が図のように配置されている。大円の径が 34 寸のとき,人円の径はいくつか。

大円の半径を 34 とし,図のように地円,人円の半径を r2, r3,人円の中心座標を (x, y) として方程式を解く。

using SymPy

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

r1 = 34
eq1 = x^2+ (y-2r2-r3)^2 - (r1+r3)^2 |> expand;
eq2 = (2r2 - x)^2 + (y - r2)^2 - (r1 + r2)^2 |> expand;
eq3 = r2^2 + (r2 - r3)^2 - (r2 + r3)^2 |> expand;
eq4 = x^2 + (y - r2)^2 - (r1 + r2)^2 |> expand;
a = solve([eq1, eq2, eq3, eq4], (r2, r3, x, y))

   1-element Vector{NTuple{4, Sym}}:
    (-68*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 136*sqrt(5)/5 + 408/5, -17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5, -68*sqrt(10*sqrt(5) + 30)/5 + 136*sqrt(5)/5 + 408/5, 238/5 + 136*sqrt(5)/5)

人円の半径は 11.002631123499281 である。

-17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5

   11.002631123499281

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")
   r1 = 34
   (r2, r3, x, y) = (-68*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 136*sqrt(5)/5 + 408/5, -17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5, -68*sqrt(10*sqrt(5) + 30)/5 + 136*sqrt(5)/5 + 408/5, 238/5 + 136*sqrt(5)/5)
   println("地 = $r2, 人 = $r3, x = $x, y= $y")
   plot()
   circle(x, y, r1, :red)
   circle(-x, y, r1, :red)
   circle(0, 2r2 + r3, r3, :blue)
   circle(r2, r3, r3, :blue)
   circle(-r2, r3, r3, :blue)
   circle(0, r2, r2, :magenta)
   circle(2r2, r2, r2, :magenta)
   circle(-2r2, r2, r2, :magenta)
   hline!([0], color=:black, lw=0.5)
   if more
       point(0, r2, "r2 ", :magenta, :right)
       point(x, y, "(x,y)", :red, :top)
       point(r2, r3, "(r2,r3)", :blue, :top)
       vline!([0], color=:black, lw=0.5)
   end
end;

   地 = 44.010524493997124, 人 = 11.002631123499281, x = 44.010524493997124, y= 108.42104898799428

 


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

コメントを投稿

Julia」カテゴリの最新記事