裏 RjpWiki

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

算額(その2078)

2024年09月07日 | Julia

算額(その2078)

百四十八 群馬県安中市磯部 赤城神社 昭和52年(1977) 復元
群馬県和算研究会:群馬の算額,上武印刷株式会社,高崎市,1987年3月31日.
キーワード:円3個,正方形

正方形の中に,甲円 1 個,乙円 2 個を容れる。正方形の一辺の長さが 10 寸,甲円の直径が 7.5 寸のとき,乙円の直径はいかほどか。

正方形の一辺の長さを a
甲円の半径と中心座標を r1, (r1, r1)
乙円の半径と中心座標を r2, (a - r2, y), (y, a - r2)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, r1::positive, r2::positive, y::positive;
eq1 = (a - r2 - r1)^2 + (y - r1)^2 - (r1 + r2)^2
eq2 = (y - (a - r2)) + √Sym(2)*r2
res = solve([eq1, eq2], (r2, y))[2]

   (-a + sqrt(2)*a + (1 - sqrt(2))*(sqrt(2)*sqrt(a)*sqrt(r1)*sqrt(sqrt(2) + 2)/(1 + sqrt(2)) - sqrt(2)*a + a + r1), sqrt(2)*sqrt(a)*sqrt(r1)*sqrt(sqrt(2) + 2)/(1 + sqrt(2)) - sqrt(2)*a + a + r1)

手動で簡約化すると以下のようになる。
正方形の一辺の長さが 10 寸,甲円の直径が 7.5 寸のとき,乙円の直径は 2*1.5590435749682972 = 3.1180871499365943 寸である。

a = 10
r1 = 7.5/2
t = sqrt(a*r1*(√2+2))
r2 = (2 - √2)a - (3√2 - 4)t - (√2 - 1)r1
y  = (2 - √2)t - (√2 - 1)a + r1
(r2, y)

   (1.5590435749682972, 6.236135856980884)

すべてのパラメータは以下のとおりである。

   a = 10;  r1 = 3.75;  r2 = 1.55904;  y = 6.23614

function draw(a, r1, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   t = sqrt(a*r1*(√2+2))
   r2 = (2 - √2)a - (3√2 - 4)t - (√2 - 1)r1
   y  = (2 - √2)t - (√2 - 1)a + r1
   @printf("正方形の一辺の長さが %g,甲円の直径が %g のとき,乙円の直径は %g である。\n", a, 2r1, 2r2)
   @printf("a = %g;  r1 = %g;  r2 = %g;  y = %g\n", a, r1, r2, y)
   plot([0, a, a, 0, 0], [0, 0, a, a, 0], color=:green, lw=0.5)
   circle(r1, r1, r1) 
   circle(a - r2, y, r2, :blue)
   circle(y, a - 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, r1, "甲円:r1,(r1,r1)", :red, :center, delta=-delta/2)

       point(a - r2, y, "乙円:r2,(a-r2,y)", :blue, :center, delta=-delta/2)
       point(y, a - r2, "乙円:r2,(y,a-r2)", :blue, :center, delta=-delta/2)
       point(a, a, "(a,a)", :green, :right, :bottom, delta=delta/2)
   end

end;

draw(10, 7.5/2, true)

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

算額(その2077)

2024年09月07日 | Julia

算額(その2077)

百四十七 群馬県甘楽郡妙義町下高田 高太神社 大正12年(1923)
群馬県和算研究会:群馬の算額,上武印刷株式会社,高崎市,1987年3月31日.
キーワード:円4個,長方形,菱形

長方形の中に菱形 1 個と等円 4 個を容れる。長方形の長辺,短辺が 8.3 寸,7.1 寸,菱形の一辺が 3 寸のとき,等円の直径はいかほどか。

長方形の長辺,短辺を 2a, 2b
菱形の一辺を c
等円の半径と中心座標を r, (a - r, 0), (0, b - r)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, c::positive, r::positive;
eq = (a - 2r)^2 + (b - 2r)^2 - c^2
res = solve(eq, r)[1]  # 1 of 2
res |> println

   a/4 + b/4 - sqrt(-a^2 + 2*a*b - b^2 + 2*c^2)/4

長方形の長辺,短辺が 8.3 寸,7.1 寸,菱形の一辺が 3 寸のとき,等円の直径は 1.75 寸である。

res(a => 8.3/2, b => 7.1/2, c => 3)*2 |> println

   1.75000000000000

function draw(a, b, c, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = a/4 + b/4 - sqrt(-a^2 + 2*a*b - b^2 + 2*c^2)/4
   @printf("長方形の長辺,短辺が %g, %g,菱形の一辺が %g のとき,等円の直径は %g である。\n", 2a, 2b, c, 2r)
   plot([a, a, -a, -a, a], [-b, b, b, -b, -b], color=:green, lw=0.5)
   plot!([a - 2r, 0, 2r - a, 0, a - 2r], [0, b - 2r, 0, 2r - b, 0], color=:blue, lw=0.5)
   circle22(0, b - r, r) 
   circle2(a - r, 0, 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(a - r, 0, "等円:(a-r,0)", :red, :center, delta=-delta/2)
       point(0, b - r, "等円:(0,b-r)", :red, :center, delta=-delta/2)
       point(a, b, "(a,b) ", :green, :right, delta=-delta)
       point(0, b - 2r, "(0,b-2r)", :blue, :left, :vcenter, deltax=4delta)
       point(a - 2r, 0, "(a-2r,0)", :blue, :right, :vcenter, deltax=-2delta)
   end

end;

draw(8.3/2, 7.1/2, 3, true)

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

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

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