裏 RjpWiki

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

算額(その65)

2022年12月16日 | Julia

算額(その65)

長野県木曽郡上松町寝覚 臨川寺弁財天社 文政13年
http://www.wasan.jp/nagano/rinsenji.html

3 個の甲円が交差している部分に内接する乙円の径を求めよ。

甲円の半径を 1 として,図のように記号を定め,方程式を解く。
x, y は簡単に決められる。方程式は,甲円と乙円が内接することに基づく。

using SymPy
@syms x::positive, y::positive, r::positive;
x = sqrt(Sym(3))/4
y = 1//4
eq = x^2 + (1 - y)^2 - (1 - r)^2;

res = solve(eq) |> println

   Sym[1 - sqrt(3)/2, sqrt(3)/2 + 1]

解は 2 つ得られるが,1 - sqrt(3)/2 = 0.1339745962155614 が適切な解である。

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; mark=true)
   mark && 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")
   plot()
   r = 1 - sqrt(3)/2
   println("r = $r")
   circle(0, 1, 1, :green)
   circle(cos(pi/6), -sin(pi/6), 1, :green)
   circle(-cos(pi/6), -sin(pi/6), 1, :green)
   circle(x, y, r)
   circle(-x, y, r)
   circle(0, -1/2, r)
   if more
       point(x, y, "(x,y)", :red, :center)
       point(0, 1, "1 ", :green, :right)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   end
end;

   r = 0.1339745962155614


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

コメントを投稿

Julia」カテゴリの最新記事