裏 RjpWiki

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

算額(その975)

2024年05月19日 | Julia

算額(その975)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

直角三角形内に直角三角形の底辺上と斜辺上に二辺を持つ大小の正五角形を描く。小さい正五角形の左の頂点は,大きい正五角形の右の辺に接している。大きい正五角形の一辺の長さが 2 寸のとき,小さい正五角形の一辺の長さはいかほどか。

計算をしなくてもわかる。
大きな正五角形の右の辺の中点が小さい五角形の左の頂点になる。
大小の正五角形の左の頂点のy座標値の比が正五角形の相似比である。
相似比は 1/2 なので,大きい正五角形の一辺の長さが 2 寸のとき,小さい正五角形の一辺の長さは 1 寸である。

include("julia-source.txt");
function pentagon(x1, a; color=:red, lw=0.5)
   r = a/2sind(36)
   h = r*cosd(36)        
   y1 = h +  r*cosd(72)
   x2 = x1 + a*cosd(36)
   y2 = y1 + a*sind(36)
   x3 = x1 + 2a*cosd(36)
   y3 = y1
   x5 = x1 + a*sind(18)
   y5 = 0
   x4 = x5 + a
   y4 = 0
   y_next = y3/2  # y1 - (r + h)*sind(18)
   x_next = (x3 + x4)/2  # x1 + (r + h)*cosd(18)
   if x1 == 0
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       h2 = y1 + 2a*sind(36)
       w = h2*tand(54)
       plot!([0, w, 0, 0], [0, 0, h2, 0], color=:black, lw=0.5)
       point(x1, y1, "  (x1,y1)", color, :left, :vcenter)
       point(x_next, y_next, "((x3+x4)/2,y3/2) ", color, :right, :vcenter)
       point(x3, y3, "(x3,y3) ", color, :right, :vcenter)
       point(x4, y4, "(x4,y4)", color, :right, :bottom, delta=delta)
       println("相似比 = $(y_next/y1)")
   end
   plot!([x1, x2, x3, x4, x5, x1],
         [y1, y2, y3, y4, y5, y1], color=color, lw=lw)
   return x_next
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 119/2
   (r2, x2, y1, a) = (3*r1*(9 - 4*sqrt(2))/49, 4*r1*(sqrt(3) + 5*sqrt(6))/49, r1*(-5 + 24*sqrt(2))/49, 8*sqrt(6)*r1/49 + 31*sqrt(3)*r1/49)
   plot()
   x2 = pentagon(0, 2)
   x3 = pentagon(x2, 1, color=:blue)
   x4 = pentagon(x3, 0.5, color=:green)
   x5 = pentagon(x4, 0.25, color=: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)
   end
end;

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

算額(その971)

2024年05月19日 | Julia

算額(その971)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

三角形の大斜と小斜一部に一致する正六角形が入っている。大斜と小斜の長さが 10 寸,5 寸のとき,正六角形の一辺の長さを求めよ。
注:大斜は最も長い辺,小斜は最も短い辺

三角形は直角三角形で,中斜の長さは 5√3 である。
正六角形の一辺の長さを a,大斜と小斜の長さを b, c とおき以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, c::positive
eq1 = √Sym(3)a/(b - 2a) - √Sym(3)c/2/(b - c/2)
a = solve(eq1, a)[1]
a |> println

   b*c/(2*b + c)

正六角形の一辺の長さは,「大斜と小斜の積を大斜の 2 倍と小斜の和で割る」ことにより得られる。
大斜,小斜の長さが 10 寸,5 寸 のとき,正六角形の一辺の長さは 2 寸である。

b = 10; c = 5
b*c/(2*b + c) |> println

   2.0

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (b, c) = (10, 5)
   a = b*c/(2b + c)
   @printf("大斜,小斜の長さが %g,%g のとき,正六角形の一辺の長さは %g である。\n", b, c, a)
   plot([0, b, c/2, 0], [0, 0, √3c/2], color=:magenta, lw=0.5)
   plot!(a.*[1, 2, 5/2, 2, 1, 1/2, 1], a.*[0, 0, √3/2, √3, √3, √3/2, 0], color=:blue, lw=0.5)
   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, 0, " a", :blue, :left, :bottom, delta=delta/2)
       point(b, 0, " b", :magenta, :left, :bottom, delta=delta/2)
       point(c/2, c√3/2, "(c/2,c√3/2)", :magenta, :left, :bottom, delta=delta/2)
   end
end;

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

算額(その974)

2024年05月19日 | Julia

算額(その974)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

正三角形と大円が交差してできる区画された領域に小円 3 個を入れる。大円の直径が 119 寸のとき,小円の直径はいかほどか。

式を簡単にするために元の図を時計回りに 120° 回転させた図で考える。
正三角形の一辺の長さを 2a
大円の半径と中心座標を r1, (0, y1)
小円の半径と中心座標を r2, (x2, r2), (0, y1 - r1 + r2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, r1::positive, y1::positive,
     r2::positive, x2::positive
eq1 = r2*√Sym(3) - (a - x2)
eq2 = x2^2 + (y1 - r2)^2 - (r1 + r2)^2
eq3 = 2r1 - (√Sym(3)a - y1)
eq4 = y1 - r1 + 2r2
res = solve([eq1, eq2, eq3, eq4], (r2, x2, y1, a))

   1-element Vector{NTuple{4, Sym{PyCall.PyObject}}}:
    (3*r1*(9 - 4*sqrt(2))/49, 4*r1*(sqrt(3) + 5*sqrt(6))/49, r1*(-5 + 24*sqrt(2))/49, 8*sqrt(6)*r1/49 + 31*sqrt(3)*r1/49)

乙円の半径は甲円の半径の 3(9 - 4√2)/49 倍である。
甲円の直径が 119 寸のとき,乙円の直径は 119*3(9 - 4√2)/49 = 24.35720475369837 寸である。
このシリーズでは整数値に近い答えになるという設定になっているのであるが,この問は半端な数になった。三角形の一辺の長さは 88.9943843290936 で 89 にかなり近い値にはなっている。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 119/2
   (r2, x2, y1, a) = (3*r1*(9 - 4*sqrt(2))/49, 4*r1*(sqrt(3) + 5*sqrt(6))/49, r1*(-5 + 24*sqrt(2))/49, 8*sqrt(6)*r1/49 + 31*sqrt(3)*r1/49)
   @printf("大円の直径が %g のとき,小円の直径は %g である。\n", 2r1, 2r2)
   @printf("r2 = %g;  x2 = %g;  y1 = %g;  a = %g\n", r2, x2, y1, a)
   plot([a, 0, -a, a], [0, √3a, 0, 0], color=:magenta, lw=0.5)
   circle(0, y1, r1)
   circle2(x2, r2, r2, :blue)
   circle(0, y1 - r1 + 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(a, 0, " a", :magenta, :center, :bottom, delta=delta/2)
       point(0, √3a, " √3a", :magenta, :center, :bottom, delta=delta/2)
       point(0, y1, "大円:r1,(0,y1)", :red, :center, delta=-delta/2)
       point(x2, r2, "小円:r2,(x2,r2) ", :blue, :right, delta=-delta/2, deltax=4delta)
       point(0, y1 - r1 + r2, "小円:r2,(0,y1-r1+r2) ", :black, :right, delta=-delta/2, deltax=4delta)
   end
end;

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

算額(その973)

2024年05月19日 | Julia

算額(その973)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

正方形の中に 2 本の平行な斜線を入れ,区画された領域に甲円,乙円 2 個ずつを入れる。甲円の直径が 408 寸のとき,乙円の直径はいかほどか。

正方形の一辺の長さを 2a
斜線と正方形の一辺の交点座標を (-c, -a), (a, c)
甲円の半径と中心座標を r1, (a - r1, a - r1)
乙円の半径と中心座標を r2, (a - r2, r2 - a)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, c::positive, r1::positive, r2::positive
eq1 = √Sym(2)*(a - r1) - r1
eq2 = dist2(-c, -a, a, c, a - r2, r2 - a, r2)
eq3 = dist2(-c, -a, a, c, a - r1, a - r1, r1)
res = solve([eq1, eq2, eq3], (r2, a, c))[1]

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

乙円の半径は甲円の半径の 2 - √2 倍である。
甲円の直径が 408 寸のとき,乙円の直径は 408(2 - √2) = 239.0008665517772 寸である。
ちなみに,正方形の一辺の長さは 甲円の直径の (√2 + 2)/2 倍の 696.4995667241113 寸である。

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

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

算額(その972)

2024年05月19日 | Julia

算額(その972)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

四十一 岩手県一関市牧沢 牧沢八幡神社 明治8年(1875)
山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.
http://www.wasan.jp/yamamura/yamamura.html 

キーワード:円5個,正方形,斜線

正方形内に 4 本の斜線を引き,区画された領域に甲円 1 個と乙円 2 個(4 個)を入れる。甲円の直径が 987 寸のとき,乙円の直径はいかほどか。

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

include("julia-source.txt");

using SymPy
@syms a::positive, r1::positive, r2::positive
sinθ = a/sqrt(a^2 + 4a^2)
eq1 = r1/a - sinθ
eq2 = r2/(a - r2) - sinθ
res = solve([eq1, eq2], (r2, a))
res[r2] |> println
res[a]  |> println

   r1*(5 - sqrt(5))/4
   sqrt(5)*r1

乙円の半径は甲円の半径の (5 - √5)/4 倍である。
甲円の直径が 987 寸のとき,乙円の直径は 987(5 - √5)/4 = 682.0002265519269 寸である。
ちなみに,正方形の一辺の長さは 甲円の直径の √5 倍の 2206.9990937922926 寸である。

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

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

算額(その970)

2024年05月19日 | Julia

算額(その970)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

2 個の正方形が交差してできる 8 個の二等辺三角形に内接円を入れる。正方形の一辺の長さが 239 寸のとき,等円の直径はいかほどか。

正方形の一辺の長さを 2a とすると,二等辺三角形の等辺は a*(2 - √2),斜辺が a*(√2 - 1) で,内接する円の半径を r とすれば,2(a*(2 - √2)) - 2(a*(√2 - 1)) = 2r の関係が成り立つ。等円の半径は r = a*2(3 - 2√2) である。

include("julia-source.txt");

using SymPy
@syms a::positive, r::positive
l = √Sym(2)*a - a
eq1 = 2√Sym(2)*l - 2l - 2r
r = solve(eq1, r)[1]
r |> println

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

正方形の一辺の長さが 239 寸のとき,等円の直径は 41.00591718566052 寸である。

a = 239/2
2a*(3 - 2*sqrt(2)) |> println

   41.00591718566052

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   a = 239/2
   r = a*(3 - 2√2)
   @printf("正方形の一辺の長さが %g のとき,等円の直径は %g である。\n", 2a, 2r)
   plot(a.*[1, 1, -1, -1, 1], a.*[-1, 1, 1, -1, -1], color=:magenta, lw=0.5)
   plot!(√2a.*[0, 1, 0, -1, 0], √2a.*[-1, 0, 1, 0, -1], color=:green, lw=0.5)
   rotate(a + r, 0, r, angle=45)
   circle(0, 0, √2a, :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(√2a, 0, " √2a", :green, :left, :bottom, delta=delta/2)
       point(a, 0, "a ", :magenta, :right, :bottom, delta=delta/2)
   end
end;

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

算額(その969)

2024年05月19日 | Julia

算額(その969)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

横倒しされた台形の中に 2 本の斜線を入れ,区分された領域に 甲円,乙円,丙円を入れる。大頭(台形の下底),甲円の直径,乙円の直径がそれぞれ 16 寸,12 寸,8 寸のとき,丙円の直径はいかほどか。

台形の上底,下底,高さを h2, h1, a
斜線と台形の辺の交点座標を (b, 0), (c, 0), (d, (h1 - h2)*d/a)
甲円の半径と中心座標を r1, (r1, r1)
乙円の半径と中心座標を r2, (a -r2, r2)
丙円の半径と中心座標を r3, (x3, r3)
とおき,以下の連立方程式の数値解を求める。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive,
     c::positive, d::positive, h1::positive,
     h2::positive, r1::positive, r2::positive,
     r3::positive, x3::positive
eq1 = dist(0, h1, a, h2, a - r2, r2) - r2^2
eq2 = dist(b, 0, d, h1 - (h1 - h2)*d/a, a - r2, r2) - r2^2
eq3 = dist(b, 0, d, h1 - (h1 - h2)*d/a, x3, r3) - r3^2
eq4 = dist(b, 0, d, h1 - (h1 - h2)*d/a, r1, r1) - r1^2
eq5 = dist(0, h1, c, 0, a - r2, r2) - r2^2
eq6 = dist(0, h1, c, 0, x3, r3) - r3^2
eq7 = dist(0, h1, c, 0, r1, r1) - r1^2
# solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], (r3, x3, h2, a, b, c, d))

using NLsolve

function nls(func, params...; ini = [0.0])
   if typeof(ini) <: Number
       r = nlsolve((vout, vin) -> vout[1] = func(vin[1], params..., [ini]), ftol=big"1e-40")
       v = r.zero[1]
   else
       r = nlsolve((vout, vin)->vout .= func(vin, params...), ini, ftol=big"1e-40")
       v = r.zero
   end
   return Float64.(v), r.f_converged
end;

function H(u)
   (r3, x3, h2, a, b, c, d) = u
   return [
       -r2^2 + (a - a*(a*(a - r2) + (-h1 + h2)*(-h1 + r2))/(a^2 + (-h1 + h2)^2) - r2)^2 + (-h1 + r2 - (-h1 + h2)*(a*(a - r2) + (-h1 + h2)*(-h1 + r2))/(a^2 + (-h1 + h2)^2))^2,  # eq1
       -r2^2 + (r2 - (h1 - d*(h1 - h2)/a)*(r2*(h1 - d*(h1 - h2)/a) + (-b + d)*(a - b - r2))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2 + (a - b - r2 - (-b + d)*(r2*(h1 - d*(h1 - h2)/a) + (-b + d)*(a - b - r2))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2,  # eq2
       -r3^2 + (r3 - (h1 - d*(h1 - h2)/a)*(r3*(h1 - d*(h1 - h2)/a) + (-b + d)*(-b + x3))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2 + (-b + x3 - (-b + d)*(r3*(h1 - d*(h1 - h2)/a) + (-b + d)*(-b + x3))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2,  # eq3
       -r1^2 + (r1 - (h1 - d*(h1 - h2)/a)*(r1*(h1 - d*(h1 - h2)/a) + (-b + d)*(-b + r1))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2 + (-b + r1 - (-b + d)*(r1*(h1 - d*(h1 - h2)/a) + (-b + d)*(-b + r1))/((-b + d)^2 + (h1 - d*(h1 - h2)/a)^2))^2,  # eq4
       -r2^2 + (a - c*(c*(a - r2) - h1*(-h1 + r2))/(c^2 + h1^2) - r2)^2 + (-h1 + h1*(c*(a - r2) - h1*(-h1 + r2))/(c^2 + h1^2) + r2)^2,  # eq5
       -r3^2 + (-c*(c*x3 - h1*(-h1 + r3))/(c^2 + h1^2) + x3)^2 + (-h1 + h1*(c*x3 - h1*(-h1 + r3))/(c^2 + h1^2) + r3)^2,  # eq6
       -r1^2 + (-c*(c*r1 - h1*(-h1 + r1))/(c^2 + h1^2) + r1)^2 + (-h1 + h1*(c*r1 - h1*(-h1 + r1))/(c^2 + h1^2) + r1)^2,  # eq7
   ]
end;

(h1, r1, r2) = (16, 12/2, 8/2)
iniv = BigFloat[2.3, 20.8, 7.11, 35.0, 7.0, 30.0, 30.83]
res = nls(H, ini=iniv)

   ([2.3, 20.8, 7.111111111111111, 35.0, 7.0, 30.0, 30.829787234042552], true)

大頭 = 16 寸, 甲円径 = 12 寸, 乙円径 = 8 寸のとき,丙円径 = 4.6  寸である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (h1, r1, r2) = (16, 12/2, 8/2)
   (r3, x3, h2, a, b, c, d) = [2.3, 20.8, 7.111111111111111, 35.0, 7.0, 30.0, 30.829787234042552]
   @printf("大頭 = %g, 甲円径 = %g, 乙円径 = %g のとき,丙円径 = %g\n", h1, 2r1, 2r2, 2r3)
   plot([0, a, a, 0, 0], [0, 0, h2, h1, 0], color=:blue, lw=0.5)
   circle(r1, r1, r1)
   circle(a - r2, r2, r2, :green)
   circle(x3, r3, r3, :magenta)
   segment(0, h1, c, 0, :black)
   segment(b, 0, d, h1 -(h1 - h2)*d/a, :black)
   if more        
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, h1, " h1", :blue, :left, :bottom, delta=delta)
       point(a, h2, " (a,h2)", :blue, :center, :bottom, delta=2delta)
       point(b, 0, "b", :black, :center, delta=-2delta)
       point(c, 0, "c", :black, :center, delta=-2delta)
       point(d, h1 - (h1 - h2)*d/a, "(d,h1-(h1-h2)*d/a)", :black, :center, :bottom, delta=5delta)
       point(r1, r1, "甲円:r1,(r1,r1)", :red, :center, delta=-2delta)
       point(a - r2, r2, "乙円:r2\n(a-r2,r2)", :green, :center, delta=-2delta)
       point(x3, r3, "丙円:r3,(x3,r3)", :black, :center, delta=-2delta)
       plot!(ylims=(-8delta, h1 + 3delta))
   end
end;

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

算額(その968)

2024年05月19日 | Julia

算額(その968)

一七 大里郡岡部村岡 稲荷社 文化13年(1816)

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

正三角形内に 2 本の斜線,大円(内接円),甲円,乙円を入れる。甲円の直径が 9 寸のとき,乙円の直径はいかほどか。

正三角形の一辺の長さを a,斜線と斜辺の交点座標を (b, (a - b)√3)
大円の半径と中心座標を r1, (0, r1)
甲円の半径と中心座標を r2, (0, r2)
乙円の半径と中心座標を r3, (0, 2r1 + r3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive,
     r1::positive, r2::positive, r3::positive
r1 = a/√Sym(3)
eq1 = dist2(a, 0, -b, (a - b)√Sym(3), 0, r2, r2)
eq2 = dist2(a, 0, -b, (a - b)√Sym(3), 0, 2r1 + r3, r3)
eq3 = √Sym(3)a - 2r1 - 3r3
solve([eq1, eq2, eq3], (r3, a, b))[1]

   (4*r2/9, 4*sqrt(3)*r2/3, 20*sqrt(3)*r2/63)

乙円の半径 r3 は,甲円の半径 r2 の 4/9 倍である。
甲円の直径が 9 寸のとき,乙円の直径は 4 寸である。
ちなみに a = 10.392304845413262,b = 2.474358296526967 である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 9/2
   (r3, a, b) = (4*r2/9, 4*sqrt(3)*r2/3, 20*sqrt(3)*r2/63)
   r1 = a/√3
   @printf("甲円の直径が %g のとき,乙円の直径は %g である。\n", 2r2, 2r3)
   @printf("r3 = %g;  a = %g;  b = %g\n", r3, a, b)
   plot([a, 0, -a, a], [0, √3a, 0, 0], color=:blue, lw=0.5)
   circle(0, r1, r1)
   circle(0, r2, r2, :green)
   circle(0, 2r1 + r3, r3, :magenta)
   segment(a, 0, -b, (a - b)√3, :black)
   segment(-a, 0, b, (a - b)√3, :black)
   if more        
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(b, (a - b)√3, " (b,(a-b)√3)", :black, :left, :vcenter)
       point(a, 0, " a", :black, :left, :bottom, delta=delta/2)
       point(0, √3a, "√3a", :blue, :center, :bottom, delta=delta/2)
       point(0, 2r1, "2r1", :red, :center, :bottom, delta=delta/2)
       point(0, r1, "大円:r1,(0,r1)", :red, :center, delta=-delta/2)
       point(0, r2, "甲円:r2,(0,r2)", :green, :center, delta=-delta/2)
       point(0, 2r1 + r3, "乙円:r3\n(0,2r1+r3)", :green, :center, :bottom, delta=delta/2)
   end
end;

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

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

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