裏 RjpWiki

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

算額(その689)

2024年02月10日 | Julia

算額(その689)

和算問題あれこれ 2 令和5年4月の問題-No.2(『神壁算法』15問)
https://gunmawasan.web.fc2.com/k-n-mondai.html

大円内に等脚台形と小円をいれる。台形の上底(上頭),下底(下頭),対角線(内斜)がそれぞれ 36 寸,300 寸,280 寸のとき,小円の直径は何寸か。
注:「
神壁算法」の図の寸法を10倍している。

 

大円の半径と中心座標を R, (0, 0)
小円の半径と中心座標を r0, (x0, y0)
上底,下底と円の交点座標を (x1, y1), (x2, y2)
とおき,以下の連立方程式を解く。

なお,4 元連立方程式として一度に解くことはできるが,R, r0 が負の値になる(絶対値を取ればもんだいはない)ので,eq1, eq2 の 2 元連立方程式として R, r0 を求め,ついで eq3, eq4 で x0,y0 を求める。

include("julia-source.txt");
# julia-source.txt ソース https://blog.goo.ne.jp/r-de-r/e/ad3a427b84bb416c4f5b73089ae813cf

using SymPy

@syms R::positive, x1::positive, y1::positive, x2::positive, y2::negative, r0::positive, x0::positive, y0::positive

(x1, x2) = (300, 36) .// 2
y1 = -sqrt(R^2 - x1^2)
y2 = sqrt(R^2 - x2^2)
eq1 = (x1 + x2)^2 + (y2 - y1)^2 - 280^2
eq2 = 2sqrt(R^2 - (R - 2r0)^2) - sqrt((x1 - x2)^2 + (y2 - y1)^2);
solve([eq1, eq2], (R, r0))

   2-element Vector{Tuple{Sym, Sym}}:
    (325/2, 65/2)
    (325/2, 130)

最初のものが適解である。

小円の直径は 65 寸である。ちなみに,外円の直径は 325 寸である。

図を描くために,小円の中心座標 (x0, y0) を求める。

(R, r0) = (325//2, 65//2)
eq3 = x0^2 + y0^2 - (R - r0)^2
eq4 = y0/x0 * (sqrt(R^2 - x2^2) + sqrt(R^2 - x1^2))/(x2 - x1) + 1;
solve([eq3, eq4], (x0, y0))

   1-element Vector{Tuple{Sym, Sym}}:
    (112.000000000000, 66.0000000000000)

using Plots

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (x1, x2) = (300, 36) .// 2
   (R, r0, x0, y0) = [325/2, 65/2, 112, 66]
   y1 = -sqrt(R^2 - x1^2)
   y2 = sqrt(R^2 - x2^2)
   @printf("小円の直径 = %g\n", 2r0)
   @printf("R = %g;  x0 = %g;  y0 = %g;  r0 = %g\n", R, x0, y0, r0)
   plot([x1, x2, -x2, -x1, x1], [y1, y2, y2, y1, y1], color=:black, lw=0.5)
   circle(0, 0, R)
   circle(x0, y0, r0, :blue)
   segment(-x2, y2, x1, y1, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
       point(x0, y0, "小円:r0\n(x0,y0)", :blue, :center, delta=-delta/2)
       point(R, 0, " R", :red, :left, :bottom, delta=delta)
       point(x1, y1, "(x1,y1)")
       point(x2, y2, "(x2,y2)", :green, :left, :bottom, delta=delta)
   end
end;

 


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

コメントを投稿

Julia」カテゴリの最新記事