裏 RjpWiki

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

算額(その461)

2023年10月13日 | Julia

算額(その461)

埼玉県秩父市大宮 秩父神社 明治20年(1887)

山口正義(2015): やまぶき, 第27号
https://yamabukiwasan.sakura.ne.jp/ymbk27.pdf

外円内に大円,中円,小円と弦が図のように配置されている。中円の直径が 3 寸のとき,小円の直径はいかほどか。

外円の半径と中心座標を r0, (0, 0)
大円の半径と中心座標を r1, (0, r1), (0, -r1)
中円の半径と中心座標を r2, (x2, y2)
小円の半径と中心座標を r3, (x31, 2r3), (x32, 0)
弦が y 軸と交わる y 座標は r3
として以下の連立方程式を解く。

なお,r2 が既知として方程式を解くと SymPy ではなぜか解が求まらない。
r2 を未知して,他の未知数も r0 により表せるとすれば解は求まる。
中円の直径が 3 寸のときの小円の直径は比例関係で求めることができる。

include("julia-source.txt")

using SymPy

@syms a::positive, r0::positive, r1::positive,
     r2::positive, x2::negative, y2::negative, r3::positive, x31::negative, x32::negative

r1 = r0//2
eq1 = x31^2 + (r1 - 2r3)^2 - (r1 + r3)^2 |> expand
eq2 = x31^2 + 4r3^2 - (r0 - r3)^2 |> expand
eq3 = x32^2 + r1^2 - (r1 + r3)^2 |> expand
eq4 = x2^2 + (r1 + y2)^2 - (r1 + r2)^2 |> expand
eq5 = (x2 - x32)^2 + y2^2 - (r2 + r3)^2 |> expand
eq6 = x2^2 + y2^2 - (r0 - r2)^2 |> expand;
res = solve([eq1, eq2, eq3, eq4, eq5, eq6], (r2, x2, y2, r3, x31, x32))

   1-element Vector{NTuple{6, Sym}}:
    (3*r0/14, -2*sqrt(6)*r0/7, -5*r0/14, r0/5, -2*sqrt(3)*r0/5, -sqrt(6)*r0/5)

r3/r2 = (1/5)/(3/14) = 14/15 なので, r3 = (14/15)r2 である。
r2 = 3/2 ならば r3 = 7/5 = 1.4。
中円の直径が 3 寸ならば,小円の直径は2寸8分である。

   r2 = 0.214286; x2 = -0.699854; y2 = -0.357143; r3 = 0.2; x31 = -0.69282; x32 = -0.489898
   r0 = 1 のとき,中円の直径 = 0.428571;  小円の直径 = 0.4
   r0 = 1 のとき,中円の直径 = 3//7;  小円の直径 = 2//5

using Plots

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r0 = 1
   r1 = r0//2
   (r2, x2, y2, r3, x31, x32) = (3*r0//14, -2*sqrt(6)*r0//7, -5*r0/14, r0//5, -2*sqrt(3)*r0//5, -sqrt(6)*r0//5)
   @printf("r2 = %g; x2 = %g; y2 = %g; r3 = %g; x31 = %g; x32 = %g\n", r2, x2, y2, r3, x31, x32)
   @printf("r0 = %g のとき,中円の直径 = %g;  小円の直径 = %g\n", r0, 2r2, 2r3)
   println("r0 = $r0 のとき,中円の直径 = $(2r2);  小円の直径 = $(2r3)")
   plot()
   circle(0, 0, r0, :black)
   circle(0, r1, r1)
   circle(0, -r1, r1)
   circle(x2, y2, r2, :blue)
   circle(-x2, y2, r2, :blue)
   circle(x31, 2r3, r3, :orange)
   circle(-x31, 2r3, r3, :orange)
   circle(x32, 0, r3, :orange)
   circle(-x32, 0, r3, :orange)
   segment(-sqrt(r0^2 - r3^2), r3, sqrt(r0^2 - r3^2), r3, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /  3  # size[2] * fontsize * 2
       point(0, r1, " 大円:r1,(0,r1)", :red, :left, :vcenter)
       point(x2, y2, "中円:r2\n(x2,y2)", :blue, :center, :bottom, delta=delta)
       point(x31, 2r3, "小円:r3\n(x31,2r3)", :black, :center, :top, delta=-delta)
       point(x32, 0, "小円:r3\n(x32,0)", :black, :center, :top, delta=-delta)
       point(0, r3, " r3", :green, :left, :top)
       hline!([0], color=:gray, lw=0.5)
       vline!([0], color=:gray, lw=0.5)
   else
      plot!(showaxis=false)
   end
end;

コメント
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする

PVアクセスランキング にほんブログ村

PVアクセスランキング にほんブログ村