裏 RjpWiki

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

算額(その155)

2023年03月11日 | Julia

算額(その155)

岐阜県大垣市西外側町 大垣八幡神社 天保年間
http://ryugen3.sakura.ne.jp/toukou3/wasankibousya.PDF

第7問: 1 つの内角が 60° の菱形に赤円 2 個と黒円 4 個を入れる。黒円の直径を知って赤円の直径を求めよ。

右の赤円の半径を r1,中心座標を (x1, 0) とする。
右上の黒円の半径を r2,中心座標を (x2, y2) とする。
図のように記号を定め,連立方程式を解く。
x2, y2 は r2 が求まれば決まる。

赤円の半径と黒円の半径の比は res[r1] / res[r2]

using SymPy

@syms r1::positive, x1::positive, r2::positive, x2::positive, y2::positive;

eq1 = (sqrt(Sym(3)) - x1) / 2 - r1  # r1 = (√3 - x1) / 2
eq2 = 1 + r1 - x1             # x1 = 1 + r1

eq3 = 1 - sqrt(Sym(3)) / 2 - 2r2  # 2r2 = 1 - √3 / 2

res = solve([eq1, eq2, eq3], (r1, x1, r2))

   Dict{Any, Any} with 3 entries:
     r2 => 1/2 - sqrt(3)/4
     x1 => sqrt(3)/3 + 2/3
     r1 => -1/3 + sqrt(3)/3

print("x2 = "); (1 - res[r2])/2 |> println
print("y2 = "); (1 - res[r2])*sqrt(Sym(3))/2 |> println

   x2 = sqrt(3)/8 + 1/4
   y2 = sqrt(3)*(sqrt(3)/4 + 1/2)/2

res[r1] / res[r2] |> simplify |> println

   4/3 + 4*sqrt(3)/3

赤円径 = (4/3 + 4*sqrt(3)/3) × 黒円径 = 4/3 * (1 + sqrt(3)) × 黒円径

using Plots
using Printf

function circle(ox, oy, r, color=:red; beginangle=0, endangle=360, fill=false)
   θ = beginangle:0.1:endangle
   x = r.*cosd.(θ)
   y = r.*sind.(θ)
   if fill
       plot!(ox .+ x, oy .+ y, linecolor=color, linewidth=0.5, seriestype=:shape, fillcolor=color)
   else
       plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
   end
end;

function point(x, y, string="", color=:green, position=:left, vertical=:top; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
end;

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   x1 = sqrt(3)/3 + 2/3
   r1 = -1/3 + sqrt(3)/3
   r2 = 1/2 - sqrt(3)/4
   x2 = (1 - r2)/2
   y2 = (1 - r2)sqrt(3)/2
   plot([0, sqrt(3), 0, -sqrt(3), 0], [-1, 0, 1, 0, -1], color=:black, lw=0.5)
   circle(0, 0, 1, :black)
   circle(x1, 0, r1, :red, fill=true)
   circle(-x1, 0, r1, :red, fill=true)
   circle(x2, y2, r2, :black, fill=true)
   circle(x2, -y2, r2, :black, fill=true)
   circle(-x2, y2, r2, :black, fill=true)
   circle(-x2, -y2, r2, :black, fill=true)
   if more == true
       println("r1 = $r1;  x1 = $x1")
       println("r2 = $r2;  x2 = $x2;  y2 = $y2")
       point(x2, y2, "  (x2,y2,r2)", :red, :left, :bottom)
       point(x1, 0, "x1", :black)
       point(x1 + r1, 0, " x1+r1", :black)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

   r1 = 0.24401693585629242;  x1 = 1.2440169358562922
   r2 = 0.0669872981077807;  x2 = 0.46650635094610965;  y2 = 0.8080127018922193

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

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

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