裏 RjpWiki

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

算額(その523)

2023年11月30日 | Julia

算額(その523)

和算図形問題あれこれ - 令和4年11月の問題-No.1
https://gunmawasan.web.fc2.com/kongetu-no-mondai.html

2 個の甲円が交差しており,乙円 2 個と丙円 3 個が入っている。甲円,丙円の直径が 100 寸,36 寸であるとき,乙円の直径はいくらか。

甲円の半径と中心座標を r1, (0, r1 - r3), (0, r3 - r1)
乙円の半径と中心座標を r2, (x2, y2)
丙円の半径と中心座標を r3, (x3, y3), (0, 0)
とおき,以下の連立方程式を解く。
なお,r1, r3 を変数のままとして解くことは,solve() の性能上無理なようで,問に書かれた通りの数値を代入して解を求める。

include("julia-source.txt");

using SymPy
@syms r1::positive, r2::positive, x2::negative, y2::positive,
   r3::positive, x3::positive, y3::positive;
(r1, r3) = (100, 36) .// 2
eq1 = x2^2 + (y2 - (r3 - r1))^2 - (r1 + r2)^2
eq2 = x3^2 + (y3 - (r3 - r1))^2 - (r1 + r3)^2
eq3 = x2^2 + (y2 - (r1 - r3))^2 - (r1 - r2)^2
eq4 = x3^2 + (y3 - (r1 - r3))^2 - (r1 - r3)^2
eq5 = (x3 - x2)^2 + (y3 - y2)^2 - (r2 + r3)^2;
res = solve([eq1, eq2, eq3, eq4, eq5], (r2, x2, y2, x3, y3))

   1-element Vector{NTuple{5, Sym}}:
    (20500*sqrt(7)/4181 + 72242/4181, -66075*sqrt(41)/16724 + 25215*sqrt(287)/33448, 128125*sqrt(7)/16724 + 903025/33448, 15*sqrt(287)/8, 225/8)

乙円の半径 r2 は 20500√7/4181 + 72242/4181 = 82*(250√7 + 881)/4181,直径は 60.502225246029234 である。

2*82*(250√7 + 881)/4181

   60.502225246029234

   r2 = 30.2511;  x2 = -12.527;  y2 = 47.2674;  x3 = 31.7645;  y3 = 28.125
   乙円の直径 = 60.5022

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r1, r3) = (100, 36) .// 2
   (r2, x2, y2, x3, y3) = res[1]
   #r2 = 4.30617;  x2 = 38.0693;  y2 = 6.72839;  x3 = 31.7645;  y3 = 28.125
   @printf("r2 = %g;  x2 = %g;  y2 = %g;  x3 = %g;  y3 = %g\n", r2, x2, y2, x3, y3)
   @printf("乙円の直径 = %g\n", 2r2)
   plot()
   circle(0, r1 - r3, r1)
   circle(0, r3 - r1, r1)
   circle(x2, y2, r2, :blue)
   circle(-x2, -y2, r2, :blue)
   circle(x3, y3, r3, :green)
   circle(-x3, -y3, r3, :green)
   circle(0, 0, r3, :green)
   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=:black, lw=0.5)
       point(0, r1 - r3, "甲円:r1 \n(0,r1-r3) ", :red, :right, :vcenter)
       point(0, r3 - r1, "(0,r3-r1)")
       point(x2, y2, "乙円:r2 \n(x2,y2) ", :blue, :right, :vcenter)
       point(x3, y3, " 丙円:r3(x3,y3)", :green, :center, :top, delta=-delta/2)
   end
end;

 

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

算額(その522)

2023年11月30日 | Julia

算額(その522)

岩手県山田町 武内大明神 文政3年(1820)
一関市博物館>>和算に挑戦>>平成28年度出題問題&解答例>>平成28年度出題問題(2)[中級問題] https://www.city.ichinoseki.iwate.jp/museum/wasan/h28/normal.html

外円内に長方形,甲円,乙円が入っている,乙円の直径が 1,長方形の短辺の長さが 6 のとき,外円の直径を求めよ。

長方形の長辺と短辺の長さをそれぞれ 2b, 2a とする。b = r0 - 2r1 である。
外円の半径と中心座標を r0, (0,  0)
甲円の半径と中心座標を r1, (b + r1, 0)
乙円の半径と中心座標を r2, (b + r2, y2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms r0::positive, r1::positive, r2::positive, y2::positive, b::positive;
a = r0 - 2r1
eq1 = (a + r2)^2 + y2^2 - (r0 - r2)^2
eq2 = (r1 - r2)^2 + y2^2 - (r1 + r2)^2
eq3 = a^2 - (r0^2 - b^2)
res = solve([eq1, eq2, eq3], (r0, r1, y2))

   2-element Vector{Tuple{Sym, Sym, Sym}}:
    (b^2/(4*r2), b*(b - sqrt(b^2 - 16*r2^2))/(8*r2), sqrt(2)*sqrt(b)*sqrt(b - sqrt(b - 4*r2)*sqrt(b + 4*r2))/2)
    (b^2/(4*r2), b*(b + sqrt(b^2 - 16*r2^2))/(8*r2), sqrt(2)*sqrt(b)*sqrt(b + sqrt(b - 4*r2)*sqrt(b + 4*r2))/2)

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

   外円の直径 = 9;  r0 = 4.5;  r1 = 0.572949;  y2 = 1.07047

外円の直径は,長方形の短辺の長さの二乗を乙円の直径の 4 倍で割って得られる。

乙円の直径が 1,長方形の短辺の長さが 6 のとき,外円の直径は 36/4 = 9 である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r2, b) = (1//2, 6//2)
   (r0, r1, y2) = (b^2/(4*r2), b*(b - sqrt(b^2 - 16*r2^2))/(8*r2), sqrt(2)*sqrt(b)*sqrt(b - sqrt(b - 4*r2)*sqrt(b + 4*r2))/2)
   @printf("外円の直径 = %g;  r0 = %g;  r1 = %g;  y2 = %g\n", 2r0, r0, r1, y2)
   (r2, b) = (1//2, 6//2)
   a = r0 - 2r1
   plot([a, a, -a, -a, a], [-b, b, b, -b, -b], color=:black, lw=0.5)
   circle(0, 0, r0)
   circle(a + r1, 0, r1, :blue)
   circle(-a - r1, 0, r1, :blue)
   circle4(a+r2, y2, r2, :magenta)
   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=:black, lw=0.5)
       point(a, 0, "a ", :black, :right, :bottom, delta=delta/2)
       point(0, b, " b", :black, :left, :bottom, delta=delta/2)
       point(a + r1, 0, "a+r1", :blue, :center, :bottom, delta=delta/2)
       point(a + r2, y2, "乙円:r2,(a+r2,y2) ", :magenta, :right, :vcenter)
   end
end;

 

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

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

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