裏 RjpWiki

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

算額(その84)

2022年12月29日 | Julia

算額(その84)

福島県田村郡三春町平沢担橋 諏訪神社 大正15年(1926)8月
http://www.wasan.jp/fukusima/miharusuwa.html

二本の線分に挟まれて,3個の円がある。大円,中円の径を 4, 2 としたとき,小円の径を求めよ。

大円,中円の半径を 2, 1 として,図のよう記号を定め方程式を解く。

using SymPy

@syms x1::positive, r1::positive, x2::positive, x3::positive;
eq1 = (x2 - x1)^2 + (1 - r1)^2 - (1 + r1)^2
eq2 = (x3 - x2)^2 + (2 - 1)^2 - (2 + 1)^2
eq3 = (2 - r1)/(x3 - x1) - (1 - r1)/(x2 - x1)
eq4 = r1/x1 - 1/x2
solve([eq1, eq2, eq3, eq4], (r1, x1, x2, x3))

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

小円の径は 1 である。

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, x1, x2, x3) = (1/2, sqrt(2), 2*sqrt(2), 4*sqrt(2))
   println("小円の径(直径) = $(2r1)")
   plot()
   circle(x1, r1, r1)
   circle(x2, 1, 1, :blue)
   circle(x3, 2, 2, :green)
   hline!([0], color=:black, lw=0.5)
   θ = atan(2, x3)
   y = 6tan(2θ)
   plot!([0, 6], [0, y], color=:black, lw=0.5)
   if more
       point(x1, r1, "(x1,r1)", :red, :top, :center)
       point(x2, 1, "(x2,2)", :blue, :top, :center)
       point(x3, 2, "(x3,4)", :green, :top, :center)
       point(6, y, "(6, y)", :black)
   end
end;

   小円の径(直径) = 1.0


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

コメントを投稿

Julia」カテゴリの最新記事