裏 RjpWiki

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

算額(その729)

2024年02月25日 | Julia

算額(その729)

富岡村天王社 明治26年
街角の数学 Street Wasan 街角の数学 ~落書き帳「○△□」~ 539. 関根熊吉の算額

http://streetwasan.web.fc2.com/math19.1.22.html

直角三角形内に,内接円と直角の頂点から斜辺(弦)への垂線(中鈎)を入れる。
直角三角形の 3 辺の長さの積が 60 寸(立方寸であるが細かいことは言わない),内接円の直径が 2 寸のとき,短弦(弦と中鈎の交点で区切られる弦の短い方)の長さはいかほどか。

直角を挟む短い方の辺と長い方の辺を,「鈎」,「股」,斜辺を「弦」,中鈎,短弦を「中鉤」,「短弦」という変数にする。
内接円の半径と中心座標を r, (股-r, r)
として以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms 鈎::positive, 股::positive, 弦::positive, 中鈎::positive, 短弦::positive

r = 2//2
弦 = sqrt(鈎^2 + 股^2)
eq1 = 鈎*股*弦 - 60
eq2 = 鈎 + 股 - 弦 - 2r  # 有名な公式
eq3 = 弦*中鈎 - 股*鈎
eq4 = 短弦/中鈎 - 鈎/股
res = solve([eq1, eq2, eq3, eq4], (鈎, 股, 中鈎, 短弦))

   2-element Vector{NTuple{4, Sym{PyCall.PyObject}}}:
    (3, 4, 12/5, 9/5)
    (4, 3, 12/5, 16/5)

一般に,鈎 < 股 なので,最初のものが適解である。すなわち,短弦は 9/5 寸,すなわち 1 寸 8 分である。

図を描く必要がなければこれで十分である。

図を描くためには中鉤と弦の交点座標があればよい。

交点の座標を (x, y) とする(y 座標は x*鈎/股 であるが,連立させて求める)。

2 条件を追加して連立方程式を解く。

@syms x::positive, y::positive
eq5 = (鈎 - y)/(股 - x) - 鈎/股
eq6 = sqrt(x^2 + y^2) + 短弦 - 弦
res = solve([eq1, eq2, eq3, eq4, eq6, eq5], (鈎, 股, 中鈎, 短弦, x, y))

   2-element Vector{NTuple{6, Sym{PyCall.PyObject}}}:
    (4, 3, 12/5, 16/5, 27/25, 36/25)
    (3, 4, 12/5, 9/5, 64/25, 48/25)

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

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = 2//2
   (鈎, 股, 中鈎, 短弦, x, y) = (3, 4, 12/5, 9/5, 64/25, 48/25)
   plot([0, 股, 股, 0], [0, 0, 鈎, 0], color=:green, lw=0.5)
   circle(股 - r, r, r, :blue)
   segment(股, 0, x, y, :red)
   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, " 股", :green, :left, :bottom, delta=delta/2)
       point(股, 鈎, "(股,鈎) ", :green, :right, :vcenter)
       point(x, y, "(x,y) ", :green, :right, :vcenter)
       point(股 - r, r, "r,(股-r,r) ", :blue, :center, delta=-delta/2)
   end
end;

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

算額(その728)

2024年02月25日 | Julia

算額(その728)

富岡村天王社 明治26年
街角の数学 Street Wasan 街角の数学 ~落書き帳「○△□」~ 544. 関根熊吉の算額(その2)

http://streetwasan.web.fc2.com/math19.1.28.html

大円の中に正三角形,中円,小円が入っている。中円の直径が 5 寸のとき,小円の直径はいかほどか。

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

include("julia-source.txt");

using SymPy
@syms R::positive, r1::positive, r2::positive, y2::positive

#r1 = 5//2
eq1 = r2^2 + y2^2 - (R - r2)^2
eq2 = r2^2 + (y2 - (r1 - R))^2 - (r1 + r2)^2
eq3 = (2R - r1)/2 - r1
res = solve([eq1, eq2, eq3], (r2, y2, R))

   1-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (12*r1/25, 9*r1/10, 3*r1/2)

小円の半径は中円の半径の 12/25 倍である。
よって,中円の直径が 5 寸のとき,小円の直径は 2 寸 4 分である。
なお,外円の半径は中円の半径の 3/2 倍である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 5//2
   (r2, y2, R) = r1 .* (12/25, 9/10, 3/2)
   plot([√3R/2, 0, -√3R/2, √3R/2], [-R/2, R, -R/2, -R/2], color=:green, lw=0.5)
   circle(0, 0, R, :blue)
   circle(0, r1 - R, r1, :orange)
   circle(r2, y2, r2)
   circle(-r2, y2, 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(R, 0, " R", :blue, :left , :bottom, delta=delta/2)
       point(0, r1 - R, " 中円:r1\n (0,r1-R)", :orange, :left , :vcenter)
       point(r2, y2, " 小円:r2\n (r2,y2)", :red, :left , :vcenter)
   end
end;

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

算額(その22)Ver.2

2024年02月25日 | Julia

算額(その22)Ver.2

算額(その22)算額(その225)を,解析解を求めるように書き換えた。

岩手県遠野市附馬牛町 早池峰神社 弘化3年(1846)
http://www.wasan.jp/iwate/hayatine.html

矢祭町 矢祭神社 明治21年(1888)
街角の数学 Street Wasan ~落書き帳「○△□」~ 499. 矢祭神社算額(その2)

http://streetwasan.web.fc2.com/math18.11.17.html

中村信弥「改訂増補 長野県の算額」
http://www.wasan.jp/zoho/zoho.html
県内の算額3(205)
長野県千曲市八幡 八幡八幡神社 文久2年(1862)

一辺の長さが 2 の正三角形に 3 種類の半径を持つ円が図のように接している。それぞれの円の半径を求めよ。

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

include("julia-source.txt");

using SymPy

@syms a::positive, r1::positive, r2::positive, r3::positive, x2::positive, y3::positive;

eq1 = r3 / (sqrt(Sym(3)) - y3) - sin(PI/6);
eq1 = (y3 + 2r3)^2 - 3 |> expand |> simplify
eq2 = r2 / (1 - x2) - tan(PI/6);
eq2 = 3r2^2 - ( 1 - x2)^2 |> expand |> simplify
eq3 = r1^2 + (y3 - r1)^2 - (r1 + r3)^2 |> expand |> simplify;
eq4 = x2^2 + (y3 - r2)^2 - (r2 + r3)^2 |> expand |> simplify;
eq5 = (x2 - r1)^2 + (r2 - r1)^2 - (r1 + r2)^2 |> expand |> simplify;

@time res = solve([eq1, eq2, eq3, eq4, eq5], (r1, r2, r3, x2, y3))

   214.393407 seconds (4.97 M allocations: 459.084 MiB, 0.07% gc time, 0.08% compilation time)

   1-element Vector{NTuple{5, Sym{PyCall.PyObject}}}:
    ((-7268914764*sqrt(-12 + 94*sqrt(3))/13 - 51461127444*sqrt(3)/13 + 101195052708/13 + 5137424024*sqrt(-36 + 282*sqrt(3))/13)/(-4327566283*sqrt(3) - 464793774*sqrt(2)*sqrt(-6 + 47*sqrt(3)) + 661062705*sqrt(6)*sqrt(-6 + 47*sqrt(3)) + 15529289325), (1786462829813*sqrt(-36 + 282*sqrt(3))/3 + 392536725370733/13 + 1329217045078973*sqrt(3)/13 + 15848313004378*sqrt(-12 + 94*sqrt(3)))/(-78432136532557*sqrt(6)*sqrt(-6 + 47*sqrt(3)) + 13232389652808*sqrt(3) + 770162769521882 + 200428587172835*sqrt(2)*sqrt(-6 + 47*sqrt(3))), (-8216629030*sqrt(-36 + 282*sqrt(3))/13 - 131473919301/13 + 105598644225*sqrt(3)/13 + 18423011967*sqrt(-12 + 94*sqrt(3))/13)/(-4327566283*sqrt(3) - 464793774*sqrt(2)*sqrt(-6 + 47*sqrt(3)) + 661062705*sqrt(6)*sqrt(-6 + 47*sqrt(3)) + 15529289325), (-62924*sqrt(3)/13 - 3300*sqrt(-36 + 282*sqrt(3))/13 + 11640*sqrt(-12 + 94*sqrt(3))/13 + 182484/13)/(-3398*sqrt(3) - 89*sqrt(6)*sqrt(-6 + 47*sqrt(3)) + 993*sqrt(2)*sqrt(-6 + 47*sqrt(3)) + 16140), -sqrt(-3/169 + 47*sqrt(3)/338) + 3*sqrt(3)/26 + 27/26)

それぞれを表す数式は大きな整数があったりで長いものである。
たとえば,r1 は以下のようになる。

r1 = res[1][1]
r1 |> println

   (-7268914764*sqrt(-12 + 94*sqrt(3))/13 - 51461127444*sqrt(3)/13 + 101195052708/13 + 5137424024*sqrt(-36 + 282*sqrt(3))/13)/(-4327566283*sqrt(3) - 464793774*sqrt(2)*sqrt(-6 + 47*sqrt(3)) + 661062705*sqrt(6)*sqrt(-6 + 47*sqrt(3)) + 15529289325)

しかし,SymPy である程度簡約化できる。

@syms d
apart(res[1][1], d) |> println
apart(res[1][2], d) |> println
apart(res[1][3], d) |> println
apart(res[1][4], d) |> println
apart(res[1][5], d) |> println

   -sqrt(3)*sqrt(-36 + 282*sqrt(3))/78 - sqrt(-36 + 282*sqrt(3))/52 + 5*sqrt(3)/52 + 45/52
   -sqrt(-36 + 282*sqrt(3))/78 - sqrt(3)*sqrt(-36 + 282*sqrt(3))/156 + 11*sqrt(3)/52 + 21/52
   -27/52 + sqrt(3)*sqrt(-36 + 282*sqrt(3))/156 + 23*sqrt(3)/52
   -21*sqrt(3)/52 + 19/52 + sqrt(-36 + 282*sqrt(3))/52 + sqrt(3)*sqrt(-36 + 282*sqrt(3))/78
   -sqrt(2)*sqrt(-6 + 47*sqrt(3))/26 + 3*sqrt(3)/26 + 27/26

実際に計算するときは,更に手を加えた,以下のような計算式のほうがよいだろう。
t = sqrt(282√3 - 36)  # よく出てくるので事前に計算
r1 = (15√3 + 135 - 3t - 2√3t)/156
r2 = (33√3 + 63 - 2t - √3t)/156
r3 = (69√3 - 81 + √3t)/156
x2 = (57 - 63√3 + 3t + 2√3t)/156
y3 = (3√3 + 27 - sqrt(94√3 - 12))/26

正三角形の一辺の長さが 2 寸のとき,それぞれの値は以下のようになる。
r1 = 0.1505478011587474
r2 = 0.2613764437119185
r3 = 0.4830337288182606
x2 = 0.5472827195892904
y3 = 0.765983349932356

矢祭神社の問題は,2r2 が 3 寸 のとき,2r1 を求めることを要求しているので,以下のようになる。
答は 1.72794226236405 寸である。

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

   1.72794226236405

八幡神社の問題は,2r3 が 1 寸のとき,2r2 を求めることを要求しているので,以下のようになる。
答えは 0.541114270325127 寸である。

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

  0.541114270325127

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   t = sqrt(282√3 - 36)
   r1 = (15√3 + 135 - 3t - 2√3t)/156
   r2 = (33√3 + 63 - 2t - √3t)/156
   r3 = (69√3 - 81 + √3t)/156
   x2 = (57 - 63√3 + 3t + 2√3t)/156
   y3 = (3√3 + 27 - sqrt(94√3 - 12))/26
   println("r1 = $r1;  r2 = $r2;  r3 = $r3;  x2 = $x2;  y3 = $y3")
   plot([-1, 1, 0, -1], [0, 0, sqrt(3), 0], color=:black, linewidth=0.25)
   circle(0, sqrt(3)-2r3, r3)
   circle(r1, r1, r1, :blue)
   circle(-r1, r1, r1, :blue)
   circle(1-sqrt(3)*r2, r2, r2, :green)
   circle(sqrt(3)*r2-1, r2, 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(r1, r1, "(r1,r1)", :blue, :center)
       point(x2, r2, "(x2,r2)", :green, :center)
       point(0, y3, " y3", :red, :left, :vcenter)
       point(0, y3+r3, " y3+r3", :red, :left, :bottom, delta=delta/2)
       point(0, sqrt(3), " √3", :red, :left, :vcenter)
   end
end;

 

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

算額(その727)

2024年02月25日 | Julia

算額(その727)

安富有恒:和算を楽しむ,和算研究所だより,第12号,Vol. 7, No.2, 2004.
https://i-wasan.sakura.ne.jp/inst/component/tayori_12.pdf

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

外円内に楕円が 3 個入っている。中央部と楕円の中に直径の同じ円(等円)が 4 個入っている。

問題を簡単にするために,半径 R,中心座標 (0, 0) の外円に内接する正三角形と,正三角形の辺上に中心を持ち相互に外接する楕円を考える。更に,楕円に外接する円の半径 R2 を求める。楕円の長径と円の直径の比を求めれば,任意の楕円の長径に対する求める円の直径がわかる。

求める外円の直径を R2, (0, 0) とする。
仮の外円の半径と中心座標を R, (0, 0)
等円の半径と中心座標を r, (0, -R/2); r = R/4
楕円の長半径と短半径,中心座標を a, b, (0, -R/2); b = r
楕円同士の接点座標を (x0, y0),楕円と求める外円の接点座標を (x1, y1)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, a::positive, b::positive, r::positive,
x0::positive, y0::negative, x1::positive, y1::negative, R2::positive

R = 4r
b = r
eq1 = -b^2*x0/(a^2*(y0 + R/2)) + 1/√Sym(3)
eq2 = x0^2/a^2 + (y0 + R/2)^2/b^2 - 1
eq3 = y0/x0 + 1/√Sym(3)
eq4 = -b^2*x1/(a^2*(y1 + R/2)) + x1/y1
eq5 = x1^2/a^2 + (y1 + R/2)^2/b^2 - 1
eq6 = x1^2 + y1^2 - R2^2
res = solve([eq1, eq2, eq3, eq4, eq5, eq6], (R2, a, x0, y0, x1, y1))

   1-element Vector{NTuple{6, Sym{PyCall.PyObject}}}:
    (3*sqrt(6)*r/2, 3*r, 3*sqrt(3)*r/2, -3*r/2, 3*sqrt(15)*r/4, -9*r/4)

等円の半径が r のとき,外円の半径,楕円の長半径がそれぞれ 3*sqrt(6)*r/2, 3*r なので,外円の直径は楕円の長径の √6/2 倍である。

div(res[1][1], res[1][2]) |> println

   sqrt(6)/2

その他のパラメータは以下のとおりである。なお,楕円の長径は等円の直径の 3 倍である。

R2 = 3.674234614174767
R = 4
r = 1
a = 3
b = 1
x0 = 2.598076211353316
y0 = -1.5
x1 = 2.904737509655563
y1 = -2.25

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = 1
   R = 4r
   b = r
   (R2, a, x0, y0, x1, y1) = (3√6r/2, 3r, 3√3r/2, -3r/2, 3√15r/4, -9r/4)
   @show(R2, R, r, a, b, x0, y0, x1, y1)
   plot()
   circle(0, 0, R, :gray90)
   plot!([√3R/2, 0, -√3R/2, √3R/2], [-R/2, R, -R/2, -R/2], color=:gray90, lw=0.5)
   circle(0, 0, R2, :orange)
   circle(0, 0, r)
   rotate(0, -2r, r)
   ellipse(0, -R/2, a, r, color=:blue)
   ellipse(R/2*cos(pi/6), R/2*sin(pi/6), a, r, φ=120, color=:blue)
   ellipse(R/2*cos(5pi/6), R/2*sin(5pi/6), a, r, φ=240, color=: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, -2r, "(a,-2r) ", :blue, :right, :vcenter)
       point(x0, y0, "(x0,y0)", :blue, :left, :bottom, delta=delta)
       point(x1, y1, " (x1,y1)", :blue, :left, :vcenter)
       point(0, -R/2, "等円:r,(0,-R/2)", :red, :center, delta=-delta)
       point(r, 0, "r ", :red, :right, :bottom, delta=delta/2)
       point(0, -r, " -r=-R/4", :red, :center, :bottom, delta=delta)
       point(0, -R, " -R", :black, :left, :vcenter)
       point(0, -R2, " -R2", :black, :left, :vcenter)
       # plot!(xlims=(2, 4), ylims=(-2.5, -1))
   end
end;

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

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

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