裏 RjpWiki

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

手打ちうどん 三徳

2025年02月01日 | さぬきうどん

高松市林町 手打ちうどん 三徳
いつものしっぽくうどんやや太麺
ちょっと変わった店構え

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

算額(その1577)

2025年02月01日 | Julia

算額(その1577)

愛知県名古屋市中央区 大須観音(北野山真福寺寶生院) 天保8年(1837)
藤安順:所掲大須観音堂解義
山田潤:動的幾何ソフトウエアを利用した平面図形の作図についての一考察 - 和算所にある平面図形問題の利用 -
2023018-Yamada.pdf

https://www.kurims.kyoto-u.ac.jp/~kyodo/kokyuroku/contents/pdf/2273-19.pdf

キーワード:円10個,外円
#Julia, #SymPy, #算額, #和算

外円の中に大円 4 個,甲円 3 個,乙円を 2 個容れる。甲円の直径が 1 寸のとき,乙円および外円の直径はいかほどか。

算額(その1575)は,深川が意図的に大円が交差する部分にある円を省略し,甲円と乙円の関係を述べさせるものであったようだ。

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

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

using SymPy
@syms R::positive, r1::positive, x1::positive,
      r2::positive, r3::positive
x1 = r1 - r2
eq1 = R - (2r1 + r2)
eq2 = x1^2 + r1^2 - (r1 + r2)^2  # 大円と甲円が接する
eq3 = x1^2 + (R - r3 - r1)^2 - (r1 + r3)^2;  # 大円と乙円が接する

res = solve([eq1, eq2, eq3], (R, r1, r3))[1]

    (9*r2, 4*r2, r2)

外円の直径は甲円の直径の 9 倍,大円の直径は甲円の直径の 4 倍,乙円の直径は甲円の直径に等しい。

考察:大円の交差するところに甲円が入っているのが,算額(その1575)での y1 の制約条件になっている。

function draw(r2, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
    (R, r1, r3) = (9*r2, 4*r2, r2)
    plot()
    circle(0, 0, R, :green)
    circle4(r1 - r2, r1, r1, :blue)
    circle(0, 0, r2)
    circle22(0, r1, r3)
    circle22(0, R - r3, r3, :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(0, R, "R", :green, :center, :bottom, delta=delta/2)
        point(r1 - r2, r1, "大円:r1,(r1-r2,r1)", :blue, :center, delta=-delta, deltax=5delta)
        point(0, R - r3, "乙円:r3,(0,R-r3)", :magenta, :left, :bottom, delta=delta/2, deltax=4delta)
        point(0, r1, "甲円:r2,(0,r1)", :red, :right, :vcenter, deltax=-4delta)
    end
end;

draw(1/2, true)

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

算額(その1576)

2025年02月01日 | Julia

算額(その1576)

佐久間纉:算法起源集,1877.
https://kokusho.nijl.ac.jp/biblio/100234582/69?ln=ja

山田潤:動的幾何ソフトウエアを利用した平面図形の作図についての一考察 - 和算所にある平面図形問題の利用 -
2023018-Yamada.pdf

https://www.kurims.kyoto-u.ac.jp/~kyodo/kokyuroku/contents/pdf/2273-19.pdf

キーワード:円7個,外円
#Julia, #SymPy, #算額, #和算

外円の中に甲円,乙円,丙円を 2 個ずつ容れる。甲円,乙円,丙円の直径が与えられたとき,外円の直径はいかほどか。

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

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

using SymPy
@syms R::positive, r1::positive,
      r2::positive, x2::positive, y2::negative,
      r3::positive, x3::positive, y3::positive
eq1 = x2^2 + y2^2 - (R - r2)^2 |> expand
eq2 = x3^2 + y3^2 - (R - r3)^2 |> expand
eq3 = x2^2 + (y2 - r1 + R)^2 - (r1 + r2)^2 |> expand
eq4 = x3^2 + (R - r1 - y3)^2 - (r1 + r3)^2 |> expand
eq5 = (x3 - x2)^2 + (y3 - y2)^2 - (r2 + r3)^2 |> expand;

まず,eq1, eq3 の連立方程式から x2, y2 を求める。

res2 = solve([eq1, eq3], (x2, y2))[1]

    (-2*sqrt(R)*sqrt(r1)*sqrt(r2)*sqrt(R - r1 - r2)/(-R + r1), -(-R^2 + R*r1 + R*r2 + r1*r2)/(-R + r1))

次に,eq2, eq4 の連立方程式から x3, y3 を求める。

res3 = solve([eq2, eq4], (x3, y3))[1]

    (-2*sqrt(R)*sqrt(r1)*sqrt(r3)*sqrt(R - r1 - r3)/(-R + r1), (-R^2 + R*r1 + R*r3 + r1*r3)/(-R + r1))

eq5 の x2, y2, x3, y3 に求められた解を代入し,整理する。

eq15 = eq5(x2 => res2[1], y2 => res2[2], x3 => res3[1], y3 => res3[2])/R |> simplify |> numerator;

しかし,このままでは SymPy では解けない。

eq15 |> println

    4*R^3 - 8*R^2*r1 - 4*R^2*r2 - 4*R^2*r3 + 4*R*r1^2 + 4*R*r1*r2 + 4*R*r1*r3 - 8*r1*sqrt(r2)*sqrt(r3)*sqrt(R - r1 - r2)*sqrt(R - r1 - r3) + 8*r1*r2*r3

8*r1*sqrt(r2)*sqrt(r3)*sqrt(R - r1 - r2)*sqrt(R - r1 - r3) の項とそれ以外の項をそれぞれ二乗し,方程式を再構成する。

eq25 = (4*R^3 - 8*R^2*r1 - 4*R^2*r2 - 4*R^2*r3 + 4*R*r1^2 + 4*R*r1*r2 + 4*R*r1*r3 + 8*r1*r2*r3)^2 - ( - 8*r1*sqrt(r2)*sqrt(r3)*sqrt(R - r1 - r2)*sqrt(R - r1 - r3))^2;

ここまで来ると SymPy でも解ける。

res = solve(eq25)[2];  # 2 of 5
res[R] |> println

    r1 + r2 + r3

外円の半径は,甲円,乙円,丙円の半径の合計である。

なお,x2 = x3 であることがわかる。

# x2
res2[1](R => r1 + r2 + r3) |> println
# x3
res3[1](R => r1 + r2 + r3) |> println

    -2*sqrt(r1)*sqrt(r2)*sqrt(r3)*sqrt(r1 + r2 + r3)/(-r2 - r3)
    -2*sqrt(r1)*sqrt(r2)*sqrt(r3)*sqrt(r1 + r2 + r3)/(-r2 - r3)

function draw(r1, r2, r3, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
    R = r1 + r2 + r3
    (x2, y2) = (-2*sqrt(R)*sqrt(r1)*sqrt(r2)*sqrt(R - r1 - r2)/(-R + r1), -(-R^2 + R*r1 + R*r2 + r1*r2)/(-R + r1))
    (x3, y3) = (-2*sqrt(R)*sqrt(r1)*sqrt(r3)*sqrt(R - r1 - r3)/(-R + r1), (-R^2 + R*r1 + R*r3 + r1*r3)/(-R + r1))
    @printf("r1 = %g;  r2 = %g;  r3 = %g;  R = %g;  x2 = %g;  y2 = %g;  x3 = %g;  y3 = %g\n",
        r1, r2, r3, R, x2, y2, x3, y3)
    plot()
    circle(0, 0, R, :green)
    rotate(0, R - r1, r1, angle=180)
    rotate(x2, y2, r2, :blue, angle=180)
    rotate(x3, y3, r3, :magenta, angle=180)
    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", :green, :center, :bottom, delta=delta/2)
        point(0, R - r1, "甲円:r1,(0,R-r1)", :red, :center, delta=-delta/2)
        point(x2, y2, "乙円:r2,(x2,y2)", :blue, :center, delta=-delta/2)
        point(x3, y3, "丙円:r3\n(x3,y3)", :magenta, :center, delta=-delta/2)
    end
end;

draw(0.5, 0.3, 0.2, true)

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

算額(その1575)

2025年02月01日 | Julia

算額(その1575)

愛知県名古屋市中央区 大須観音(北野山真福寺寶生院) 天保8年(1837)
深川英俊,トニー・ロスマン:聖なる数学:算額,森北出版株式会社,2010年4月22日.

キーワード:円8個,外円
#Julia, #SymPy, #算額, #和算

外円の中に,大円 4 個,小円 3 個を容れる。外円と小円の直径が与えられたとき,大円の直径はいかほどか。

深川は,「中央の小円1と左右の小円2の直径の関係を示せ」という問題としている。
図を見ただけで直径は等しいとわかるが,ちゃんと式で示せということではある。
大円の中心の y 座標はどんな非負の値も取れるが,3個の小円の直径は同じであるということで,算額問題としては,「大円の直径を外円と小円の直径であらわせ」という問題にした。

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

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

    (-(-R + r2)/2, sqrt(R)*sqrt(r2))

大円の直径は,外円の直径から小円の直径を差し引いたものの半分である。

外円の直径が同じでも,小円の直径により印象の異なる図が得られる。

function draw(R, r2, more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
    (r1, y1) = ((R - r2)/2, sqrt(R)*sqrt(r2))
    r3 = r2
    p = plot()
    circle(0, 0, R, :green)
    circle4(r1, y1, r1, :magenta)
    circle2(R - r2, 0, r2, :blue)
    circle(0, 0, r3)
    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", :green, :left, :bottom, delta=delta/2, deltax=delta/2)
        point(R - r2, 0, "R-r2", :blue, :center, delta=-delta)
        point(r3, 0, "r3", :red, :right, :vcenter, deltax=-delta/2)
        point(r1, y1, "大円:r1,(r1,y1)", :magenta, :center, :bottom, delta=delta/2)
        pos = max(R, r2)
        str = @sprintf(" R=%.3g, r2=%.3g", R, r2)
        point(0, pos, str, :black, :center, :bottom, delta=delta, mark=false)
    end
    return p
end;

draw(1, 0.1, true)

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

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

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