裏 RjpWiki

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

算額(その82)

2022年12月28日 | Julia

算額(その82)

福島県田村郡三春町平沢担橋 諏訪神社 大正15年(1926)8月
http://www.wasan.jp/fukusima/miharusuwa.html

直線の上に乙円と甲円が載り,その上に丙円が載っている。甲円,丙円の径をそれぞれ二寸,三寸としたとき,乙円の径を求めよ。

図のように記号を定め,r, x を求める。

using SymPy
@syms x::positive, r::positive;
eq1 = x^2 + (4 + r - 3)^2 - (r + 3)^2
eq2 = x^2 + 1 - (2 + 3)^2
solve([eq1, eq2], (r, x))

   1-element Vector{Tuple{Sym, Sym}}:
    (4, 2*sqrt(6))

丙円の径は 4 である。


using Plots

function circle(ox, oy, r, color=:red; beginangle=0, endangle=360)
 θ = beginangle:0.1:endangle
 x = r.*cosd.(θ)
 y = r.*sind.(θ)
 plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
end;

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

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r, x) = (4, 2*sqrt(6))
   plot()
   circle(0, 2, 2)
   circle(0, 4 + r, r, :green)
   circle(x, 3, 3, :blue)
   circle(-x, 3, 3, :blue)
   hline!([0], color=:black, lw=0.5)
   if more
       point(0, 4 + r, "丙円 \n4+r ", :green, :bottom, :right)
       point(0, 2, "甲円 \n2 ", :red, :bottom, :right)
       point(x, 3, "乙円 (x,3)", :blue, :top, :center)
       vline!([0], color=:black, lw=0.5)
   end
end;

 

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

算額(その81)

2022年12月28日 | Julia

算額(その81)

福島県船引町 蚕養国神社 明治24年(1891)2月
http://www.wasan.jp/fukusima/kogaikuni.html

台形の中に,正六角形,正三角形が入っている。大頭が 97 寸のとき,正三角形の辺の長さを求めよ。

正六角形の一辺の長さを2として,それぞれの点の座標を決定して行く。

図の a, c の座標まで決めればよい。大頭は 5,a, c の距離が正三角形の一辺の長さ 5/√3 である。

using SymPy
sqrt((5sqrt(Sym(3))/2-5sqrt(Sym(3))/3)^2+(5//2)^2) |> println  # a,c の距離

   5*sqrt(3)/3

算額では「大頭が 97 寸のとき」なので,97/sqrt(3) = 56.0029761113937 である。

算額の答え「置三個 開平方 以除大頭」は「3 の平方根で大頭を割る」ということである。

97/√3

   56.0029761113937

using Plots

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

function segment(x1, y1, x2, y2, color=:black; linestyle=:solid, linewidth=0.5)
 plot!([x1, x2], [y1, y2], color=color, linestyle=linestyle, linewidth=linewidth)
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   plot(xlims=(-0.3, 6.2), ylims=(-0.3, 5.2))
   hline!([0], color=:black, lw=0.5)
   vline!([0], color=:black, lw=0.5)
   plot!([√3, 0, 0, √3, 2√3, 2√3, √3], [0, 1, 3, 4, 3, 1, 0], color=:blue, lw=0.5)
   plot!([0, 0, √3], [1, 0, 0])
   plot!([0, 0, √3], [3, 5, 4])
   segment(5√3/3, 0, 2√3, 1, :brown)
   segment(2√3, 3, 5√3/2, 5/2, :green)
   segment(2√3, 1, 5√3/2, 5/2, :red)
   segment(5√3/2, 5/2, 10√3/3, 0, :magenta)
   segment(5√3/2, 5/2, 10√3/3, 5/3, :blue)
   segment(10√3/3, 5/3, 10√3/3, 0, :cyan)
   if more
       point(0.05, 2.5, "大 \n\n\n頭 ", :black, :right, mark=false)
       point(5.9, 1.3, "小\n\n\n頭", :black, mark=false)
       point(5√3/2, 5/2, "   a:(5√3/2, 5/2)")
       point(5√3/3, 0, " c:5√3/3")
       point(10√3/3, 0, "  b:10√3/3")
       point(√3, 0, "√3")
       point(2√3, 1, "  (2√3, 1)")
       point(2√3, 3, "  (2√3, 3)")
       point(√3, 4, "  (√3, 4)")
       point(10√3/3, 5/3, " (10√3/3, 5/3)")
   end
end;

 

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

算額(その80)

2022年12月28日 | Julia

算額(その80)

福島県船引町 蚕養国神社 明治24年(1891)2月
http://www.wasan.jp/fukusima/kogaikuni.html

正三角形に内接する全円と大円,小円がある。小円の径が 3 寸のとき,全円の径はいくつか。

正三角形の一辺の長さを 1 とすると全円の半径 r0 は √3/3,大円の半径 r1 は √3/5である。小円の半径を r2,その中心座標を (x2, 2r1) として方程式を立て,x2, r2 を求める。

using SymPy
@syms x2::positive, r2::positive;
r1 = √Sym(3) / 5
r0 = √Sym(3) / 3
eq1 = x2^2 + r1^2 - (r1 + r2)^2
eq2 = x2^2 + (2r1 - r0)^2 - (r0 - r2)^2;
solve([eq1, eq2], (x2, r2))

   1-element Vector{Tuple{Sym, Sym}}:
    (sqrt(15)/10, sqrt(3)/10)

r2 = sqrt(3)/10 が 3 寸ならば,全円の径は 3*r0/(sqrt(3)/10) = 10 寸である。

3*r0/(sqrt(Sym(3))/10) |> println

   10

using Plots

function circle(ox, oy, r, color=:red; beginangle=0, endangle=360)
 θ = beginangle:0.1:endangle
 x = r.*cosd.(θ)
 y = r.*sind.(θ)
 plot!(ox .+ x, oy .+ y, color=color, linewidth=0.5)
end;

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

function segment(x1, y1, x2, y2, color=:black; linestyle=:solid, linewidth=0.5)
 plot!([x1, x2], [y1, y2], color=color, linestyle=linestyle, linewidth=linewidth)
end;

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   plot([-1, 1, 0, -1], [0, 0, √3, 0], color=:black, lw=0.5)
   r0 = √3/3
   r1 = √3/5
   (x2, r2) = (sqrt(15)/10, sqrt(3)/10)
   println("r0 = $r0;  r1 = $r1;  r2 = $r2;  3*r0/r2 = $(3r0/r2)")
   circle(0, r0, r0)
   circle(0, r1, r1, :green) 
   circle(0, 3r1, r1, :green) 
   circle(x2, 2r1, r2, :blue)
   circle(-x2, 2r1, r2, :blue)
   if more
       circle(0, 4r1, r1, :gray)
       point(0, √3/3, "r0 ", :red, :right)
       point(0, r1, "r1 ", :green, :right)
       point(0, 3r1, "3r1 ", :green, :right)
       point(x2, 2r1, "(x2,2r1)", :green, :top, :center)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   end
end;

   r0 = 0.5773502691896257;  r1 = 0.34641016151377546;  r2 = 0.17320508075688773;  3*r0/r2 = 10.0

 

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

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

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