裏 RjpWiki

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

算額(その843)

2024年04月08日 | Julia

算額(その843)

百四 岩手県大船渡市田茂山 根城八幡宮 天保12年(1841)

山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市. http://www.wasan.jp/yamamura/yamamura.html

一関市博物館>>和算に挑戦>>平成20年度出題問題&回答例
https://www.city.ichinoseki.iwate.jp/museum/wasan/h20/index.html

全円内に直角三角形が内接し,小円は直角三角形に内接し,大円は直角三角形の二辺と全円に内接している。小円の直径が 1 のとき,大円の直径はいかほどか。

直角三角形が全円に内接するので,全円の中心は直角三角形の斜辺の中点にある。
直角三角形の直角の頂点を原点とし,直角を挟む二辺の短い方を a, 長い方を b
全円の半径と中心座標を R, (a/2, b/2)
大円の半径と中心座標を r1, (r1, r1)
小円の半径と中心座標を r2, (r2, r2)
とおき,以下の連立方程式を解く。

include("julia-source.txt")

using SymPy

@syms a::positive, b::positive, r1::positive, r2::positive, R::positive;
@syms a, b, r1, r2, R
R = sqrt(a^2 + b^2)/2
eq1 = (r1 - a/2)^2 + (r1 - b/2)^2 - (R - r1)^2 |> expand
eq2 = a + b - 2R - 2r2 |> expand
eq3 = (a + b + 2R)r2 - a*b |> expand;

println(eq1, ",  # eq1")
println(eq2, ",  # eq2")
println(eq3, ",  # eq3")

   -a*r1 - b*r1 + r1^2 + r1*sqrt(a^2 + b^2),  # eq1
   a + b - 2*r2 - sqrt(a^2 + b^2),  # eq2
   -a*b + a*r2 + b*r2 + r2*sqrt(a^2 + b^2),  # eq3

注目すべきは,eq1 は r1 について,eq2, eq3 は r2 についての式になっている。つまり単なる一元方程式である。
それぞれについて解く。

res_r1 = solve(eq1, r1)[2] |> factor
res_r1 |> println

   a + b - sqrt(a^2 + b^2)

res_r2 = solve(eq2, r2)[1] |> factor
res_r2 |> println

   (a + b - sqrt(a^2 + b^2))/2

大円の半径 res_r1 は,小円の半径 res_r2 の 2 倍である。
また,それぞれは直角三角形の直角を挟む二辺 a, b がどんな値であっても,a + b - sqrt(a^2 + b^2) により決まる。

r2 = 1//2 のとき,b = (a - 1/2)/(a - 1) である。例えば a = 3 なら b = 5/4,a = 2.345 なら b = 1.3717472118959106 である。

@syms a
r2 = 1//2
eq = (a + b - sqrt(a^2 + b^2))/2 - r2
solve(eq, b)  # a から,r2 = 1/2 になるような b を求める式

   1-element Vector{Sym{PyCall.PyObject}}:
    (a - 1/2)/(a - 1)

例えば,a = 2.345,  b = 1.3717472118959106 のとき,小円の直径は 1,大円の直径は 2 である。

   r1 = 1;  r2 = 0.5;  a = 2.345;  b = 1.37175;  R = 1.35837

function draw(a, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   b =  (a - 1/2)/(a - 1)
   r2 = (a + b - sqrt(a^2 + b^2))/2
   r1 = 2r2
   R = sqrt(a^2 + b^2)/2
   @printf("r1 = %g;  r2 = %g;  a = %g;  b = %g;  R = %g\n", r1, r2, a, b, R)
   plot([0, a, 0, 0], [0, 0, b, 0], color=:black, lw=0.5)
   circle(a/2, b/2, R, :blue)
   circle(r1, r1, r1)
   circle(r2, 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(a/2, b/2, "全円:R,(a/2,b/2)", :blue, :left)
       point(r1, r1, "大円:r1,(r1,r1)", :red, :center, delta=-delta/2)
       point(r2, r2, " 小円:r2,(r2,r2)", :green, :left, :vcenter)
       point(a, 0, "  a", :black, :left, :bottom, delta=delta/2)
       point(0, b, "b ", :black, :right, :bottom, delta=delta/2)
    end
end;

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

算額(その842)

2024年04月08日 | Julia

算額(その842)

岩手県一関市 日吉神社 弘化2年(1845)

一関市博物館>>和算に挑戦>>平成25年度出題問題&回答例
https://www.city.ichinoseki.iwate.jp/museum/wasan/h25/index.html

正方形の二辺に大円が接し,3 個の小円がある。小円の直径が 1 寸のとき,大円の直径を求めよ。

回答例に色々言い訳が書いてあるが,出題図が不適切で,大円は AB にも接するとして(単純な問題を)解く。

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

include("julia-source.txt")

using SymPy

@syms r1::positive, r2::positive;

eq = 2(r1 - r2)^2 - (r1 + r2)^2
res = solve(eq, r1)
res[2] |> println

   r2*(2*sqrt(2) + 3)

大円の直径は小円の直径の 2√2 + 3 倍である。
小円の直径が 1 寸のとき,大円の直径は 5.82842712474619 寸である。

2√2 + 3

   5.82842712474619

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 1/2
   r1 = r2*(2√2 + 3)
   @printf("大円の直径 = %g;  小円の直径 = %g\n", 2r1, 2r2)
   a = 2r1 - 2r2
   plot([0, a, a, 0, 0], [0, 0, a, a, 0], color=:blue, lw=0.5)
   circle(r1, r1, r1, :green)
   circle(r2, r2, r2)
   circle(r1, 2r1 - r2, r2)
   circle(2r1 - r2, r1, 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(r1, r1, "大円:r1,(r1,r1)", :green, :center, delta=-delta/2)
       point(r2, r2, " 小円:r2,(r2,r2)", :black, :left, :vcenter)
       point(r1, 2r1 - r2, " 小円:r2,(r1,2r1-r2)", :black, :left, :vcenter)
       point(2r1 - r2, r1, "小円:r2,(2r1-r2,r1)", :black, :right, :bottom, delta=delta/2)
       point(0, 2r1 - 2r2, " 2r1-2r2", :blue, :left, :bottom, delta=delta/2)
       point(2r1 - 2r2, 0, " 2r1-2r2", :blue, :left, :bottom, delta=delta/2)
   end
end;

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

算額(その841)

2024年04月08日 | Julia

算額(その841)

百四 岩手県大船渡市田茂山 根城八幡宮 天保11年(1840)

山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.
http://www.wasan.jp/yamamura/yamamura.html

全円内に正三角形 4 個と等円 4 個を入れる。等円の直径がわかっているときに全円の直径を求めるすべを求めよ。

全円の半径と中心座標を R, (0, 0)
正三角形の一辺の長さを 2a
とおき,以下の方程式を解く。

include("julia-source.txt")

using SymPy

@syms R::positive, a::positive, r::positive;
a = R/(1 + sqrt(Sym(3)))
eq1 = dist(R, 0, a, a, (R - r)/sqrt(Sym(2)), (R - r)/sqrt(Sym(2))) - r^2
res = solve(eq1, R);

2 組の解が得られるが,最初のものが適解である。 

R = res[1] |>sympy.sqrtdenest |> simplify
R |> println

   r*(90 + 52*sqrt(3) + 71*sqrt(2) + 41*sqrt(6))/(2*(-41*sqrt(6) - 71*sqrt(2) + 71*sqrt(3) + 123))

r の係数 (90 + 52*sqrt(3) + 71*sqrt(2) + 41*sqrt(6))/(2*(-41*sqrt(6) - 71*sqrt(2) + 71*sqrt(3) + 123)) の分母の有理化を行うと (3(√2 + √3) - 1)/2 になる。

@syms d
apart(R/r, d) |> factor |> println

   (-1 + 3*sqrt(2) + 3*sqrt(3))/2

等円の直径が 1 のとき,全円の直径は 4.21939655491296 である。

r*(3(√2 + √3) - 1)/2 |> println

   4.21939655491296*r

術では,全円径 = (4√6 - 1)/2 * 等円径 とあるが,どうやってそれを導いたか不明である。
これにしたがうと,全円の直径は 4.398979485566356 となり,これを起点として図を描くと,正三角形にはならない。

(4√6 - 1)/2

   4.398979485566356

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

   等円の直径 = 1;  全円の直径 = 4.2194;  三角形の一辺の長さ = 1.54441

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = 1/2
   R = r*(3(√2 + √3) - 1)/2
   a = R/(1 + √3)
   @printf("等円の直径 = %g;  全円の直径 = %g;  三角形の一辺の長さ = %g\n", 2r, 2R, 2a)
   plot([a, a, -a, -a, a], [ -a, a, a, -a, -a], color=:blue, lw=0.5)
   circle(0, 0, R, :green)
   # R2 = (4√6 - 1)/4
   # circle(0, 0, R2, :black)
   circle4((R - r)/√2, (R - r)/√2, r)
   for i in 0:3
       deg = 90i
       plot!([√2a*cosd(deg + 45), R*cosd(deg), √2a*cosd(deg - 45)],
             [√2a*sind(deg + 45), R*sind(deg), √2a*sind(deg - 45)], color=:magenta, lw=0.5)
   end
   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, a, "(a,a) ", :blue, :right, delta=-delta/2)
       point(0, (1 + √3)a, " R=(1+√3)a", :green, :center, :bottom, delta=delta/2)
       point((R - r)/√2, (R - r)/√2, "((R-r)/√2,\n(R-r)/√2)", :red, :center, :bottom, delta=delta/2)
       # d = 0.2
       # plot!(xlims=(0, a+d), ylims=(0, a+d))
   end
end;

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

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

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