裏 RjpWiki

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

算額(その879)

2024年04月25日 | Julia

算額(その879)

六十三 羽生市須影 八幡神社 慶応元年(1865)

埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

正方形の中に,四分円が 2 個,半円が 1 個,甲円が 3 個,乙円が 2 個入っている。乙円の直径が 3 寸のとき,甲円の直径はいかほどか。

四分円の半径と中心座標を 2r1, (0, 0)
半円の半径と中心座標を r1, (r1, 0)
甲円の半径と中心座標を r2, (r1, r1 + r2), (2r1 - r2, y2)
乙円の半径と中心座標を r3, (x3, y3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms r1::positive, r2::positive, y2::positive,
     r3::positive, x3::positive, y3::positive
eq1 = r1^2 + (r1 + r2)^2 - (2r1 - r2)^2
eq2 = (x3 - r1)^2 + y3^2 - (r1 + r3)^2
eq3 = (2r1 - r2)^2 + y2^2 - (2r1 + r2)^2
eq4 = x3^2 + y3^2 - (2r1 - r3)^2
eq5 = (x3 - r1)^2 + (r1 + r2 - y3)^2 - (r2 + r3)^2
res = solve([eq1, eq2, eq3, eq4, eq5], (r1, r2, y2, x3, y3))

   1-element Vector{NTuple{5, Sym{PyCall.PyObject}}}:
    (11*r3/2, 11*r3/6, 11*sqrt(6)*r3/3, 8*r3, 6*r3)

甲円の半径は乙円の半径の 11/6 倍である。
乙円の直径が 3 寸のとき,甲円の直径は 11/2 = 5.5 寸である。

その他のパラメータは以下のとおりである。

r1 = 8.25;  r2 = 2.75;  y2 = 13.4722;  x3 = 12;  y3 = 9

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r3 = 3/2
   (r1, r2, y2, x3, y3) = r3 .* [11/2, 11/6, 11√6/3, 8, 6]
   @printf("乙円の直径が %g のとき,甲円の直径は %g である\n", 2r3, 2r2)
   @printf("r1 = %g;  r2 = %g;  y2 = %g;  x3 = %g;  y3 = %g\n", r1, r2, y2, x3, y3)
   plot([0, 2r1, 2r1, 0, 0], [0, 0, 2r1, 2r1, 0], color=:green, lw=0.5)
   circle(0, 0, 2r1, :magenta, beginangle=0, endangle=90)
   circle(2r1, 0, 2r1, :magenta, beginangle=90, endangle=180)
   circle(r1, 0, r1, :green, beginangle=0, endangle=180)
   circle(r1, r1 + r2, r2)
   circle(2r1 - r2, y2, r2)
   circle(r2, y2, r2)
   circle(x3, y3, r3, :blue)
   circle(2r1 - x3, y3, r3, :blue)
   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(r1, r1 + r2, "甲円:r2,(r1,r1+r2)", :red, :center, delta=-delta/2)
       point(2r1 - r2, y2, "甲円:r2,(2r1-r2,y2)", :red, :center, delta=-delta/2)
       point(x3, y3, "乙円:r3\n(x3,y3)", :red, :center, delta=-delta/2)
       point(r1, 0, "r1", :green, :center, :bottom, delta=delta/2)
       point(2r1, 0, "2r1 ", :green, :right, :bottom, delta=delta/2)
   end
end;

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

算額(その878)

2024年04月25日 | Julia

算額(その878)

六十三 羽生市須影 八幡神社 慶応元年(1865)

埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

正方形内に半円 2 個,等円 2 個を入れる。等円の直径が 1 寸のとき,正方形の一辺の長さはいかほどか。

正方形の一辺の長さを 2r1
半円の半径と中心座標を r1, (r1, 0)
等円の半径と中心座標を r2, (r2, y2), (2r1 - y2, 2r1 - r2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms r1::positive, r2::positive, y2::positive
eq1 = (r1 - r2)^2 + y2^2 - (r1 + r2)^2
eq2 = (2r1 - y2 - r2)^2 + (2r1 - r2 - y2)^2 - 4r2^2;
res = solve([eq1, eq2], (r1, y2))

   3-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (r2/2, sqrt(2)*r2)
    (r2*(2 - sqrt(2))^2/4, r2*(2 - sqrt(2)))
    (r2*(sqrt(2) + 2)^2/4, r2*(sqrt(2) + 2))

3 組の解が得られるが,3 番目のものが適解である。

res[3][1]/r2 |> expand |> println

   sqrt(2) + 3/2

半円の半径は等円の半径の (√2 + 3/2) 倍である。
等円の直径が 1 寸のとき,半円の直径は 2.914213562373095 寸で,それは正方形の一辺の長さでもある。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 1/2
   (r1, y2) = (r2*(sqrt(2) + 2)^2/4, r2*(sqrt(2) + 2))
   @printf("等円の直径 = %g;  正方形の一辺の長さ = %g\n", 2r2, 2r1)
   plot([0, 2r1, 2r1, 0, 0], [0, 0, 2r1, 2r1, 0], color=:green, lw=0.5)
   circle(r1, 0, r1, beginangle=0, endangle=180)
   circle(2r1, r1, r1, beginangle=90, endangle=270)
   circle(r2, y2, r2, :blue)
   circle(2r1 - y2, 2r1 - r2, r2, :blue)
   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(r1, 0, "r1", :red, :center, :bottom, delta=delta/2)
       point(2r1, 0, " 2r1", :red, :left, :bottom, delta=delta/2)
       point(0, 2r1, " 2r1", :red, :left, :bottom, delta=delta/2)
       point(2r1, r1, "", :red)
       point(r2, y2, "等円:r2,(r2,y2)", :blue, :center, delta=-delta/2)
       point(2r1 - y2, 2r1 - r2, "等円:r2\n(2r1-y2,2r1-r2)", :blue, :center, delta=-delta/2)
   end
end;

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

算額(その877)

2024年04月25日 | Julia

算額(その877)

七 川越市石田本郷折戸 地蔵堂 文化元甲子歳

埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所, 埼玉県与野市.

外円の中に甲方(正方形)と乙円が入っている。正方形の一辺の長さは乙円の直径より 25 寸短く,正方形の下辺が作る円弧の矢が 5 寸である。このとき,外円の直径はいかほどか。

正方形の一辺の長さを 2a
乙円の半径と中心座標を r, (0, R - r)
乙円と正方形の一辺の長さとの差をそのまま「差」
矢をそのまま「矢」
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, 差::positive, 矢::positive, r::positive,
     a::positive
r  = a + 差//2
eq1 = (矢 - R)^2 + a^2 - R^2
eq2 = 2r + 2a + 矢 - 2R;
res = solve([eq1, eq2], (R, a));
res[2]  # 2 of 2

   (差/2 + 2*sqrt(矢)*sqrt(差 + 4*矢) + 9*矢/2, sqrt(矢)*sqrt(差 + 4*矢) + 2*矢)

2 組の解が得られるが,2 番目のものが適解である。

与えられた条件のもとでは,外円の直径は 130 寸である。

ちなみに,乙円の直径は 75 寸,正方形の一辺の長さは 50 寸である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   差 = 25
   矢 = 5
   (R, a) = (差/2 + 2sqrt(矢*差 + 4矢^2) + 9矢/2, sqrt(矢*差 + 4矢^2) + 2矢)
   r  = a + 差/2
   @printf("乙円の直径 = %g;  矢 = %g;  外円の直径 = %g;  正方形の一辺の長さ = %g\n", 2r, 矢, 2R, 2a)
   plot()
   circle(0, 0, R)
   plot!([a, a, -a, -a, a], (矢 - R) .+ [0, 2a, 2a, 0, 0], color=:blue, lw=0.5)
   circle(0, R - r, r, :green)
   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, R, "R", :red, :center, :bottom, delta=delta/2)
       point(0, R - r, "乙円:r,(0,R-r)", :green, :center, delta=-delta/2)
       point(0, R - 2r, "R-2r=2a+矢-R", :blue, :center, delta=-delta/2)
       point(0, 矢-R, "矢-R", :blue, :center, :bottom, delta=delta/2)
   end
end;

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

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

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