裏 RjpWiki

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

算額(その360)

2023年08月03日 | Julia

算額(その360)

山形県山形市鉄砲町 竜宝院勢至堂
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

二等辺三角形と甲円 2 個,乙円 2 個がある。甲円の直径が 6 寸のとき,乙円の直径はいくつか。

甲円の直径,中心座標を r1, (0, r1) および (0, 3r1)
乙円の直径,中心座標を r2, (x,y)
として,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive, x::positive, y::positive, a::positive;

eq1 = x^2 + (y - 3r1)^2 - (r1 - r2)^2
eq2 = a^2 + (4r1)^2 - (3a)^2
eq3 = 3(r1 - 2r2) - r1
eq4 = 4r1*(y - 3r1) - a*x
res = solve([eq1, eq2, eq3, eq4], (r2, a, x, y))

   1-element Vector{NTuple{4, Sym}}:
    (r1/3, sqrt(2)*r1, 4*sqrt(2)*r1/9, 29*r1/9)

乙円の半径は甲円の半径の 1/3 である。よって,甲円の直径が 6 寸なら,乙円の直径は 2 寸である。

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 6//2
   (r2, a, x, y) = (r1/3, sqrt(2)*r1, 4*sqrt(2)*r1/9, 29*r1/9)
   @printf("r2 = %g;  a = %g;  x = %g;  y = %g\n", r2, a, x, y)
   @printf("甲円の直径が %g 寸のとき,乙円の直径は %g 寸\n", 2r1, 2r2)
   plot([a, 0, -a, a], [0, 4r1, 0, 0], color=:black, lw=0.5)
   circle(0, r1, r1)
   circle(0, 3r1, r1)
   circle(x, y, r2, :blue)
   circle(-x, y, r2, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, 4r1, " 4r1", :red, :left, :bottom, delta=delta/2)
       point(0, 3r1, " 3r1", :red, :left, :vcenter)
       point(0, 2r1, " 2r1", :red, :left, :bottom, delta=delta/2)
       point(0, r1, " r1  甲円", :red, :left, :vcenter)
       point(x, y, "乙円:r2\n(x,y)", :blue, :center, delta=-delta/2)
       point(a, 0, "a ", :black, :right, :bottom, delta=delta/2)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

算額(その359)

2023年08月03日 | Julia

算額(その359)

山形県山形市鉄砲町 竜宝院勢至堂
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

大円の中に甲円 2 個,乙円 2 個,丙円 1 個が入っている。乙円,丙円の直径がそれぞれ 5 寸,4 寸のとき,甲円の直径を求めよ。

大円の直径,中心座標を r0, (0, 0)
甲円の直径,中心座標を r1, (0, r0 - r1)
乙円の直径,中心座標を r2, (r0 - r2, 0)
丙円の直径,中心座標を r3, (0, 0)
として,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

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

eq1 = (r0 - r2)^2 + (r0 - r1)^2 - (r1 + r2)^2
eq2 = r0 - 2r1 + r3
solve([eq1, eq2], (r0, r1))

   2-element Vector{Tuple{Sym, Sym}}:
    (3*r2/2 + r3/2 - sqrt(r2 + r3)*sqrt(9*r2 + r3)/2, 3*r2/4 + 3*r3/4 - sqrt(r2 + r3)*sqrt(9*r2 + r3)/4)
    (3*r2/2 + r3/2 + sqrt(r2 + r3)*sqrt(9*r2 + r3)/2, 3*r2/4 + 3*r3/4 + sqrt(r2 + r3)*sqrt(9*r2 + r3)/4)

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

r0 = (3r2 + r3 + sqrt((r2 + r3)*(9r2 + r3)))/2
r1 = (3(r2 + r3) + sqrt((r2 + r3)*(9r2 + r3)))/4

r2 = 5/2, r3 = 2 のとき, r0 = 10; r1 = 6 で,甲円の直径 = 2r1 = 12 寸である。

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r2, r3) = (5, 4) .// 2
   (r0, r1) = ((3r2 + r3 + sqrt((r2 + r3)*(9r2 + r3)))/2, (3(r2 + r3) + sqrt((r2 + r3)*(9r2 + r3)))/4)
   @printf("r0 = %g; r1 = %g\n", r0, r1)
   @printf("甲円の直径 = 2r1 = %g 寸\n", 2r1)
   plot()
   circle(0, 0, r0, :black)
   circle(0, r0 - r1, r1)
   circle(0, r1 - r0, r1)
   circle(r0 - r2, 0, r2, :blue)
   circle(r2 - r0, 0, r2, :blue)
   circle(0, 0, r3, :orange)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, r0, " r0", :black, :left, :bottom, delta=delta/2)
       point(0, r0 - r1, " r0-r1", :red, :left, :bottom, delta=delta/2)
       point(0, r3, " r3", :orange, :left, :bottom, delta=delta/2)
       point(r0 - r2, 0, "r0-r2", :blue, :center, delta=-delta/2)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

算額(その358)

2023年08月03日 | Julia

算額(その358)

岩手県盛岡市 八幡宮 文化3年(1806)
一関市博物館 平成 30 年度出題問題 2 [中級問題](中学・高校生向き)

https://www.city.ichinoseki.iwate.jp/museum/wasan/h30/normal.html

三角形の三辺の長い順に大斜,中斜,小斜とする。中斜に 9 個の等円が接し,小斜に 7 個の等円が接している。等円は隣り合う等円とも接している。
中斜が 8 寸のとき,小斜の長さを求めよ。

等円の中心を結んでできる三角形を見ると,外の三角形と相似であることがわかる。
等円の直径を R とする。bc/BC = ab/AB で,AB = ab/bc * BC である。
BC = 8寸, ab = 6R, bc = 8R を代入して,AB = 6R/8R * 8寸 = 6寸である。

include("julia-source.txt");

using SymPy

@syms r, x1::negative, y1, x2, y2, x3, y3

r = 1//2
y3 = -r
y1 = -r
eq1 = distance(x1, -r, x2, y2, 0, 0) -r^2
eq2 = distance(x3, -r, x2, y2, 36//10, 48//10) -r^2
eq3 = (y2 - y1)/(x2 - x1) - 4//3
eq4 = (y2 + r)/(x2 - x3) + 3//4
res = solve([eq1, eq2, eq3, eq4], (x1, x2, y2, x3))

   2-element Vector{NTuple{4, Sym}}:
    (-1, 29/10, 47/10, 59/6)
    (-1, 7/2, 11/2, 23/2)

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, x, y) = (10, 3.6, 4.8)
   r = 0.5
   y3 = y1 = -r
   (x1, x2, y2, x3) = res[2] # [-1.,-0.5, 3.5, 5.5, 11.5, -0.5]
   @printf("x1 = %g; y1 = %g; x2 = %g; y2 = %g; x3 = %g; y3 = %g\n", x1, y1, x2, y2, x3, y3)
   plot()
   # plot([0, a, x, 0], [0, 0, y, 0], color=:black, lw=0.5)
   for i = 0:6
       circle(i*(3.6/6), i*(4.8/6), r)
   end
   for i = 0:7
       circle(10 - i*(6.4/8), i*(4.8/8), r)
   end
   plot!([x1, x3, x2, x1], [y1, y3, y2, y1], color=:black, lw=0.5)
   point((x1+x2)/2, (y1+y2)/2, "小斜 ", :black, :right, :vcenter, mark=false)
   point((x3+x2)/2, (y3+y2)/2, " 中斜", :black, :left, :vcenter, mark=false)
   point((x3+x1)/2, y1, "大斜", :black, :center, mark=false)
   if more
       plot!([0, 10, 3.6, 0], [0, 0, 4.8, 0], color=:red, lw=0.5)
       point(x1, -r, " A")
       point(x2, y2, " B", :green, :left, :vcenter)
       point(x3, -r, " C")
       point(0, 0, " a", :red, :left, :vcenter)
       point(3.6, 4.8, " b", :red, :left, :vcenter)
       point(10, 0, " c", :red, :left, :vcenter)
       plot!(showaxis=false)
   else
       plot!(showaxis=false)
   end
end;

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

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

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