裏 RjpWiki

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

算額(その787)

2024年03月17日 | Julia

算額(その787)

寛政十年戊午九月(1798) 藤田貞資門人 肥後人吉 西九郎左衛門孟周
藤田貞資(1807):続神壁算法
http://www.wasan.jp/jinpeki/zokujinpekisanpo.pdf

正方形内に円弧(弧背)と等円 3 個を入れる。正方形の一辺の長さが 971 寸のとき,等円の直径はいかほどか。

最初に見たとき,正方形の上辺で 2 つの円弧は互いに外接しているかと思ったが,そうではなかった。そこで交わっている。

正方形の一辺の長さを 2a
等円の半径と中心座標を r, (0, r), (a - r, 2a - r)
円弧のもとの円の半径と中心座標を r0, (x0, y0)
とおき,以下の連立方程式を解く。

include("julia-source.txt");
# julia-source.txt ソース https://blog.goo.ne.jp/r-de-r/e/ad3a427b84bb416c4f5b73089ae813cf

using SymPy
@syms r0::positive, x0::positive, y0::positive, a::positive, r::positive
#a = 971//2
eq1 = (x0 - (a - r))^2 + (y0 - (2a - r))^2 - (r0 - r)^2
eq2 = x0^2 + (y0 - r)^2 - (r0 + r)^2
eq3 = (x0 - a)^2 + y0^2 - r0^2
eq4 = x0^2 + (y0 - 2a)^2 - r0^2;
res = solve([eq1, eq2, eq3, eq4], (r, r0, x0, y0))

   1-element Vector{NTuple{4, Sym{PyCall.PyObject}}}:
    (a*(-5*sqrt(5) + sqrt(14 + 10*sqrt(5)) + 7)/4, 5*a*(-34 - 14*sqrt(5) + 5*sqrt(70 + 50*sqrt(5)) + 13*sqrt(14 + 10*sqrt(5)))/(8*(-sqrt(2)*sqrt(7 + 5*sqrt(5)) + 5*sqrt(5) + 13)), a*(-sqrt(14 + 10*sqrt(5)) + 5*sqrt(5) + 17)/8, a*(-sqrt(7/128 + 5*sqrt(5)/128) + 5*sqrt(5)/16 + 29/16))

等円の直径は,正方形の一辺の長さの (sqrt(14 + 10*√5) + 7 - 5√5)/4 倍である。

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

数式はそんなに長くないと思うが,術は結構長い。

971*(sqrt(14 + 10*√5) + 7 - 5√5)/4

   449.00055949866737

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   a = 971//2
   (r, r0, x0, y0) = (a*(-5*sqrt(5) + sqrt(14 + 10*sqrt(5)) + 7)/4, 5*a*(-34 - 14*sqrt(5) + 5*sqrt(70 + 50*sqrt(5)) + 13*sqrt(14 + 10*sqrt(5)))/(8*(-sqrt(2)*sqrt(7 + 5*sqrt(5)) + 5*sqrt(5) + 13)), a*(-sqrt(14 + 10*sqrt(5)) + 5*sqrt(5) + 17)/8, a*(-sqrt(7/128 + 5*sqrt(5)/128) + 5*sqrt(5)/16 + 29/16))
   @printf("等円の直径 = %g;  r = %g;  r0 = %g;  x0 = %g\n", 2r, r, r0, x0)
   plot([a, a, -a, -a, a], [0, 2a, 2a, 0, 0], color=:blue, lw=0.5)
   circle2(a - r, 2a - r, r)
   circle(0, r, r)
   circle(x0, y0, r0, :green, beginangle=180, endangle= 235)
   circle(-x0, y0, r0, :green, beginangle=305, endangle= 360)
   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\n (0,r)", :red, :left, :vcenter)
       point(a - r, 2a - r, " 等円:r\n (a-r,2a-r)", :red, :left, :vcenter)
       point(0, 2a, " 2a", :blue, :left, :bottom, delta=delta/2)
       point(a, 0, " a", :blue, :left, :bottom, delta=delta/2)
       point(0.3a, a, "弧背:r0,(x0,y0)", :green, :left, mark=false)
   end
end;

 

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

算額(その786)

2024年03月17日 | Julia

算額(その786)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

外円の中に大小の正方形と甲乙丙の 3 円が入っている(甲円ははみ出すが)。丙円の直径がわかっているとき,外円の直径を求めよ。

それぞれの図形が独立なので,上から順に図形を構成していく。

外円の半径と中心座標を R, (0, 0),大正方形の一辺の長さを a とする。
右にある大正方形の右上の頂点座標から,以下の方程式を解くことにより a が決定される。

include("julia-source.txt");

@syms R, a
eq = sqrt(R^2 - (R - a)^2) - 2a;
solve(eq, a)

   2-element Vector{Sym{PyCall.PyObject}}:
        0
    2*R/5

斜線と外円の交点座標 (x02, y02) を求める。傾きは -1 である。

@syms x02, y02
a = 2R/5
eq1 = (R - a - y02)/x02 + 1
eq2 = x02^2 + y02^2 - R^2;
solve([eq1, eq2], (x02, y02))

   2-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (R*(-3 + sqrt(41))/10, R*(3 + sqrt(41))/10)
    (R*(-sqrt(41) - 3)/10, R*(3 - sqrt(41))/10)

@syms r1, r2, r3
(x02, y02) = (R*(sqrt(Sym(41)) + 3)/10, R*(3 - sqrt(Sym(41)))/10)
eq3 = distance(0, R - a, x02, y02, r2, R - 2a - r2) - r2^2
eq4 = distance(0, R - a, x02, y02, 2r1, R - 2a - 2r2 - r1) - r1^2
eq5 = r1^2 + (r1 - r3)^2 - (r1 + r3)^2
solve([eq3, eq4, eq5], (r1, r2, r3))

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

2番目のものが適解である。

甲円,乙円,丙円の半径はそれぞれ,外円の半径の,2/5, √2/5, 1/10 倍である。

例えば,外円の直径が 10 寸のとき,乙円の半径は 1 寸である。

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = 5
   (a, r1, r2, r3) = R .* (2/5, 2/5, √2/5, 1/10)
   @printf("丙円の直径 = %g;  外円の直径 = %g;  甲円の直径 = %g;  乙円の直径 = %g\n", 2r3, 2R, 2r1, 2r2)
   @printf("R = %g;  r1 = %g;  r2 = %g;  r3 = %g\n", R, r1, r2, r3)
   y01 = R - a
   x01 = sqrt(R^2 - y01^2)
   plot([0, a/2, 0, -a/2, 0, 0, a/2, 0, -a/2, 0],
       [R - a, R - a/2, R, R - a/2, R - a, R - 2a, R - 3a/2, R - a, R - 3a/2, R - 2a],
       color=:black, lw=0.5)
   rect(x01, y01, x01 - a, y01 - a, :black)
   rect(x01 - 2a, y01, x01 - a, y01 - a, :black)
   rect(-x01, y01, -x01 + a, y01 - a, :black)
   rect(-x01 + 2a, y01, -x01 + a, y01 - a, :black)
   circle(0, 0, R)
   circle2(r2, R - 2a - r2, r2, :blue)
   circle(0, R - 2a - 2r2 - r1, r1, :green)
   circle2(2r1, R - 2a - 2r2 - r1, r1, :green)
   circle2(r1, R - 2a - 2r2 - r3, r3)
   factor = 5R/4
   segment(-factor, R - 2a - 2r2, factor, R - 2a - 2r2, :orange)
   segment(0, R - a, factor, R - a - factor, :orange)
   segment(0, R - a, -factor, R - a - factor, :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(2r1, R - 2a - 2r2 - r1, "甲円:r1,(r2,R-2a-r1)", :black, :center, delta=-delta/2)
       point(r2, R - 2a - r2, "乙円:r2,(r2,R-2a-r2)", :black, :center, delta=-delta/2)
       point(r1, R - 2a - 2r2 - r3, "丙円:r3,(r2,R-2a-2r2-r3)", :red, :center, delta=-delta/2)
       point(0, R, " R", :green, :left, :bottom, delta=delta/2)
       point(0, R - a, "  R-a", :green, :left, :bottom, delta=delta/2)
       point(0, R - 2a, "  R-2a", :green, :left, :bottom, delta=delta/2)
       point(2a, R - a, "(2a,R-a) ", :black, :right, :bottom, delta=delta/2)
   end
end;

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

算額(その785)

2024年03月16日 | Julia

算額(その785)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

半円内に 2 本の斜線を描き,天円,地円,人円を入れる。人円の直径が与えられたとき,天円の直径を求めよ。

半円の半径と中心座標を r1, (0, 0)
天円の半径と中心座標を r2, (0, r2)
地円の半径と中心座標を r3, (x3, r3)
人円の半径と中心座標を r4, (x4, r4)
斜線と半円の交点座標を (x01, y01), (x02, y02)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive,r3::positive, x3::positive,
     r4::positive, x4::positive, y4::positive,
     x01::positive, y01::positive, x02::positive, y02::positive
eq1 = x3^2 + (r2 - r3)^2 - (r2 + r3)^2
eq2 = x3^2 + r3^2 - (r1 - r3)^2
eq3 = x4^2 + y4^2 - (r1 - r4)^2
eq4 = 2sqrt(r1^2 - (r1 - 2r4)^2) - sqrt((x01 - x02)^2 + (y01 - y02)^2)
eq5 = x01^2 + y01^2 - r1^2
eq6 = x02^2 + y02^2 - r1^2
eq7 = (x01 - x02)/(y02 - y01) - y4/x4
eq8 = r1 - 2r2
eq9 = dist(x01, y01, x02, y02, 0, r2) - r2^2
eq10 = dist(x01, y01, x02, y02, x3, r3) - r3^2;

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)
   (r1, r2, r3, x3, x4, y4, x01, y01, x02, y02) = u
   return [
       x3^2 + (r2 - r3)^2 - (r2 + r3)^2,  # eq1
       r3^2 + x3^2 - (r1 - r3)^2,  # eq2
       x4^2 + y4^2 - (r1 - r4)^2,  # eq3
       2*sqrt(r1^2 - (r1 - 2*r4)^2) - sqrt((x01 - x02)^2 + (y01 - y02)^2),  # eq4
       -r1^2 + x01^2 + y01^2,  # eq5
       -r1^2 + x02^2 + y02^2,  # eq6
       (x01 - x02)/(-y01 + y02) - y4/x4,  # eq7
       r1 - 2*r2,  # eq8
       -r2^2 + (-x01 - (-x01 + x02)*(-x01*(-x01 + x02) + (r2 - y01)*(-y01 + y02))/((-x01 + x02)^2 + (-y01 + y02)^2))^2 + (r2 - y01 - (-y01 + y02)*(-x01*(-x01 + x02) + (r2 - y01)*(-y01 + y02))/((-x01 + x02)^2 + (-y01 + y02)^2))^2,  # eq9
       -r3^2 + (r3 - y01 - (-y01 + y02)*((r3 - y01)*(-y01 + y02) + (-x01 + x02)*(-x01 + x3))/((-x01 + x02)^2 + (-y01 + y02)^2))^2 + (-x01 + x3 - (-x01 + x02)*((r3 - y01)*(-y01 + y02) + (-x01 + x02)*(-x01 + x3))/((-x01 + x02)^2 + (-y01 + y02)^2))^2,  # eq10
   ]
end;
r4 = 1/2
iniv = BigFloat[9.1, 4.6, 2.2, 6.3, 5.3, 6.6, 8.2, 3.6, 1.8, 8.8]
res = nls(H, ini=iniv)

   ([9.0, 4.5, 2.25, 6.363961030678928, 5.342584568965026, 6.611111111111111, 8.23517481947363, 3.630688046735422, 1.8214549574017131, 8.813756397709023], true)

人円の直径が 1 のとき,天円の直径は 9 である。

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

r1 = 9;  r2 = 4.5;  r3 = 2.25;  x3 = 6.36396;  x4 = 5.34258;  y4 = 6.61111;  x01 = 8.23517;  y01 = 3.63069;  x02 = 1.82145;  y02 = 8.81376

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r4 = 1/2
   (r1, r2, r3, x3, x4, y4, x01, y01, x02, y02) = res[1]
   @printf("人円の直径が %g のとき,天円の直径は %g\n", 2r4, 2r2)
   @printf("r1 = %g;  r2 = %g;  r3 = %g;  x3 = %g;  x4 = %g;  y4 = %g;  x01 = %g;  y01 = %g;  x02 = %g;  y02 = %g\n",
       r1, r2, r3, x3, x4, y4, x01, y01, x02, y02)
   plot()
   circle(0, 0, r1, beginangle=0, endangle=180)
   circle(0, r2, r2, :blue)
   circle2(x3, r3, r3, :green)
   circle2(x4, y4, r4, :magenta)
   segment(x01, y01, x02, y02, :orange)
   segment(-x01, y01, -x02, y02, :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(r1, 0, "r1  ", :red, :right, :bottom, delta=delta/2)
       point(0, 0, "半円:r1,(0,0)", :red, :center, :bottom, delta=delta/2)
       point(r1, 0, "r1  ", :red, :right, :bottom, delta=delta/2)
       point(0, r2, "天円:r2,(0,r2)", :blue, :center, :bottom, delta=delta)
       point(x3, r3, "地円:r3,(x3,r3)", :green, :center, :bottom, delta=delta)
       point(x4, y4, "人円:r4,(x4,r4) ", :black, :right, :vcenter)
       point(x01, y01, "(x01,y01)", :black, :right, :vcenter)
       point(x02, y02, "(x02,y02)", :black, :left, :bottom, delta=delta)
   end
end;

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

算額(その784)

2024年03月16日 | Julia

算額(その784)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

半円内に甲円を入れる。弧の両端から甲円に接する2直線を引き交点を頂点とする二等辺三角形を作る。斜辺に 2 点で内接し,同時に甲円に外接する乙円を入れる。乙円の直径が与えられたとき,半円の直径を求めよ。

半円の半径と中心座標を r1, (0, 0)
甲円の半径と中心座標を r2, (0, r2)
乙円の半径と中心座標を r3, (0, r3 + 2r2)
二等辺三角形の高さを h とする。
等辺のなす角度を θ とすると,sin(θ) = r1/sqrt(h^2 + r1^2) である。
以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms h::positive, r1::positive,
     r2::positive, r3::positive
sinθ = r1/sqrt(h^2 + r1^2)
eq1 = (h - r2)*sinθ - r2
eq2 = (h - r3 - 2r2)*sinθ - r3
eq3 = r1 - 2r2
res = solve([eq1, eq2, eq3], (h, r1, r2));
res[1] |> println

   (32*r3/3, 8*r3, 4*r3)

乙円の直径が 1 のとき,半円の直径は 8 である。

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

r3 = 0.5;  h = 5.33333;  r1 = 4;  r2 = 2

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

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

算額(その783)

2024年03月16日 | Julia

算額(その783)

百四 岩手県大船渡市田茂山 根城八幡宮 天保11年(1840)
山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.
http://www.wasan.jp/yamamura/yamamura.html

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

和算に挑戦_一関市博物館https://www.city.ichinoseki.iwate.jp/museum/wasan/h25/hard.html

外円内に正三角形と甲円,乙円を入れる。乙円の直径が与えられたとき,甲円の直径を求めよ。

外円の半径と中心座標を R, (0, 0)
甲円の半径と中心座標を r1,(x1, r1 - R/2)
乙円の半径と中心座標を r2, (x2, r2 - R/2), (x3, r2 - R/2), (0, r2 - R); x3 = x2 - 2r2
とおいて以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms R::positive, r1::positive, x1::positive,
     r2::positive, x2::negative, x3::negative
R = 4r2
x3 = x2 - 2r2
eq1 = x1^2 + (r1 - R/2)^2- (R - r1)^2
eq2 = (x1 - x2)^2 + (r1 - r2)^2 - (r1 + r2)^2
eq3 = x3^2 + (r2 - R/2)^2 - (R - r2)^2
solve([eq1, eq2, eq3], (r1, x1, x2))

   1-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (2*r2, 2*r2, 2*r2*(1 - sqrt(2)))

乙円の直径が 1 のとき,甲円の直径は 2 である。
なお,甲円の中心は x 軸上にある。また,横並びの 2 個の乙円は共に x 軸に接している。

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

   r2 = 0.5;  r1 = 1;  x1 = 1;  x2 = -0.414214;  x3 = -1.41421;  R = 2

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 1/2
   (r1, x1, x2) = (2*r2, 2*r2, 2*r2*(1 - sqrt(2)))
   R = 4r2
   x3 = x2 - 2r2
   @printf("r2 = %g;  r1 = %g;  x1 = %g;  x2 = %g;  x3 = %g;  R = %g\n",  r2, r1, x1, x2, x3, R)
   @printf("乙円の直径が %g のとき,甲円の直径は %g\n", 2r2, 2r1)
   plot([√3R/2, 0, -√3R/2, √3R/2], [-R/2, R, -R/2, -R/2], color=:black, lw=0.5)
   circle(0, 0, R)
   circle(x1, r1 - R/2, r1, :blue)
   circle(x2, r2 - R/2, r2, :green)
   circle(x3, r2 - R/2, r2, :green)
   circle(0, r2 - R, r2, :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, :left, :bottom, delta=delta/2)
       point(x1, r1 - R/2, "甲円:r1 \n(x1,r1-R/2)", :blue, :right, :bottom, delta=delta/2)
       point(x2, r2 - R/2, "乙円:r2\n(x2,r2-R/2)", :green, :center, :bottom, delta=delta/2)
       point(x3, r2 - R/2, "乙円:r2\n(x3,r2-R/2)", :green, :left, delta=-delta/2)
       point(0, r2 - R, "乙円:r2\n(0,r2-R)", :green, :center, delta=-delta/2)
       point(√3R/2, -R/2, "(√3R/2,-R/2) ", :black, :right, delta=-delta/2)
   end
end;

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

算額(その782)

2024年03月16日 | Julia

算額(その782)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

直角三角形の各辺を直径とする 3 個の半円と,それらの隙間に乾円 1 個,坤円 2 個を入れる。坤円の直径が与えられたとき,乾円の直径を求めよ。

直角三角形の直角を挟む二辺のうち短い方の長さを 2r1,長い方の長さを 2r2,対辺の長さを 2R とする。
乾円の半径と中心座標を r3, (r3, y3)
坤円の半径と中心座標を r4, (x4, y4), (r2, -r4)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms R::positive, r1::positive, r2::positive, r3::positive, y3::positive,
     r4::positive, x4::positive, y4::positive, x0::positive, y0::positive, d
R = sqrt(4r1^2 + 4r2^2)/2
eq1 = r1 + 2r4 - R
eq2 = x0^2 + (y0 - r1)^2 - r1^2
eq3 = y0/(2r2 - x0) - 2r1/2r2
eq4 = x4^2 + (r1 - y4)^2 - (r1 - r4)^2
eq5 = (r2 - r3)^2 + y3^2 - (r2 + r3)^2
eq6 = (r2 - x4)^2 + y4^2 - (r2 - r4)^2
eq7 = dist(0, 2r1, 2r2, 0, r3, y3) - r3^2
eq7 = div(numerator(apart(eq7, d)), r2);
eq8 = 2R*sqrt(x0^2 + y0^2) - 4r1*r2;

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)
   (r1, r2, r3, y3, x4, y4, x0, y0) = u
   return [
       r1 + 2*r4 - sqrt(4*r1^2 + 4*r2^2)/2,  # eq1
       -r1^2 + x0^2 + (-r1 + y0)^2,  # eq2
       -r1/r2 + y0/(2*r2 - x0),  # eq3
       x4^2 - (r1 - r4)^2 + (r1 - y4)^2,  # eq4
       y3^2 + (r2 - r3)^2 - (r2 + r3)^2,  # eq5
       y4^2 - (r2 - r4)^2 + (r2 - x4)^2,  # eq6
       4*r1^2*r2 - 4*r1^2*r3 - 4*r1*r2*y3 + 2*r1*r3*y3 - r2*r3^2 + r2*y3^2,  # eq7
       -4*r1*r2 + sqrt(4*r1^2 + 4*r2^2)*sqrt(x0^2 + y0^2),  # eq8
   ]
end;

r4 = 1/2
iniv = BigFloat[1.5, 2, 0.5, 2, 0.8, 0.9, 36/25, 48/25]
res = nls(H, ini=iniv);
println(res);


   ([1.5, 2.0, 0.5, 2.0, 0.8000000000009287, 0.9000000000012384, 1.44, 1.92], true)

坤円の半径が 0.5 のとき,乾円の半径は 0.5 である(坤円の半径に等しい)。

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

r1 = 1.5;  r2 = 2;  r3 = 0.5;  y3 = 2;  x4 = 0.8;  y4 = 0.9;  x0 = 1.44;  y0 = 1.92;  R = 2.5

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r4 = 0.5
   (r1, r2, r3, y3, x4, y4, x0, y0) = (1.5, 2, 0.5, 2, 0.8, 0.9, 36/25, 48/25)
   (r1, r2, r3, y3, x4, y4, x0, y0) = res[1]
   R = sqrt(4r1^2 + 4r2^2)/2
   @printf("r1 = %g;  r2 = %g;  r3 = %g;  y3 = %g;  x4 = %g;  y4 = %g;  x0 = %g;  y0 = %g;  R = %g\n",  r1, r2, r3, y3, x4, y4, x0, y0, R)
   @printf("乾円の直径 = %g;  坤円の直径 = %g\n", r4, r3)
   plot([0, 2r2, 0, 0], [0, 0, 2r1, 0], color=:black, lw=0.5)
   circle(0, r1, r1, beginangle=270, endangle=450)
   circle(r2, 0, r2, :blue, beginangle=0, endangle=180)
   circle(r3, y3, r3, :green)
   circle(x4, y4, r4, :magenta)
   circle(r2, -r4, r4, :magenta)
   circle(r2, r1, 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(x0, y0, " (x0,y0)", :black, :left, :vcenter)
       point(r2, r1, " (r2,r1)", :black, :left, :vcenter)
       point(r3, y3, "乾円:r3\n(r3,y3)", :green, :center, delta=-delta/2)
       point(x4, y4, "坤円:r4\n(x4,y4)", :magenta, :center, delta=-delta/2)
       point(r2, -r4, "坤円:r4\n(r2,-r4)", :magenta, :center, delta=-delta/2)
       point(0, 2r1, "2r1 ", :red, :right, :vcenter)
       point(0, r1, "r1 ", :red, :right, :vcenter)
       point(r2, 0, " r2", :blue, :left, :bottom, delta=delta/2)
       point(2r2, 0, " 2r2", :blue, :left, :bottom, delta=delta/2)
   else
       plot!(showaxis=false)
   end
end;

 

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

算額(その781)

2024年03月15日 | Julia

算額(その781)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

団扇の中に,2 個の大円が交差し,中円 3 個と小円 5 個が入っている。小円の直径が与えられたとき,団扇の直径を求めよ。

中円の中心点は団扇の直径の上にある。
中円の半径と中心座標を r2, (0, 0), (2r2, 0) とすれば,
大円の半径と中心座標は 2r2, (r2, 0), (-r2, 0)
団扇の半径と中心座標は 3r2, (0, 0) である。
小円の半径と中心座標を r3, (x3, y3)
とおき,以下の連立方程式を r2 を変数のまま解く。

include("julia-source.txt");

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

   (3*r2/5, 6*r2/5, 4*sqrt(3)*r2/5)

r3 = 3r2/5 となり,小円の直径が中円の直径の 3/5 倍で,外円の直径が中円の直径の 3 倍であるから,外円の直径は小円の直径の 5 倍である。

中円の半径を 5 としたとき,その他のパラメータは以下のとおりである。

団扇の半径 = 15;  小円の半径 = 3;  大円の半径 = 10;  中円の半径 = 5;  x3 = 6;  y3 = 6.9282

x3 が小円の直径と等しくなる。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 5  # 中円の半径を 5 として図を描く
   (r3, x3, y3) = (3*r2/5, 6*r2/5, 4*sqrt(3)*r2/5)
   R = 3r2
   r1 = 2r2
   @printf("団扇の直径は小円の直径の %g 倍である\n", R/r3)
   @printf("団扇の半径 = %g;  小円の半径 = %g;  大円の半径 = %g;  中円の半径 = %g;  x3 = %g;  y3 = %g\n", R, r3, r1, r2, x3, y3)
   plot()
   circle(0, 0, R)
   circle2(r2, 0, r1, :blue)
   circle(0, 0, r2)
   circle2(2r2, 0, r2)
   circle4(x3, y3, r3, :green)
   circle(0, R - r3, r3, :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(-r2, 0, " -r2", :red, :left, :bottom, delta=delta/2)
       point(r2, 0, " r2", :red, :left, :bottom, delta=delta/2)
       point(x3, y3, " 小円:r3\n(x3,y3)", :green, :center, delta=-delta/2)
       point(0, R - r3, " 小円:r3\n(0,R-r3)", :green, :center, delta=-delta/2)
   end
end;

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

算額(その780)

2024年03月15日 | Julia

算額(その780)

「祠刹匾掲算法(しさつへんけいさんぽう)第2巻」
武州阿佐个谷神明宮所掲者一事 文政11年戊子二月
關流六傅馬場小太郎正統門人
東都个谷本村住 十三歳童 宮澤新太郎種秀

https://books.google.com.mx/books/about/%E7%A5%A0%E5%88%B9%E5%8C%BE%E6%8E%B2%E7%AE%97%E6%B3%95.html?id=6jXC08Qkm7kC

難問ぞろいの算術対決 #3
https://www.saigyo.org/blog/index.php?UID=1326517227

佐藤健一:「和算で遊ぼう」,かんき出版,121ページ
小説ドラマ映画漫画アニメを解析する マスメディアの中の数学 Mathematics in Mass Media
ドラマ 水戸黄門「難問ぞろいの算術対決」

https://hb1104.blogspot.com/2011/12/blog-post.html

交差する 2 個の大円と正方形,楕円,4 個の甲円,2個の乙円がある。
10 個の円の直径,正方形の一辺,楕円の長径を加えると 149 寸のとき,楕円の短径はいかほどか。

正方形の一辺の長さを 2a
楕円の長半径,短半径を a, b
大円の半径と中心座標を r1, (a + 2r3 - r1, 0)
甲円の半径と中心座標を r2, (r2, 0), (a - r2, y2)
乙円の半径と中心座標を r3, (a + r3, 0)
とおき,以下の連立方程式を解く。
「パラメータの和が 149」という条件も方程式の一つとして組み込む。これによって,換算しなくても楕円の短半径が得られる。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, r1::positive, r2::positive, y2::positive, r3::positive
eq1 = (r1 - r2 - 2r3)^2 + y2^2 - (r1 - r2)^2
eq2 = (a^2 - b^2)*(b^2 - r2^2)/b^2 - r2^2  # 算法助術 公式84
eq3 = (r1 - 2r3)^2 + a^2 - r1^2
eq4 = (a - 2r2)^2 + y2^2 - 4r2^2
eq5 = 2a + 2r3 - 2r1  # 乙円
eq6 = 2(2r1 + 6r2 + 2r3) + 2a + 2a - 149  # 総和条件
res = solve([eq1, eq2, eq3, eq4, eq5, eq6], (a, b, r1, r2, y2, r3))

   2-element Vector{NTuple{6, Sym{PyCall.PyObject}}}:
    (745/74, 149*sqrt(5)/74, 3725/296, 149/37, 149*sqrt(15)/74, 745/296)
    (745/74, 149*sqrt(5)/37, 3725/296, 149/37, 149*sqrt(15)/74, 745/296)

2 組の解が得られるが,最初のものが適解である。得られるのは楕円の短半径なので,短径はそれを 2 倍したものである。

149*sqrt(5)/74*2

   9.004706179661316

よって,楕円の短径は 149*sqrt(5)/74*2 = 9.004706179661316 = 9寸有奇 である。

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

a = 10.0676;  b = 4.50235;  r1 = 12.5845;  r2 = 4.02703;  y2 = 7.7983;  r3 = 2.51689

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, b, r1, r2, y2, r3) = (745/74, 149*sqrt(5)/74, 3725/296, 149/37, 149*sqrt(15)/74, 745/296)
  @printf("a = %g;  b = %g;  r1 = %g;  r2 = %g;  y2 = %g;  r3 = %g\n", a, b, r1, r2, y2, r3)
   plot([a, a, -a, -a, a], [-a, a, a, -a, -a], color=:black, lw=0.5)
   ellipse(0, 0, a, b, color=:magenta)
   circle2(a + 2r3 - r1, 0, r1)
   circle2(a + r3, 0, r3, :green)
   circle2(r2, 0, r2, :blue)
   circle4(a - r2, y2, 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 + 2r3 - r1, 0, "a+2r3-r1", :red, :center, :bottom, delta=delta/2)
       point(r2, 0, "r2", :blue, :center, delta=-delta/2)
       point(a - r2, y2, "甲円:r2\n(a-r2,y2)", :blue, :center, delta=-delta/2)
       point(a + r3, 0, "乙円:r3\n(a+r2,0)", :green, :center, :bottom, delta=delta/2)
       point(a, a, "(a,a)", :black, :left, :bottom, delta=delta/2)
       point(0, b, "b", :magenta, :center, :bottom, delta=delta/2)
   end
end;

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

算額(その779)

2024年03月14日 | Julia

算額(その779)

福島県白河市南湖 南湖神社 昭和58年(1983)
http://www.wasan.jp/fukusima/nanko.html

等脚台形の中に大円が内接しており,台形との隙間に 6 個の小円が入っている。小円の直径が 1 寸のとき,大円の直径はいかほどか。

算額(その731)から内部の楕円と内円を抜き取った簡易版である。
https://blog.goo.ne.jp/r-de-r/e/14641c44eab0e2f8256131152a6cd68b

大円の中心を原点に置く。
大円の半径と中心座標を R, (0, 0)
台形の右上と右下の頂点の座標を (xb, R), (xa, -R)
小円の半径と中心座標を r2, (x1, R - r2), (x2, y2), (x3, r2)
とおき以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, xa::positive, xb::positive, r2::positive, x1::positive, x2::positive, y2::negative, x3::positive
@syms d
eq1 = dist(xa, -R, xb, R, x1, R - r2) - r2^2
eq2 = dist(xa, -R, xb, R, x2, y2) - r2^2
eq3 = dist(0, 0, xa, - R, x2, y2) - r2^2
eq1 = numerator(apart(eq1, d))
eq2 = numerator(apart(eq2, d))
eq3 = numerator(apart(eq3, d))
eq4 = x3^2 + (r2 - R)^2 - (R + r2)^2;
eq5 = x2^2 + y2^2 - (R + r2)^2
eq6 = xa*xb - R^2;
eq7 = x1^2 + (R - r2)^2 - (R + r2)^2;

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)
   (R, xa, xb, x1, x2, y2, x3) = u
   return [
       -r2^2 + (2*R - 2*R*(2*R*(2*R - r2) + (x1 - xa)*(-xa + xb))/(4*R^2 + (-xa + xb)^2) - r2)^2 + (x1 - xa - (-xa + xb)*(2*R*(2*R - r2) + (x1 - xa)*(-xa + xb))/(4*R^2 + (-xa + xb)^2))^2,  # eq1
       -r2^2 + (R - 2*R*(2*R*(R + y2) + (x2 - xa)*(-xa + xb))/(4*R^2 + (-xa + xb)^2) + y2)^2 + (x2 - xa - (-xa + xb)*(2*R*(R + y2) + (x2 - xa)*(-xa + xb))/(4*R^2 + (-xa + xb)^2))^2,  # eq2
       -r2^2 + (x2 - xa*(-R*y2 + x2*xa)/(R^2 + xa^2))^2 + (R*(-R*y2 + x2*xa)/(R^2 + xa^2) + y2)^2,  # eq3
       x3^2 + (-R + r2)^2 - (R + r2)^2,  # eq4
       x2^2 + y2^2 - (R + r2)^2,  # eq5
       -R^2 + xa*xb,  # eq6
       x1^2 + (R - r2)^2 - (R + r2)^2,  # eq7
   ]
end;

r2 = 1/2
iniv = BigFloat[7.1, 8, 6.1, 5.3, 6.6, -4.5, 3]
res = nls(H, ini=iniv)

   ([3.5, 3.968626966596886, 3.086709862908689, 2.6457513110645907, 3.307189138830738, -2.25, 2.6457513110645907], true)

大円の直径は小円の直径の 7 倍である。
小円の直径が 1 寸のとき,大円の直径は 7 寸である。

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

R = 3.5;  xa = 3.96863;  xb = 3.08671;  x1 = 2.64575;  x2 = 3.30719;  y2 = -2.25;  x3 = 2.64575

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 1/2
   (R, xa, xb, x1, x2, y2, x3) = res[1]
   @printf("R = %g;  xa = %g;  xb = %g;  x1 = %g;  x2 = %g;  y2 = %g;  x3 = %g\n", R, xa, xb, x1, x2, y2, x3)
   plot([xa, xb, -xb, -xa, xa], [-R, R, R, -R, -R], color=:blue, lw=0.5)
   circle(0, 0, R)
   circle2(x3, r2 - R, r2, :green)
   circle2(x1, R - r2, r2, :green)
   circle2(x2, y2, r2, :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", :blue, :center, :bottom, delta=delta/2)
       point(xa, -R, "(xa,-R)", :black, :right, :bottom, delta=delta/2)
       point(xb, R, "(xb,R)", :black, :right, :bottom, delta=delta/2)
       point(x1, R - r2, "(x1,R-r2)", :red, :right, :bottom, delta=delta)
       point(x2, y2, "小円:r2,(x2,y2)", :red, :right, :vcenter)
       point(x3, r2 - R, " (x3,r2-R)", :red, :left, :vcenter)
   end
end;

 

 

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

算額(その778)

2024年03月13日 | Julia

算額(その778)

川田保知:『算法極数小補解義』 文化15年戊寅正月
山口正義:やまぶき,第26号

https://yamabukiwasan.sakura.ne.jp/ymbk26.pdf

直角三角形内に斜線(文斜と命名)を入れ,股の一部分を武斜と命名する。
文斜と武斜を 2 寸,7 寸に固定したとき,股は武斜 + x になる。面積が最大になるときの股はいかほどか。

直角三角形の面積は x の関数になる。面積を求める式を微分し,接線の傾きが 0 になるときの x を求める。

include("julia-source.txt");

using SymPy
@syms 鈎::positive, 股::positive, 文斜::positive, 武斜::positive, x::positive
S = sqrt(文斜^2 - x^2) * (武斜 + x)//2  # 鈎*股/2
S |> println

   (x/2 + 武斜/2)*sqrt(-x^2 + 文斜^2)

直角三角形の面積 S は x の関数である。

たとえば,文斜,武斜がそれぞれ 2, 7 のとき,面積は x が 0.5 前後で最大になる。

S2 = S(文斜 => 2, 武斜 => 7)
using Plots
pyplot(size=(500, 200), grid=false, aspectratio=:none, label="", fontfamily="IPAMincho")
p1 = plot(S2, xlims=(0, 2), xlabel="x", ylabel="面積 S")
p2 = plot(S2, xlims=(0.4, 0.6), xlabel="x", ylabel="面積 S", title="左図の拡大図", titlefont=11)
plot!(p1, p2)

接線の傾きが 0 になるときの x は,(sqrt(8*文斜^2 + 武斜^2) - 武斜)/4 である。

山口はまだ術を解読できていないとしているが「術曰置併文斜▢八段武斜▢開平方」の部分は sqrt(8*文斜^2 + 武斜^2) に相当するであろう。二箇所の▢は「乗」と思われる。引き続く「加武斜三段皈」はわからない。特に「皈」が。

f = diff(S, x)
res2 = solve(f, x)[1]
res2 |> println
res2.evalf() |> println

   -武斜/4 + sqrt(8*文斜^2 + 武斜^2)/4
   -0.25*武斜 + 0.707106781186548*(文斜^2 + 0.125*武斜^2)^0.5

文斜,武斜がそれぞれ 2, 7 のとき,面積は x が 0.5 のとき最大になる。
また,そのときの股は,股 = 武斜 + 0.5 = 7.5 である。

x = res2(文斜 => 2, 武斜 => 7)
x |> println

   1/2

文斜,武斜がそれぞれ 2, 7 のとき,x が 0.5 のとき,面積は最大値 7.26184377413891 になる。

文斜が 2,武斜が 7 のとき,股(= 武斜 + x)が 7.5 のとき,直角三角形の面積が最大になる(x = 0.5)。

S = sqrt(文斜^2 - x^2) * (武斜 + x)//2
S |> println
S(x => 0.5, 文斜 => 2, 武斜 => 7).evalf() |> println

   sqrt(文斜^2 - 1/4)*(武斜/2 + 1/4)
   7.26184377413891

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (文斜, 武斜) = (2, 7)
   x = 0.5
   鈎 = sqrt(文斜^2 - x^2)
   股 = 武斜 + x
   @printf("文斜が %g,武斜が %g のとき,股(= 武斜 + x)が %g のとき,直角三角形の面積が最大になる(x = %g)。\n", 文斜, 武斜, 武斜 + x, x)
   plot([0, 股, 0, 0], [0, 0, 鈎, 0], color=:red, lw=0.5)
   segment(0, 鈎, x, 0, :blue)
   segment(x, 0, 股, 0, :green, lw=1)
   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, "x+武斜 = 股", :red, :right, delta=-3delta)
       point(0, 鈎, " 鈎", :red, :left, :bottom, delta=delta)
       point(x, 0, " x", :blue, :left, :bottom, delta=delta)
       point(x, 鈎/2, "文斜", :blue, :left, mark=false)
       point(股/2, 0, "武斜", :green, :left, :bottom, delta=2delta, mark=false)
       plot!(ylims=(-0.5, 2.1))
   end
end;

 

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

算額(その777)

2024年03月13日 | Julia

算額(その777)

川田保知:『算法極数小補解義』 文化15年戊寅正月
山口正義:やまぶき,第26号

https://yamabukiwasan.sakura.ne.jp/ymbk26.pdf

2 個の甲円が交差してできる区画に,乙円と丙円を入れる。丙円の直径が最大になるときの乙円の直径を求めよ。

甲円の半径と中心座標を r1, (r1, 0), (r1 + 2r2, 0)
乙円の半径と中心座標を r2, (r2, 0)
丙円の半径と中心座標を r3, (x3, y3)
とおき,r2 を変数のまま r3, x3, y3 を求める。
r3 は r2 の関数になるので,r3 を r2 で微分し,接線の傾きが 0 になるときの r2 を求める。

include("julia-source.txt");

using SymPy
@syms r1::positive, r2::positive, r3::positive, x3::positive, y3::positive
r1 = 35//2
eq1 = (r1 - x3)^2 + y3^2 - (r1 - r3)^2
eq2 = (x3 - r2)^2 + y3^2 - (r2 + r3)^2
eq3 = (r1 + 2r2 - x3)^2 + y3^2 - (r1 + r3)^2
res1 = solve([eq1, eq2, eq3], (r3, x3, y3));

丙円の半径は,乙円の半径の関数である。

r3 = res1[1][1] |> simplify
r3 |> println

   r2*(1225 - 4*r2^2)/(4*r2^2 + 1225)

res1[1][2] |> simplify |> println
res1[1][3] |> simplify |> println

   r2*(2*r2 + 35)^2/(4*r2^2 + 1225)
   70*r2*sqrt(1225 - 4*r2^2)/(4*r2^2 + 1225)

乙円の半径 r2 が 7.5〜10.0 の範囲内で丙円の半径 r3 が最大になる。

using Plots
pyplot(size=(300, 200), grid=false, aspectratio=:none, label="", fontfamily="IPAMincho")
plot(r3, xlims=(0, 17.5), xlabel="乙円の半径 r2", ylabel="丙円の半径 r3")

r3 を r2 で微分して,接線の傾きが 0 になるときの r2 を求めると 8.50269475574130 である。つまり,乙円の直径が 17.0053895114826 のとき丙円の直径が最も大きくなる。

f = diff(r3, r2)
res2 = solve(f, r2)[1]
res2 |> println
res2.evalf() |> println

   35*sqrt(-1/2 + sqrt(5)/4)
   8.50269475574130

もっとも大きいときの丙円の半径は 5.25495435501361(直径は 10.5099087100272 である)。

2r3(r2 => res2[1]).evalf() |> println

   10.5099087100272

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

   r1 = 17.5;  r2 = 8.50269;  r3 = 5.25495;  x3 = 15.1871;  y3 = 12.0246

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 35//2
   r2 = 35sqrt(√5 - 2)/2
   t = r2/(4r2^2 + 1225)
   (r3, x3, y3) = t .* (
       1225 - 4r2^2,
       (2*r2 + 35)^2,
       70sqrt(1225 - 4r2^2))
   @printf("乙円の直径が %g のとき,丙円の直径は最大値 %g になる。\n", 2r2, 2r3)
   @printf("r1 = %g;  r2 = %g;  r3 = %g;  x3 = %g;  y3 = %g\n", r1, r2, r3, x3, y3)
   plot()
   circle(r1, 0, r1)
   circle(r1 + 2r2, 0, r1)
   circle(r2, 0, r2, :blue)
   circle22(x3, y3, r3, :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(r1, 0, " 甲円:r1,(r1,0)", :red, :left, delta=-delta)
       point(r1 + 2r2, 0, " 甲円:r1,(r1+2r2,0)", :red, :left, delta=-delta)
       point(r2, 0, "乙円:r2,(r2,0)", :blue, :center, delta=-delta)
       point(x3, y3, "丙円:r3\n(x3,y3)", :green, :center, :bottom, delta=delta)
   end
end;

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

算額(その776)

2024年03月13日 | Julia

算額(その776)

埼玉県東松山市 岩殿観音(正法寺) 文政6年(1823)
山口正義:やまぶき,第30号

https://yamabukiwasan.sakura.ne.jp/ymbk30.pdf

二四 武州比企郡紫竹村 観世音堂 文政6年(1823)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.
キーワード:円6個,半円,正三角形

外円(半円)内に大円,小円,正三角形,および正三角形内に全名円,等円が入っている。正三角形の一辺の長さは外円の半径に等しい。等円の直径が与えられたとき,外円,大円,小円の直径を求めよ。

外円の半径と中心座標を R,(0, 0)
大円の半径と中心座標を r1, (x1, r1)
小円の半径と中心座標を r2, (x2, r2)
正三角形の一辺の長さは R
全名円の半径と中心座標を r3, (-R/2, r3)
等円の半径と中心座標を r4, (x4, r4)
とおく。
大円,小円の配置と正三角形及びその内部の円の配置は独立である。
既知の変数は r4 であるが,まずは R を基準として正三角形の内部の全名円,等円のパラメータを求める。
全名円の半径は r3 = 2R/√3 であることはすぐわかる。r4, x4 については以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r1::positive, x1::positive, r2::positive, x2::positive,
     r3::positive, r4::positive, x4::negative
s3 = sqrt(Sym(3))
r3 = (R/2)/s3
eq1 = r4*(R/2) + r3*x4
eq2 = (R/2 + x4)^2 + (r3 - r4)^2 - (r3 + r4)^2;
res1 = solve([eq1, eq2], (r4, x4))

   2-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (sqrt(3)*R/18, -R/6)
    (sqrt(3)*R/2, -3*R/2)

2 組の解が得られるが,最初のものが適解である。
等円の半径 r4 は r4 = R*√3/18 である。r4 が既知であるならば,R = 18r4/√3 である。
ついで,R = 18r4/√3 として,大円と小円のパラメータを求める。

R = 18r4/s3
eq3 = x1^2 + r1^2 - (R - r1)^2
eq4 = x2^2 + r2^2 - (R - r2)^2
eq5 = (x2 - x1)^2 + (r1 - r2)^2 - (r1 + r2)^2
eq6 = dist(-R/2, s3*R/2, 0, 0, x1, r1) - r1^2;
res = solve([eq3, eq4, eq5, eq6], (r1, x1, r2, x2));

それぞれは若干長い式になるが,二重根号を外すなどの簡約化を行うと以下のようになる。

res[1][1] |> sympy.sqrtdenest |> simplify |> println
res[1][2] |> sympy.sqrtdenest |> simplify |> println
res[1][3] |> sympy.sqrtdenest |> simplify |> println
res[1][4] |> sympy.sqrtdenest |> simplify |> println

   18*r4*(2 - sqrt(3))
   6*r4*(-3 + 2*sqrt(3))
   18*r4*(-62*sqrt(2) - 41*sqrt(3) + 24*sqrt(6) + 150)/529
   6*r4*(-12*sqrt(2) - 2*sqrt(3) + 9 + 18*sqrt(6))/23

大円の直径は等円の直径の 18(2 - √3) 倍,小円の直径は等円の直径の 18(24√6 - 62√2 - 41√3 + 150)/529 倍である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   s3 = √3
   r4 = 1
   R = 18r4/s3
   x4 = -R/6
   r3 = R/2s3
   (r1, x1, r2, x2) = r4 .* (18(2 - √3), 6(2√3 - 3), 18(24√6 - 62√2 - 41√3 + 150)/529, 6(18√6 - 12√2 - 2√3 + 9)/23)
   @printf("R = %g;  r1 = %g;  x1 = %g;  r2 = %g;  x2 = %g;  r3 = %g;  r4 = %g;  x4 = %g\n", R, r1, x1, r2, x2, r3, r4, x4)
   plot([-R, 0, -R/2, -R], [0, 0, R√3/2, 0], color=:black, lw=0.5)
   circle(0, 0, R, beginangle=0, endangle=180)
   circle(x1, r1, r1, :blue)
   circle(x2, r2, r2, :orange)
   circle(-R/2, r3, r3, :green)
   circle(x4, r4, r4, :magenta)
   circle(-R - x4, r4, r4, :magenta)

   circle(-R/2, 2r3 + r4, r4, :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(R, 0, " R", :red, :left, :bottom, delta=delta/2)
       point(x1, r1, "大円:r1,(x1,r1)", :blue, :center, delta=-delta)
       point(x2, r2, "小円:r2\n(x2,r2)", :black, :center, delta=-delta)
       point(-R/2, r3, "全名円:r3\n(-R/2,r3)", :green, :center, delta=-delta)
       point(x4, r4, "等円:r4,(x4,r4)", :magenta, :left, delta=-delta)
   end
end;

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

算額(その775)

2024年03月12日 | Julia

算額(その775)

福島県二本松市 新田神社 元治元年(1864)
http://www.wasan.jp/fukusima/sinden.html

正方形内に交差する 2 個の楕円と,区画された領域に甲円 1 個,乙円 4 個が入っている。甲円の直径が 4 寸,乙円の直径が 3 寸のとき,正方形の面積はいかほどか。

計算を簡単にするために図形を 45 度回転し楕円の長軸・短軸が x-y 軸に載るようにする。
楕円の長半径と短半径と中心座標をそれぞれ a, b, (0, 0)
甲円の半径と中心座標を r1, (0, 0); 甲円の半径は楕円の短半径に等しい。r1 = b
乙円の半径と中心座標を r2, (b + r2, 0)
楕円と乙円の交点座標を (x0, y0)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, x0::positive, y0::positive, r1, r2, x1, y1
r2 = 3//2
r1 = b = 4//2
eq1 = x0^2/a^2 + y0^2/b^2 - 1
eq2 = -b^2*x0/(a^2*y0) + (x0 - b - r2)/y0
eq3 = (x0 - b - r2)^2 + y0^2 - r2^2
res1 = solve([eq1, eq2, eq3], (a, x0, y0));
res1[4]

   (sqrt(2)*b^(3/2)*sqrt(1/(b - r2)), 2*b, sqrt(b)*sqrt(-b + 2*r2))

4 組の解が得られるが,最後のものが適解である。

楕円が内接する正方形は,楕円と正方形の一辺の接点を (x1, y1) とした以下の連立方程式を解く。

@syms x1::positive, y1::positive
r2 = 3//2
r1 = b = 4//2
a = sqrt(Sym(2))*b^(3//2)*sqrt(1/(b - r2))
eq4 = x1^2/a^2 + y1^2/b^2 - 1
eq5 = -b^2*x1/(a^2*y1) + 1
res2 = solve([eq4, eq5], (x1, y1));
res2[2]

   (2*b^2*sqrt((b - r2)/(3*b - r2))/(b - r2), b*sqrt((b - r2)/(3*b - r2)))

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

接点を通る傾き -1 の直線が x-y 軸で切り取られるものが正方形の一辺 sl である。x2 は x 切片(x 軸との交点)。

x2 = x1 + y1
sl = x2*√2

甲円の直径が 4 寸,乙円の直径が 3 寸のとき,正方形の一辺の長さは 8.48528,正方形の面積は 72 歩である。

sl = sqrt(Sym(2)) * (res2[2][1] + res2[2][2]) |> simplify
sl |> println
sl(b => 4//2, r2 => 3//2).evalf() |> println
sl(b => 4//2, r2 => 3//2)^2 |> println

   sqrt(2)*b*sqrt((b - r2)/(3*b - r2))*(3*b - r2)/(b - r2)
   8.48528137423857
   72

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

   r1 = 2;  r2 = 1.5;  a = 5.65685;  b = 2;  x0 = 4;  y0 = 1.41421;  x1 = 5.33333;  y1 = 0.666667;  x2 = 6

もとの位置で図を描くのも簡単だが,わかりやすくするために回転させたままの図を描く。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = b = 4//2
   r2 = 3//2
   (a, x0, y0) = (sqrt(2)*b^(3/2)*sqrt(1/(b - r2)), 2*b, sqrt(b)*sqrt(-b + 2*r2))
   (x1, y1) = (2.0*b^2*sqrt((b - r2)/(3.0*b - r2))/(b - r2), b*sqrt((b - r2)/(3.0*b - r2)))
   x2 = x1 + y1
   sl = x2*√2
   @printf("正方形の一辺の長さは %g,面積は %g\n", sl, sl^2)
   @printf("r1 = %g;  r2 = %g;  a = %g;  b = %g;  x0 = %g;  y0 = %g;  x1 = %g;  y1 = %g;  x2 = %g\n",
       r1, r2, a, b, x0, y0, x1, y1, x2)
   plot([0, x2, 0, -x2, 0], [-x2, 0, x2, 0, -x2], color=:blue, lw=0.5)
   ellipse(0, 0, a, b, color=:green)
   ellipse(0, 0, b, a, color=:green)
   circle(0, 0, r1, :magenta)
   circle42(0, b + r2, r2)
   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, 0, "甲円:r1\n(0,0)", :magenta, :center, delta=-delta)
       point(b + r2, 0, "乙円:r2\n(b+r2,0)", :red, :center, delta=-delta)
       point(x0, y0, "(x0,y0)", :green, :right, delta=-delta)
       point(x1, y1, " (x1,y1)", :green, :left, :vcenter)
       point(x2, 0, " x2", :blue, :left, delta=-delta/2)
   end
end;

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

算額(その774)

2024年03月12日 | Julia

算額(その774)

宮城県白石市小原 小原温泉薬師堂 大正5年(1916)
徳竹亜紀子,谷垣美保:宮城県白石市小原地区の算額調査,仙台高等専門学校名取キャンパス研究紀要,第57号,2021.

https://www.sendai-nct.ac.jp/natori-library/wp/wp-content/uploads/2021/04/No57_2.pdf

愛媛県松山市 伊佐爾波神社(19) 山崎昌竜門人桐野富五郎季長 奉納 明治11年(1878)
http://www.wasan.jp/ehime/isaniwa19.html

甲円,丁円,己円に挟まれて戊円がそれぞれに外接している。丁円,戊円,己円の直径がそれぞれ 3 寸,1 寸,2 寸のとき,甲円の直径はいかほどか。

甲円の半径と中心座標を r1, (x1, y1)
丁円の半径と中心座標を r2
戊円の半径と中心座標を r3
己円の半径と中心座標を r4
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms r1::positive, x1::positive, y1::positive, r2::positive, r3::positive, r4::positive
eq1 = x1^2 + y1^2 - (r1 + r2)^2
eq2 = x1^2 + (r2 + r3 - y1)^2 - (r1 + r3)^2
eq3 = x1^2 + (r2 + 2r3 + r4 - y1)^2 - (r1 + r4)^2
res = solve([eq1, eq2, eq3], (r1, x1, y1))

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

丁円の直径 = 3;  戊円の直径 = 1;  己円の直径 = 2 のとき,甲円の直径 = 2.4

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

r1 = 1.2;  x1 = 1.69706;  y1 = 2.1

function draw(more=false)
   pyplot(size=(400, 400), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r2, r3, r4) = (3, 1, 2) .// 2
   (r1, x1, y1) = (r3*(r2 + r3)*(r3 + r4)/(r2*r4 - r3^2), 2*sqrt(r2)*r3*sqrt(r4)*sqrt(r2 + r3)*sqrt(r3 + r4)/(r2*r4 - r3^2), (r2^2*r4 + r2*r3*r4 - r3^3 - r3^2*r4)/(r2*r4 - r3^2))
   @printf("丁円の直径 = %g;  戊円の直径 = %g;  己円の直径 = %g のとき,甲円の直径 = %g\n", 2r2, 2r3, 2r4, 2r1)
   @printf("r1 = %g;  x1 = %g;  y1 = %g\n", r1, x1, y1)
   plot()
   circle(0, 0, r2)
   circle(0, r2 + r3, r3, :blue)
   circle(0, r2 + 2r3 + r4, r4, :green)
   circle2(x1, y1, r1, :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(x1, y1, " 甲円:r1,(x1,y1)", :magenta, :center, delta=-delta/2)
       point(0, 0, " 丁円:r2,(0,0)", :red, :center, delta=-delta/2)
       point(0, r2 + r3, "戊円:r3,(0,r2+r3) ", :black, :right, :vcenter)
       point(0, r2 + 2r3 + r4, "己円:r4\n(0,r2+2r3+r4)", :green, :center, delta=-delta/2)
   end
end;

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

算額(その773)

2024年03月12日 | Julia

算額(その773)

宮城県白石市小原字馬頭山 三瀧神社奉納算額(萬蔵稲荷神社所蔵) 明治8年
徳竹亜紀子,谷垣美保:宮城県白石市小原地区の算額調査,仙台高等専門学校名取キャンパス研究紀要,第57号,2021.

https://www.sendai-nct.ac.jp/natori-library/wp/wp-content/uploads/2021/04/No57_2.pdf

平面上に直径 6 寸の乙球 3 個が互いに接して載っている。更にその中央部に甲球が載っており,甲球のてっぺんまでの高さが 12 寸である。
甲球の直径はいかほどか。

甲球の半径と中心座標を r1, (0, 0, 12 - r1)
乙球の半径と中心座標を r2, (r2, -r2/√3, r2), (0, 2r2/√3, r2)とおく。

上方(z軸方向)から見下ろしたとき,乙球の中心は正三角形を構成している。z 軸から y 軸方向にある球の中心の水平距離は 2r2√3 である。

次に y z 平面において,甲球と乙球の中心間の距離についてピタゴラスの定理を適用する。

以下の方程式を解けば,甲球の半径を求めることができる。

using SymPy
@syms r1, r2
r2 = 6//2
eq = (12 - r1 - r2)^2 + (2r2/√Sym(3))^2 - (r1 + r2)^2;
solve(eq, r1)#[1] |> println

   1-element Vector{Sym{PyCall.PyObject}}:
    r2^2/18 - r2 + 6

甲球の半径は,乙球の半径を二乗し 18 で割り,乙球の半径を引き 6 を加えると求まる。
乙球の半径が 6/2 寸ならば,甲球の直径は 2((6/2)^2/18 - 6/2 + 6) = 7 寸である。

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

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

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