裏 RjpWiki

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

算額(その595)

2023年12月28日 | Julia

算額(その595)

長崎市 鎮西大社諏訪神社 明治20年(1887)
米光丁: 長崎県の和算の概説

http://hyonemitsu.web.fc2.com/Nagasakiwasan.pdf

問題 20. 外円の中に正六角形を入れる。正六角形の矢の長さが 24 寸,内側の正六角形の一辺の長さが 15 寸のとき,外円の直径はいかほどか。

内側の正六角形の一辺の長さを r とする。
点A(x,y) は内側の正六角形が内接する半径 R 円周上にある。図の AB は正六角形の矢,AR は矢の長さから内側の正六角形の一辺の長さを差し引いたものになっている。三角形 ABR において第二余弦定理を適用する。

include("julia-source.txt");

using SymPy

@syms R::positive, 矢::positive, r::positive, a::positive, b::positive,
     x::positive, y::negative

r = 15
矢 = 24
a = 矢
b = sqrt((R - x)^2 + y^2);

eq1 = a^2 + b^2 - a*b - R^2
eq2 = b + r - 矢
eq3 = x^2 + y^2 - r^2

res = solve([eq1, eq2, eq3], (x, y, R))

   1-element Vector{Tuple{Sym, Sym, Sym}}:
    (195/14, -45*sqrt(3)/14, 21)

外円の半径は 21 である。

上の連立方程式において,「r」, 「矢」 を変数のままで,[eq1, eq2] から (x, R) で解くと以下のようになる。

@syms R::positive, 矢::positive, r::positive, a::positive, b::positive,
     x::positive, y::negative

a = 矢
b = sqrt((R - x)^2 + y^2);

eq1 = a^2 + b^2 - a*b - R^2
eq2 = b + r - 矢

res = solve([eq1, eq2], (x, R))

   2-element Vector{Tuple{Sym, Sym}}:
    (-sqrt(-(-r + y + 矢)*(r + y - 矢)) + sqrt(r^2 - 2*r*矢 + 2*矢^2 - 矢*sqrt(r^2 - 2*r*矢 + 矢^2)), sqrt(r^2 - 2*r*矢 + 2*矢^2 - 矢*sqrt(r^2 - 2*r*矢 + 矢^2)))
    (sqrt(-(-r + y + 矢)*(r + y - 矢)) + sqrt(r^2 - 2*r*矢 + 2*矢^2 - 矢*sqrt(r^2 - 2*r*矢 + 矢^2)), sqrt(r^2 - 2*r*矢 + 2*矢^2 - 矢*sqrt(r^2 - 2*r*矢 + 矢^2)))

2組の解が得られる。x の式は y も未知数として含むが,R の式はどちらも同じ式になり,「r」 と 「矢」のみからなる。
SymPy では簡約化できないが手動で以下のように簡約化できる。

外円の半径は得られた式を簡約化して,sqrt(r^2 - r*矢 + 矢^2) である。

R = sqrt(r^2 - r*矢 + 矢^2)
R(r => 15, 矢 => 24).evalf() |> println

   21.0000000000000

正六角形の矢の長さが 24 寸,内側の正六角形の一辺の長さが 15 寸のとき,外円の直径は 42 寸である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = 15
   矢 = 24
   (x, y, R) =  (195/14, -45*sqrt(3)/14, 21)
   θ = atand(y, x)
   n = 7
   outerx = Vector{Float64}(undef, n)
   outery = Vector{Float64}(undef, n)
   innerx = Vector{Float64}(undef, n)
   innery = Vector{Float64}(undef, n)
   plot()
   for i in 1:n
       outerx[i] = cosd((i - 1)*60)*R
       outery[i] = sind((i - 1)*60)*R
       innerx[i] = cosd((i - 1)*60 + θ)*r
       innery[i] = sind((i - 1)*60 + θ)*r
   end
   circle(0, 0, R)
   circle(0, 0, r, :gray90)
   plot!(outerx, outery, color=:blue, lw=0.5)
   for i in 2:7
       segment(outerx[i], outery[i], innerx[i-1], innery[i-1], :green)
   end
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
       point(R, 0, " R(R,0)", :blue, :left, :bottom, delta=delta/2)
       point(r, 0, " r", :magenta, :left, :bottom, delta=delta/2)
       point(x, y, "A(x,y)  ", :green, :right, :vcenter)
       point(innerx[1], innery[1], "A(x,y)  ", :green, :right, :vcenter)
       point(outerx[2], outery[2], "B(R*cos(π/3),R*sin(π/3)", :blue, :center, :bottom, delta=delta)
   end
end;


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

コメントを投稿

Julia」カテゴリの最新記事