裏 RjpWiki

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

算額(その410)

2023年09月01日 | Julia

算額(その410)

会田安明(1811):「算法天生法指南」

永井信一:「アルベロスに関連した問題」
http://www2.ttcn.ne.jp/~nagai/waseda/wasan/arbe.pdf

円内に4個の円を入れる。甲円,乙円の直径がそれぞれ 14 寸,7 寸のとき,丙円の直径はいかほどか。

外円の中心を原点に置く。
外円の半径と中心座標を r0, (0, 0)
甲円の半径と中心座標を r1, (0, r1 - r0)
乙円の半径と中心座標を r2, (0, r0 - r2)
丙円の半径と中心座標を r3, (x3, y3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms r0::positive, r1::positive, r2::positive,
     r3::positive, x3::positive, y3::positive;

eq1 = r1 + r2 - r0
eq2 = x3^2 + (y3 - r1 + r0)^2 - (r1 + r3)^2
eq3 = x3^2 + (r0 - r2 - y3)^2 - (r2 + r3)^2
eq4 = x3^2 + y3^2 - (r0 -r3)^2
res = solve([eq1, eq2, eq3, eq4], (r0, r3, x3, y3))

   1-element Vector{NTuple{4, Sym}}:
    (r1 + r2, r1*r2*(r1 + r2)/(r1^2 + r1*r2 + r2^2), 2*r1*r2*(r1 + r2)/(r1^2 + r1*r2 + r2^2), (r1 - r2)*(r1 + r2)^2/(r1^2 + r1*r2 + r2^2))

r0 = 10.5;  r3 = 3;  x3 = 6;  y3 = 4.5
丙円の直径 = 6

甲円,乙円の直径がそれぞれ 14 寸,7 寸のとき,丙円の直径は 6 寸である。

(r1, r2) = (14, 7) ./ 2
2r1*r2*(r1 + r2)/(r1^2 + r1*r2 + r2^2)

   6.0

using Plots

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r1, r2) = (14, 7) .// 2
   (r0, r3, x3, y3) = (r1 + r2, r1*r2*(r1 + r2)/(r1^2 + r1*r2 + r2^2), 2*r1*r2*(r1 + r2)/(r1^2 + r1*r2 + r2^2), (r1 - r2)*(r1 + r2)^2/(r1^2 + r1*r2 + r2^2))
   @printf("r0 = %g;  r3 = %g;  x3 = %g;  y3 = %g\n", r0, r3, x3, y3)
   @printf("丙円の直径 = %g\n", 2r3)
   plot()
   circle(0, 0, r0, :black)
   circle(0, r1 - r0, r1)
   circle(0, r0 - r2, r2, :blue)
   circle(x3, y3, r3, :green)
   circle(-x3, y3, r3, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /  3  # size[2] * fontsize * 2
       point(0, r1 - r0, " r1-r0\n 甲円:r1", :red, :left, :vcenter)
       point(0, r0 - r2, " r0-r2\n 乙円:r2", :blue, :left, :vcenter)
       point(x3, y3, " 丙円,r3,(x3,y3)", :green, :center, delta=-delta)
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

 


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

コメントを投稿

Julia」カテゴリの最新記事