裏 RjpWiki

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

算額(その562)

2023年12月13日 | Julia

算額(その562)

群馬の算額 104-8 長谷寺 文久元年
http://takasakiwasan.web.fc2.com/gunnsann/g104-8.html

直角三角形と全円の隙間に 3 個の等円を入れる。全円の直径が与えられたとき,等円の直径を求めよ。

全円の半径と中心座標を r1, (0, 0)
等円の半径と中心座標を r2, (1 - 3r2, r2 - r1), (r1 - r2, 0), (x, y)
とおき,以下の方程式を解く。

図を描くのでない限り,斜辺に接する等円の中心座標を求める必要はない。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive

eq = (r1 - 3r2)^2 + (r1 - r2)^2 - (r1 + r2)^2
res = solve(eq, r2)
res[1] |> println

   r1/9

等円の半径は全円の半径の 1/9 である。
全円の半径が 1/2 のとき,小円の半径は 1/18,直径は 1/9 である。

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

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

算額(その561)

2023年12月13日 | Julia

算額(その561)

算額(その452)と重複

群馬の算額 104-4 長谷寺 文久元年
http://takasakiwasan.web.fc2.com/gunnsann/g104-4.html

正方形の中に大円,中円,小円を入れる。正方形の一辺の長さが与えられたとき,小円の直径を求めよ。

正方形の一辺の長さを a とする。
大円の半径と中心座標を r1, (r1, 0)
中円の半径と中心座標を r2, (0, 0), (a/2 - r2, 0)
小円の半径と中心座標を r3, (0, a/2 - r3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::positive, r1::positive, r2::positive, r3::positive

r2 = a/6
r1 = 2r2
eq = r2^2 + (a/2 - r3)^2 - (r1 + r3)^2
res = solve(eq, r3)
res[1] |> println

   a/10

小円の半径は正方形の一辺の長さの 1/10 である。
正方形の一辺の長さが 1 のとき,小円の半径は 0.1,直径は 0.2 である。

その他のパラメータは以下の通りである。
小円の直径 = 0.2;  a = 1;  r1 = 0.333333;  r2 = 0.166667;  r3 = 0.1

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

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

算額(その560)

2023年12月13日 | Julia

算額(その560)

群馬の算額 104-7改 長谷寺 文久元年
http://takasakiwasan.web.fc2.com/gunnsann/g104-7kai.html

正三角形に内接する大円,大円に外接し頂点を通る中円,中円と社編が作る弓形の中の小円がある。大円の直径が与えられたとき,小円の直径を求めよ。

大円の半径と中心座標を r1, (0, r1)
中円の半径と中心座標を r2, (0, 2r1 + r2)
小円の半径と中心座標を r3, (x, y)
とおき,以下の連立方程式を解く。
なお,eq1 と (eq2, eq3) は独立なので,まず eq1 から r3 を求め,(x, y) は (eq2, eq3) の連立方程式を解かなくても三角比から求めることもできる。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive, r3::positive, x::positive, y::positive

r2 = r1/2
eq1 = (r2 - 2r3)/r2 - r1/2r1
eq2 = x^2 + (y - 2r1 - r2)^2 - (r2 - r3)^2
eq3 = (y - 2r1 - r2)/x - 1/sqrt(Sym(3))
res = solve([eq1, eq2, eq3], (r3, x, y))
res[1] |> println

   (r1/8, 3*sqrt(3)*r1/16, 43*r1/16)

小円の半径は大円の半径の 1/8 である。
大円の直径が 1 のとき,小円の直径は 0.125 である。

その他のパラメータは以下の通りである。
小円の直径 = 0.125;  r1 = 0.5;  r2 = 0.25;  r3 = 0.0625;  x = 0.16238;  y = 1.34375

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 1/2
   r2 = r1/2
   (r3, x, y) = r1 .* (1/8, 3*sqrt(3)/16, 43/16)
   @printf("小円の直径 = %g;  r1 = %g;  r2 = %g;  r3 = %g;  x = %g;  y = %g\n", 2r3, r1, r2, r3, x, y)
   plot([√3r1, 0, -√3r1, √3r1], [0, 3r1, 0, 0], color=:blue, lw=0.5)
   circle(0, r1, r1)
   circle(0, 2r1 + r2, r2, :green)
   circle(x, y, r3, :magenta)
   circle(-x, y, r3, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
       point(0, r1, " 大円:r1,(0,r1)", :red, :left, :vcenter)
       point(0, 2r1 + r2, " 中円:r2,(0,2r1+r2)", :green, :left, :vcenter)
       point(x, y, "   小円:r3,(x,y)", :magenta, :left, :vcenter)
       point(√3r1, 0, "√3r1  ", :blue, :right, :bottom, delta=delta/2)
       point(0, 2r1, " 2r1", :green, :left, :top, delta=-delta)
       point(0, 3r1, " 3r1", :green, :left, :bottom)
   end
end;

 

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

算額(その559)

2023年12月13日 | Julia

算額(その559)

群馬の算額 104-3 長谷寺 文久元年
http://takasakiwasan.web.fc2.com/gunnsann/g104-3.html

2 個の外円が交わり,大円,小円が入っている。斜線は大円と小円の共通接線である。外円の直径が与えられたとき,小円の直径を求めよ。

外円の半径と中心座標を R, (r1, 0)
大円の半径と中心座標を r1, (0, 0); r1 = R/2
小円の半径と中心座標を r2, (r1 + r2, 0)
とおき,以下の連立方程式を解く。
eq1 と eq2 は独立で,それぞれ r2, x を求めることができる。

include("julia-source.txt");

using SymPy

@syms R::positive, r1::positive, r2::positive, x::positive, y::positive

r1 = R/2
y = sqrt(R^2 - (x - r1)^2)
eq1 = r1/3r1 - r2/(3r1 - r1 - r2)
eq2 = y/sqrt((R + r1 + x)^2 + y^2) - r1/(R + r1)
solve([eq1, eq2], (r2, x))

   1-element Vector{Tuple{Sym, Sym}}:
    (R/4, R*(5 + 4*sqrt(10))/18)

小円の半径は外円の半径の 1/4 である。
外円の直径が 1 のとき,小円の直径は 0.25 である。

その他のパラメータは以下の通りである。
小円の直径 = 0.25;  R = 0.5;  r1 = 0.25;  r2 = 0.125;  x = 0.490253;  y = 0.438496

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = 1/2
   (r1, r2, x) = R .* (1/2, 1/4, (5 + 4*sqrt(10))/18)
   y = sqrt(R^2 - (x - r1)^2)
   @printf("小円の直径 = %g;  R = %g;  r1 = %g;  r2 = %g;  x = %g;  y = %g\n",
       2r2, R, r1, r2, x, y)
   plot()
   circle(r1, 0, R)
   circle(-r1, 0, R)
   circle(0, 0, r1, :green)
   circle(r1 + r2, 0, r2, :blue)
   circle(-r1 - r2, 0, r2, :blue)
   plot!([x, -R - r1, x], [y, 0, -y], color=:magenta, lw=0.5)
   plot!([-x, R + r1, -x], [y, 0, -y], color=:magenta, lw=0.5)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
       point(r1, 0, "r1 ", :green, :right, :bottom, delta=delta/2)
       point(r1 + r2, 0, "r1+r2", :blue, :center, :bottom, delta=delta/2)
       point(r1 + R, 0, "r1+R ", :black, :right, :bottom, delta=delta/2)
       point(x, y, " (x,y)", :magenta, :left, :bottom)
   end
end;

 

 

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

算額(その558)

2023年12月13日 | Julia

算額(その558)

群馬の算額 104-6 長谷寺 文久元年
http://takasakiwasan.web.fc2.com/gunnsann/g104-6.html

外円,大円,中円,小円,等円を図のように配置する。外円の直径が与えられたとき,小円の直径を求めよ。

外円の半径と中心座標を R, (0, 0)
大円の半径と中心座標を r1, (0, y), (r1, y) ; r1 = 2r2
中円の半径と中心座標を r2, (0, R - r2), (r2, y)
小円の半径と中心座標を r3, (0, R - 2r3 - r3), (0, 3r3 - R), (0, r3 - R)
等円の半径と中心座標を r4, (x4, y4)
として,以下の連立方程式を解く。

等円のパラメータは他のパラメータと独立なので,最初に 小円と中円の半径を求める

include("julia-source.txt");

using SymPy

@syms R, r1, y::negative, r2::positive, r3, r4, x4, y4

y = r3 - r2
r1 = 2r2
eq4 = r1^2 + (R - 2r2 - r3 - y)^2 - (r1 + r3)^2
eq5 = r1^2 + (r1 - r3)^2 - (r1 + r3)^2
solve([eq4, eq5], (r2, r3))

   2-element Vector{Tuple{Sym, Sym}}:
    (2*R/7, R/7)
    (2*R, R)

最初のものが適解である。
中円と小円の半径は,外円の半径の 2/7, 1/7 である。
算額の問に対する答えはここまでで完了する。

図を描くために,次に r2, r3 が既知として 等円の半径と中心座標を求める。

@syms R, r1, y::negative, r2::positive, r3, r4, x4, y4

(r2, r3) = (2R/7, R/7)
y = r3 - r2
r1 = 2r2
eq1 = (x4 - r1)^2 + (y4 - y)^2 - (r1 + r4)^2
eq2 = x4^2 + y4^2 - (R - r4)^2
eq3 = x4^2 + (R - r2 - y4)^2 - (r2 + r4)^2
solve([eq1, eq2, eq3], (r4, x4, y4))

   2-element Vector{Tuple{Sym, Sym, Sym}}:
    (5*R*(39 - sqrt(273))/546, 8*sqrt(273)*R/273, R*(3*sqrt(273)/182 + 5/14))
    (5*R*(sqrt(273) + 39)/546, -8*sqrt(273)*R/273, R*(5/14 - 3*sqrt(273)/182))

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

他のパラメータの数値解は以下の通りである。
小円の直径 = 0.285714;  R = 1;  r1 = 0.571429;  r2 = 0.285714;  r3 = 0.142857;  r4 = 0.50845;  x4 = -0.484182;  y4 = 0.0847905

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = 1
   (r2, r3) = R .* (2/7, 1/7)
   (r4, x4, y4) = R .*(5(sqrt(273) + 39)/546, -8*sqrt(273)/273, (5/14 - 3*sqrt(273)/182))
   y = r3 - r2
   r1 = 2r2
   @printf("小円の直径 = %g;  R = %g;  r1 = %g;  r2 = %g;  r3 = %g;  r4 = %g;  x4 = %g;  y4 = %g\n",
       2r3, R, r1, r2, r3, r4, x4, y4)
   plot()
   circle(0, 0, R, :orange)
   circle(0, y, r1)
   circle(r1, y, r1)
   circle(-r1, y, r1)
   circle(0, R - r2, r2, :blue)
   circle(r2, y, r2, :blue)
   circle(-r2, y, r2, :blue)
   circle(0, R - 2r2 - r3, r3, :green)
   circle(0, 3r3 - R, r3, :green)
   circle(0, r3 - R, r3, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
       point(R, 0, " R", :black, :left, :bottom, delta=delta/2)
       point(0, 3r3 - R, " 小円:r3,(0,3r3-R)", :green, :left, :vcenter)
       point(0, r3 - R, " 小円:r3,(0,r3-R)", :green, :left, :vcenter)
       point(0, R - 2r2 - r3, " 小円:r3,(0,R-2r2-r3)", :green, :left, :vcenter)
       point(0, R - r2, " 中円:r2,(0,R-r2)", :blue, :left, :vcenter)
       point(r2, y, "中円:r2\n(r2,y)", :blue, :center, :top, delta=-delta)
       point(r1, y, " 大円:r1\n (r1,y)", :red, :left, :vcenter)
       point(0, y, "y ", :blue, :right, :vcenter)
   end
end;

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

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

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