裏 RjpWiki

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

算額(その2143)

2024年10月09日 | Julia

算額(その2143)

岐阜県垂井町 西法寺 令和6年(2024)
http://www.wasan.jp/gifu/saihoji.html

キーワード:円3個,円弧3個
#Julia, #SymPy, #算額, #和算

一辺が 1 の正三角形の頂点から 3 個の円弧内に互いに接する黄円 3 子がある。黄円の半径はいかほどか。

正三角形が内接する円の半径と中心座標を R, (0, 0)
円弧の半径と中心座標を √3R, (0, y), (√3R/2, -R/2), (-√3R/2, -R/2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::positive, r::positive, R::positive, y::positive
eq1 = (√Sym(3)R/2)^2 + (y + R/2)^2 - (√Sym(3)R - r)^2
eq2 = dist2(0, 0, √Sym(3)R, R, 0, y, r)
res = solve([eq1, eq2], (r, y))[1]

   (sqrt(3)*(-8*R^2*(-4 + 3*sqrt(2)) - 4*R^2*(-4 + 3*sqrt(2))^2 + 8*R^2)/(24*R), 2*R*(-4 + 3*sqrt(2)))

# r
res[1] |> simplify |> println

   R*(-4*sqrt(3) + 3*sqrt(6))

# y
res[2] |> println

   2*R*(-4 + 3*sqrt(2))

正三角形の一辺の長さが 1 ならば,R = 1/√3 である。そのとき,黄円の半径は 3√2 - 4 である。

res[1](R => 1/√Sym(3)) |> simplify |> println

   -4 + 3*sqrt(2)

function draw(R, more)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = R*(3√6 - 4√3)
   y = 2R*(3√2 - 4)
   plot()
   circle(0, 0, R, :pink)
   circle(0, R, √3R, :blue, beginangle=240, endangle=300)
   circle(√3R/2, -R/2, √3R, :blue, beginangle=120, endangle=180)
   circle(-√3R/2, -R/2, √3R, :blue, beginangle=0, endangle=60)
   rotatef(0, y, r, :orange)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, y, "黄円:r,(0,y)", :blue, :center, delta=-delta/2)
       point(√3y/2, -y/2, "黄円:r,(√3y/2,-y/2)", :blue, :center, delta=-delta/2)
       point(0, R, "R", :red, :center, :bottom, delta=delta/2)
       point(√3R/2, -R/2, "(√3R/2,-R/2)", :blue, :center, delta=-3delta)
   end  
end;

draw(1/√3, true)

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

算額(その2142)

2024年10月09日 | Julia

算額(その2142)

岐阜県垂井町 西法寺 令和6年(2024)
http://www.wasan.jp/gifu/saihoji.html

キーワード:円3個,正三角形
#Julia, #SymPy, #算額, #和算

一辺が 1 の正三角形内に互いに接する赤円 3 個がある。赤円の半径はいかほどか。

正三角形の一辺の長さを 2a
赤円の半径と中心座標を r, (r, 1)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::positive, r::positive

eq1 = r/(a - r) - 1/√Sym(3)
res = solve(eq1, r)[1]
res |> println

   -a/2 + sqrt(3)*a/2

正三角形の一辺の長さが 1 のとき,赤円の半径は (√3 - 1)/4 である。

res(a => 1//2) |> println

   -1/4 + sqrt(3)/4

function draw(a, more)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = -a/2 + √3a/2
   plot([a, 0, -a, a], [0, √3a, 0, 0], color=:blue, lw=0.5)
   circle2f(r, r, r)
   circlef(0, (1 + √3)r, r)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(r, r, "赤円:r,(r,r)", :black, :center, delta=-delta/2)
       point(0, (1 + √3)r, "赤円:r,(0,(1+√3)r)", :black, :center, delta=-delta/2)
       point(a, 0, "a", :blue, :left, :bottom, delta=delta)
       point(0, √3a, " √3a", :blue, :left, :vcenter)
   end  
end;

draw(1/2, true)

 

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

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

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