裏 RjpWiki

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

算額(その889)

2024年04月28日 | Julia

算額(その889)

六四 加須市不動岡 総願寺 慶応2年(1866)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

外円内に正三角形と甲円を 1 個ずつ,乙円を 2 個入れる。甲円の直径と正三角形の一辺の長さが共に 1 寸のとき,乙円の直径はいかほどか。

外円の半径と中心座標を R, (0, 0)
甲円の半径と中心座標を r1, (0, r1 - R)
乙円の半径と中心座標を r2, (x2, y2)
とおき,以下の連立方程式の解を求める。

include("julia-source.txt");

using SymPy
@syms R::positive, a::positive, r1::positive,
     r2::positive, x2::positive, y2::negative
(r1, a) = (1, 1) .// 2
eq1 = x2^2 + y2^2 - (R - r2)^2
eq2 = x2^2 + (y2 - r1 + R)^2 - (r1 + r2)^2
eq3 = (a - x2)^2 + (R - a√Sym(3) - y2)^2 - r2^2
eq4 = a√Sym(3) + 2r1 - 2R
res = solve([eq1, eq2, eq3, eq4], (R, r2, x2, y2));

res[1][1] |> simplify |> println
res[1][2] |> simplify |> println
res[1][3] |> simplify |> println
res[1][4] |> simplify |> println

   sqrt(3)/4 + 1/2
   -19*sqrt(888 + 534*sqrt(3))/2704 - 9/104 + 3*sqrt(296 + 178*sqrt(3))/338 + 25*sqrt(3)/104
   -2*sqrt(888 + 534*sqrt(3))/169 + 3*sqrt(3)/26 + 15/52 + 19*sqrt(296 + 178*sqrt(3))/676
   -sqrt(296 + 178*sqrt(3))/52 - sqrt(3)/8 + sqrt(3)*sqrt(296 + 178*sqrt(3))/208 + 3/8

かなり不明な定数が出てくるが,乙円の半径は
-2*sqrt(888 + 534*sqrt(3))/169 + 3*sqrt(3)/26 + 15/52 + 19*sqrt(296 + 178*sqrt(3))/676
である。

res[1][1].evalf() |> println
res[1][2].evalf() |> println
res[1][3].evalf() |> println
res[1][4].evalf() |> println

   0.933012701892219
   0.248826680729423
   0.675359395597227
   -0.109545416760023

数値としては,乙円の半径は 0.248826680729423(直径は 0.497653361458846)である。

2*0.248826680729423

   0.497653361458846

甲円の直径,正三角形の一辺の長さが共に 1 寸のとき,乙円の直径は 0.497653361458846 寸である。

その他のパラメータは以下のとおりである。
a = 0.5;  r1 = 0.5;  R = 0.933013;  r2 = 0.248827;  x2 = 0.675359;  y2 = -0.109545

算額の答では,「乙円径五分一厘有奇」となっているがそれだとすると,外円をはみ出す(図の赤円)。得られた答えは青円で,ちゃんと外円に接している。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, r1) = [1, 1] .//2
   (R, r2, x2, y2) = (
       sqrt(3)/4 + 1/2,
       -19*sqrt(888 + 534*sqrt(3))/2704 - 9/104 + 3*sqrt(296 + 178*sqrt(3))/338 + 25*sqrt(3)/104,
       -2*sqrt(888 + 534*sqrt(3))/169 + 3*sqrt(3)/26 + 15/52 + 19*sqrt(296 + 178*sqrt(3))/676,
       -sqrt(296 + 178*sqrt(3))/52 - sqrt(3)/8 + sqrt(3)*sqrt(296 + 178*sqrt(3))/208 + 3/8)
   @printf("甲円の直径,正三角形の一辺の長さが共に 1 寸のとき,乙円の直径は %.15g 寸である。\n", 2r2)
   @printf("a = %g;  r1 = %g;  R = %g;  r2 = %g;  x2 = %g;  y2 = %g\n", a, r1, R, r2, x2, y2)
   plot()
   circle(0, 0, R, :blue)
   plot!([a, 0, -a, a], [R - √3a, R, R - √3a, R - √3a], color=:green, lw=0.25)
   circle(0, r1 - R, r1)
   circle(x2, y2, r2, :magenta)
   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(a, R - √3a, "(a,R-√3a) ", :green, :right, :bottom, delta=delta/2)
       point(0, r1 - R, "甲円:r1,(0,r1-R)", :red, :center, delta=-delta/2)
       point(x2, y2, "乙円:r2,(x2,y2)", :magenta, :center, delta=-delta/2)
   end
end;

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

算額(その888)

2024年04月28日 | Julia

算額(その888)

六四 加須市不動岡 総願寺 慶応2年(1866)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.
キーワード:円1個,楕円1個,正方形2個

楕円の中に正方形 2 個と全円 1 個を入れる。正方形の一辺の長さが 1 寸のとき,全円の直径はいかほどか。
ちなみに,以下の図は正方形の一辺の長さが 123.45 のときの図である。

楕円の長半径と短半径,中心座標を a, b, (0, 0) とする。全円の半径は短半径と同じである。
正方形の一辺の長さを c とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, c::positive
s2 = √Sym(2)
eq1 = (b + s2*c/2)^2/a^2 + (s2*c/2)^2/b^2 - 1
eq2 = b + s2*c - a
res = solve([eq1, eq2], (a, b))[1]

   (c*(1 + sqrt(2)), c)

b すなわち全円の半径は,正方形の一辺の長さ c である。
正方形の一辺の長さが c のとき,全円の直径は 2c である。
正方形の一辺の長さが 1 寸のとき,全円の直径は 2 寸である。

function diamond(a, c)
   plot!([a, a - c/√2, a - √2c, a - c/√2, a], [0, c/√2, 0, -c/√2, 0], color=:green, lw=0.5)
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   c = 123.45
   b = c
   a = b + c√2
   plot()
   ellipse(0, 0, a, b, color=:red)
   circle(0, 0, b, :blue)
   diamond(a, c)
   diamond(-b, c)
   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, b, " b", :blue, :left, :bottom, delta=delta/2)
       point(a, 0, " a", :red, :left, :bottom, delta=delta/2)
       point(b + √2c/2, 0, "b+√2c/2", :green, :center, :bottom, delta=delta/2)
   end
end;

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

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

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