裏 RjpWiki

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

算額(その411)

2023年09月01日 | Julia

算額(その411)

会田安明(1811):「算法天生法指南」
永井信一:「アルベロスに関連した問題」
http://www2.ttcn.ne.jp/~nagai/waseda/wasan/arbe.pdf

長方形内に斜線を引き,2 区分された領域に大円,小円を入れる。大円の直径が 2 寸,長方形の長辺が 3 寸のとき,小円の直径はいかほどか。

長方形の右下を原点とし,長辺と短辺を a, b,斜線と長辺の交点座標を y とする。
大円の半径と中心座標を r1, (r1, a - r1)
小円の半径と中心座標を r2, (r2, r2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

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

r1 = 1
a = 3
b = 2r1
eq1 = y + b - sqrt(y^2 + b^2) - 2r2
eq2 = distance(0, y, b, 0, r1, a - r1) - r1^2
res = solve([eq1, eq2], (r2, y))

   1-element Vector{Tuple{Sym, Sym}}:
    (1/2, 3/2)

小円の直径は 1 寸である。

using Plots

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 1
   a = 3
   b = 2r1
   (r2, y) = (1/2, 3/2)
   @printf("r2 = %g;  y = %g\n", r2, y)
   @printf("小円の直径 = %g\n", 2r2)
   plot([0, b, b, 0, 0], [0, 0, a, a, 0], color=:black, lw=0.5)
   circle(r1, a - r1, r1)
   circle(r2, r2, r2, :blue)
   segment(0, y, b, 0, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /  3  # size[2] * fontsize * 2
       point(0, a, " a", :black, :left, :bottom)
       point(b, 0, " b", :black, :left, :bottom)
       point(0, y, " y", :green, :left, :bottom)
       point(r1, a - r1, "大円:r1,(r1,a-r1)", :red, :center, delta=-delta)
       point(r2, r2, "小円:r2,(r2,r2)", :blue, :center, delta=-delta)
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

 


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

コメントを投稿

Julia」カテゴリの最新記事