裏 RjpWiki

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

算額(その402)

2023年08月21日 | Julia

算額(その402)

愛知県岡崎市 六所神社(1779)
http://www.st.nanzan-u.ac.jp/info/ma-thesis/2015/ss/m14ss006.pdf

甲,乙,丙の正方形がある。その面積の和は 61 歩,甲乙の一辺の差は 2 寸,乙丙の一辺の差は 1 寸であるとき,丙の一辺の長さを求めよ。

甲,乙,丙の一辺の長さをそれぞれ 「甲」,「乙」,「丙」とし,以下の方程式を解く。

using SymPy

@syms 甲::positive, 乙::positive, 丙::positive;

eq1 = 甲^2 + 乙^2 + 丙^2 ~ 61
eq2 = 甲 - 乙 ~ 2
eq3 = 乙 - 丙 ~ 1
res = solve((eq1, eq2, eq3), (甲, 乙, 丙))

   1-element Vector{Tuple{Sym, Sym, Sym}}:
    (6, 4, 3)

正方形 乙 の一辺の長さは 3 寸である。

甲,乙の一辺の長さはそれぞれ 6 寸, 4 寸である。

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

算額(その401)

2023年08月21日 | Julia

算額(その401)

埼玉県所沢市下新井 熊野神社 明治6年(1873)
山口正義:毛呂周辺の算額
https://yamabukiwasan.sakura.ne.jp/22moroshuuhen.pdf

大円内に正7角形と小円が入っている。大円と小円の直径を与えたときに正7角形の一辺の長さを求めよ。

大円と小円の半径を r0, r1,正7角径が内接する円の半径を r2 として,以下の方程式を解く。

当時 sin(π/7) とか sin(π/7) どうやって計算していたのだろうか。

include("julia-source.txt");

using SymPy

@syms r0::positive, r1::positive, r2::positive,
     x2::positive, y2::positive,
     x3::positive, y3::positive,
     x4::positive, y4::positive;

eq = 2r1 + r2*(1 + cos(PI/7))- 2r0
res = solve(eq, r2)[1]
res |> println

   (2*r0 - 2*r1)/(cos(π/7) + 1)

半径は r2 = 2(r0 - r1)/(cos(π/7) + 1) である。
一辺の長さは 2r2*sin(π/7) = 5.477843385363599

r0 = 10; r1 = 4
r2 = 2(r0 - r1)/(cos(π/7) + 1)
2r2*sin(π/7)

   5.477843385363599

using Plots

function draw(more)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r0, r1) = (10, 4)
   r2 = 2(r0 - r1)/(cos(π/7) + 1)
   x = []
   y = []
   for (i, θ) = enumerate(π/2:2π/7:5π/2)
       append!(x, r2*cos(θ))
       append!(y, r2*sin(θ) + r0 - r2)
   end
   @printf("r2 = %g;  r0 = %g;  r1 = %g\n", r2, r0, r1)
   @printf("正7角径の一辺の長さは %g\n", 2r2*sin(π/7))
   plot(x, y, color=:blue, lw=0.5)
   circle(0, 0, r0, :black)
   circle(0, r1 - r0, r1)
   if more == true
       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 - r2, " r0 - r2", :blue)
       point(0, r0-r2*(1+cos(π/7)), " r0-r2*(1+cos(π/7))", :blue, :left, :bottom, delta=delta/2)
       point(0, r1 - r0, " r1-r0", :red)
       point(0, -2, "")
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

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

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