裏 RjpWiki

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

算額(その1003)

2024年05月27日 | Julia

算額(その1003)

十八 大里郡岡部村岡 稲荷社(久留里社算題集) 文化14年(1817)

埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

楕円の中に各辺が同じ長さの六角形を入れる。長径と短径が 14 寸,7 寸のとき,各辺の長さはいかほどか。

楕円の長半径,短半径,中心座標を a, b, (0, 0)
六角形の頂点の一つの座標を (x, y)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::poitive, b::poitive,
     x::poitive, y::poitive
eq1 = x^2/a^2 + y^2/b^2 - 1  # (x, y) が楕円の周上にある
eq2 = sqrt(x^2 + (b - y)^2) - 2y  # 2辺が同じ長さである
res = solve([eq1, eq2], (x, y))[2]

   (2*a*sqrt(b^4*(a^2 + 2*b^2)/(a^2 + 3*b^2)^2)/b, b*(a^2 + b^2)/(a^2 + 3*b^2))

x 座標は 2*a*sqrt(b^4*(a^2 + 2*b^2)/(a^2 + 3*b^2)^2)/b
y 座標は b*(a^2 + b^2)/(a^2 + 3*b^2))
長半径,短半径,がそれぞれ 14/2, 7/2 のとき,x = 4.898979485566356, y = 2.5
また,六角形の一辺の長さは 5 である。

(a, b) = (14/2, 7/2)
x = 2*a*sqrt(b^4*(a^2 + 2*b^2)/(a^2 + 3*b^2)^2)/b
y = b*(a^2 + b^2)/(a^2 + 3*b^2)
(x, y) |> println
2y |> println

   (4.898979485566356, 2.5)
   5.0

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, b) = (14, 7) ./ 2
   x = 2*a*sqrt(b^4*(a^2 + 2*b^2)/(a^2 + 3*b^2)^2)/b
   y = b*(a^2 + b^2)/(a^2 + 3*b^2)
   @printf("(x, y) = (%g, %g)\n", x, y)
   println("sqrt(x^2 + (b - y)^2) = $(sqrt(x^2 + (b - y)^2))\n2y = $(2y)")
   plot([0, -x, -x, 0, x, x, 0], [b, y, -y, -b, -y, y, b], color=:blue, lw=0.5)
   ellipse(0, 0, a, b, color=: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(a, 0, " a", :red, :left, :bottom, delta=delta)
       point(0, b, " b", :red, :left, :bottom, delta=delta)
       point(x, y, " (x,y)", :blue, :left, :bottom, delta=delta)
   end
end;


コメント    この記事についてブログを書く
  • X
  • Facebookでシェアする
  • はてなブックマークに追加する
  • LINEでシェアする
« 算額(その1002) | トップ | 算額(その1004) »
最新の画像もっと見る

コメントを投稿

Julia」カテゴリの最新記事