裏 RjpWiki

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

算額(その2042)

2024年08月24日 | Julia

算額(その2042)

(2) 兵庫県三田市藍本大丸 酒垂神社 文化8年(1811)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円2個,菱形,扇

地紙長が 6.4 寸,菱形の横の対角線の長さが 14.664 寸のとき,等円の直径はいかほどか。

扇長(要から先端までの長さ)を R
地紙長(紙の貼られている部分の長さ)を k
菱形の横の対角線の長さを 2a
等円の半径と中心座標を r, (x, y)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive, x::positive, y::positive,
     a::positive, k::positive
eq1 = x^2 + y^2 - ((R - k) + r)^2
eq2 = dist2(0, R - k, a, sqrt(R^2 -a^2), x, y, r)
eq3 = dist2(0, 0, a, sqrt(R^2 -a^2), x, y, r)
eq4 = sqrt(R^2 -a^2) - (R - k/2)

using NLsolve

function nls(func, params...; ini = [0.0])
   if typeof(ini) <: Number
       r = nlsolve((vout, vin) -> vout[1] = func(vin[1], params..., [ini]), ftol=big"1e-40")
       v = r.zero[1]
   else
       r = nlsolve((vout, vin)->vout .= func(vin, params...), ini, ftol=big"1e-40")
       v = r.zero
   end
   return Float64.(v), r.f_converged
end;

function H(u)
   (R, r, x, y) = u
   return [
x^2 + y^2 - (R - k + r)^2,  # eq1
4*R^2*a^2 - 8*R*a^2*k - 8*R*a^2*y + 4*R*a*k*x + 4*a^2*k^2 + 8*a^2*k*y - 4*a^2*r^2 + 4*a^2*y^2 - 4*a*k^2*x - 4*a*k*x*y - k^2*r^2 + k^2*x^2,  # eq2
-4*R^2*r^2 + 4*R^2*x^2 - 8*R*a*x*y + 4*R*k*r^2 - 4*R*k*x^2 - 4*a^2*r^2 + 4*a^2*y^2 + 4*a*k*x*y - k^2*r^2 + k^2*x^2,  # eq3
-R + k/2 + sqrt(R^2 - a^2),  # eq4

   ]
end;

a = 14.664/2
k = 6.4
iniv = BigFloat[10, 1, 2.6, 3.7]
res = nls(H, ini=iniv)

   ([9.999722499999999, 0.9429406670508707, 2.61703497874062, 3.7130737360479014], true)

地紙長が 6.4,菱横が 14.664 のとき,等円の直径は 1.88588 である。

その他のパラメータは以下のとおりである

   a = 7.332; k = 6.4; R = 9.99972; r = 0.942941; x = 2.61703; y = 3.71307

 

function draw(a, k, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (R, r, x, y) = res[1]
   @printf("地紙長が %g,菱横が %g のとき,等円の直径は %g である。\n", k, 2a, 2r)
   @printf("a = %g;  k = %g;  R = %g;  r = %g;  x = %g;  y = %g\n", a, k, R, r, x, y)
   θ = atand(R - k/2, a)
   plot([-a, 0, a, 0, -a], [R - k/2, R, R - k/2, R - k, R - k/2], color=:green, lw=0.5)
   plot!([-a, 0, a], [R - k/2, 0, R - k/2], color=:red, lw=0.5)
   circle(0, 0, R, beginangle=θ, endangle=180 - θ)
   circle(0, 0, R - k, :blue, beginangle=θ, endangle=180 - θ)
   circle2(x, y, r, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, R, "R", :red, :center, :bottom, delta=delta)
       point(0, R - k/2, "R-k/2", :green, :center, :bottom, delta=delta)
       point(a, R - k/2, "(a,R-k/2)  ", :green, :right, :vcenter)
       point(0, R - k, "R-k", :green, :center, :bottom, delta=delta)
       point(x, y, "r,(x,y)", :magenta, :center, delta=-delta/2)
       dimension_line(2delta, -2delta, a + 2delta, R - k/2 - 2delta, "  扇長", :red, :left)
       dimension_line(a*(R - k)/R + 4delta, (R - k/2)*(R - k)/R - 4delta, a + 4delta, R - k/2 - 4delta, "  地紙長", :green, :left)
   end
end;

draw(14.664/2, 6.4, true)

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

算額(その2041)

2024年08月24日 | Julia

算額(その2041)

(2) 大阪府豊中市服部元町 服部天神社 天保14年(1843)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円3個,外円,矢,弦,団扇

団扇の直径が 12.8 寸,下切(矢)が 5.6 寸で,下切の中に等円を 2 個容れる。等円の直径はいかほどか。

外円(団扇)の半径と中心座標を R, (0, 0)
矢(下切)を 「矢」
等円の半径と中心座標を r, (r, 矢 - R - r)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive, 矢::positive
eq1 = r^2 + (矢 - R - r)^2 - (R - r)^2
res = solve(eq1, r)[2]
res |> println
2res(R => 12.8/2, 矢 => 5.6).evalf() |> println

   sqrt(2)*sqrt(R)*sqrt(2*R - 矢) - 2*R + 矢
   4.80000000000000

等円の半径は「sqrt(2R*(R - 矢) - 2R + 矢」である。
団扇の直径が 12.8 寸,下切(矢)が 5.6 寸 のとき,等円の直径は 4.8 寸である。

function draw(R, 矢, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = sqrt(2)*sqrt(R)*sqrt(2*R - 矢) - 2*R + 矢
   @printf("団扇の直径,下切が %g, %g のとき,等円の直径は %g である。\n", 2R, 矢, 2r)
   plot()
   circle(0, 0, R)
   circle2(r, 矢 - R - r, r, :blue)
   y0 = 矢 - R
   x0 = sqrt(R^2 - y0^2)
   segment(-x0, y0, x0, y0, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(0, y0, " 矢-R", :green, :left, :bottom, delta=delta/2)
       point(r, 矢 - R - r, "等円:r,(0,R-r)", :blue, :center, delta=-delta/2)
   end
end;

draw(12.8/2, 5.6, true)

 

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

算額(その2038)

2024年08月23日 | Julia

算額(その2038)

(15) 京都府夜久野町字額田 妙竜寺 明治20年(1887)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円5個,外円,菱形

大円の中に菱形 1 個,小円 4 個を容れる。菱形の対角線の短いほうが 10 寸,小円の直径が 4 寸のとき,大円の直径はいかほどか。

菱形の対角線を 2a, 2b; a > b
大円の半径と中心座標を R, (0, 0)
小円の半径と中心座標を r, (r, R - b + r), (r, R - b - r)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive, a::positive, b::positive
eq1 = dist2(0, R, sqrt(R^2 - (R - b)^2), R - b, r, R - b + r, r)
res = solve(eq1, R)[2] |> factor
res |> println

   (b^2 - 2*b*r + 2*r^2)^2/(2*b*(-b + 2*r)^2)

2res(b => 10/2, r => 4/2) |> println

   33.8000000000000

菱形の対角線の短いほうが 10 寸,小円の直径が 4 寸のとき,大円の直径は 33.8 寸である。

「答」は 「33.3 寸余」である。「術」が読み切れない。

function draw(b, r, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = (b^2 - 2*b*r + 2*r^2)^2/(2*b*(-b + 2*r)^2)
   a = sqrt(R^2 - (R - b)^2)
   @printf("菱形の対角線の短いほうが %g,小円の直径が %g のとき,大円の直径は %g である。\n", 2b, 2r, 2R)
   @printf("a = %g;  b = %g;  r = %.15g;  R = %.15g\n", a, b, r, R)
   plot([a, 0, -a, 0, a], [R - b, R, R - b, R - 2b, R - b], color=:green, lw=0.5)
   circle(0, 0, R)
   circle2(r, R - b + r, r, :blue)
   circle2(r, R - b - r, r, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(r, R - b + r, " r,(r,R-b+r)", :black, :left, delta=-delta/2)
       point(r, R - b - r, " r,(r,R-b-r)", :black, :left, :bottom, delta=delta/2)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(a, R - b, " (a,R-b)", :green, :left, :vcenter)
       point(0, R - 2b, "R-2b", :green, :center, delta=-delta)
   end
end;

draw(10/2, 4/2, true)

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

算額(その2040)

2024年08月23日 | Julia

算額(その2040)

新潟県小千谷市 小千谷二荒神社 天保4年(1833)
涌田和芳,外川一仁:小千谷二荒神社の紛失算額,長岡工業高等専門学校研究紀要,第 51 巻,p.35-40,2015
https://kinpoku.nagaoka-ct.ac.jp/lib/kiyo/vol_51/51_35wakuta.pdf

弧の中に等円 3 個を容れる。弦が 4.8 寸,矢が 1.2 寸のとき,等円の直径はいかほどか。

注:問で「弦が矢の 2 倍」ということは,弧は半円である。上の図は弦が 4.8 寸,矢が 1.2 寸の場合のものである。

円弧の半径と中心座標を R, (0, 0)
等円の半径と中心座標を r, (0, R - r), (x, y + r); ただし y = R - 矢
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive, x::positive, y::positive,
     矢::positive, 弦::positive
eq1 = x^2 + (y + r)^2 - (R - r)^2
eq2 = x^2 + (R - 2r - y)^2 - 4r^2
eq3 = R - y - 矢
eq4 = y^2 + (弦/2)^2 - R^2
res = solve([eq1, eq2, eq3, eq4], (R, r, x, y))[1]

   ((弦^2 + 4*矢^2)/(8*矢), 矢*(弦^2 + 4*矢^2)/(2*(弦^2 + 8*矢^2)), 弦*矢/sqrt(弦^2 + 8*矢^2), (弦 - 2*矢)*(弦 + 2*矢)/(8*矢))

res[2] |> println
2res[2](弦 => 4.8, 矢 => 1.2) |> println

   矢*(弦^2 + 4*矢^2)/(2*(弦^2 + 8*矢^2))
   1.00000000000000

等円の半径 r は「矢*(弦^2 + 4*矢^2)/(2*(弦^2 + 8*矢^2))」である。
弦が 4.8 寸,矢が 1.2 寸のとき,等円の直径は 1 寸である。

「術」は,「角 = 4矢^2; 矢/(角/(角 + 弦^2) + 1)」である。

@syms 矢, 弦
角 = 4矢^2
矢/(角/(角 + 弦^2) + 1);

角を最終式に代入し,simplify で簡約化すると,前述した式(半径)の 2 倍(直径)になる。

術 = 矢/(4矢^2/(4矢^2 + 弦^2) + 1)
術 |> simplify |> println
術(弦 => 4.8, 矢 => 1.2) |> println

   矢*(弦^2 + 4*矢^2)/(弦^2 + 8*矢^2)
   1.00000000000000

function draw(弦, 矢, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   弦 /= 2
   (R, r, x, y) = ((弦^2 + 4*矢^2)/(8*矢), 矢*(弦^2 + 4*矢^2)/(2*(弦^2 + 8*矢^2)), 弦*矢/sqrt(弦^2 + 8*矢^2), (弦 - 2*矢)*(弦 + 2*矢)/(8*矢))
   @printf("弦,矢が %g, %g のとき,等円の直径は %g である。\n", 弦, 矢, 2r)
   @printf("R = %g;  r = %g;  x = %g;  y = %g\n", R, r, x, y)
   plot()
   circle(0, 0, R)
   circle(0, R - r, r, :blue)
   circle2(x, y + r, r, :blue)
   y0 = R - 矢
   x0 = sqrt(R^2 - y0^2)
   segment(-x0, y0, x0, y0, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(0, y, " y", :blue, :left, :bottom, delta=delta/2)
       point(0, R - r, "等円:r,(0,R-r)", :blue, :center, delta=-delta/2)
       point(x, y + r, "等円:r,(x,y+r)", :blue, :center, delta=-delta/2)
   end
end;

draw(4.8, 1.2, true)

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

算額(その2039)

2024年08月23日 | Julia

算額(その2039)

長野県飯山市木島 鳥出神社 天保14年(1843)
http://www.wasan.jp/nagano/toride1.html

大円の中に,中円,小円を容れる。大円,中円の直径がそれぞれ 180 寸,168 寸のとき,小円の直径はいかほどか。

図形としては,算額(その834)算額(その320)と同類であるが,条件の与え方次第で複雑ににも簡単にもなるという例である。

大円の半径と中心座標を R, (0, 0)
中円の半径と中心座標を r1, (0, R - r1)
小円の半径と中心座標を r2, (r2, y2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r1::positive, r2::positive, y2::negative
eq1 = r2^2 + y2^2 - (R - r2)^2
eq2 = r2^2 + (R - r1 - y2)^2 - (r1 + r2)^2
res = solve([eq1, eq2], (r2, y2))[1];
res[1] |> simplify |> println
res[2] |> simplify |> println

   4*R*r1*(R - r1)/(R + r1)^2
   R*(R - 3*r1)/(R + r1)

大円,中円の直径がそれぞれ 280 寸,168 寸のとき,小円の直径は 105 寸である。

R = 280/2
r1 = 168/2
2(4*R*r1*(R - r1)/(R + r1)^2)

   105.0

その他のパラメータは以下のとおりである。

   R = 140;  r1 = 84;  r2 = 52.5;  y2 = -70

function draw(R, r1, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r2 = 4R*r1*(R - r1)/(R + r1)^2
   y2 = R*(R - 3r1)/(R + r1)
   @printf("大円,中円の直径が %g, %g のとき,小円の直径は %g である。\n", 2R, 2r1, 2r2)
   @printf("R = %g;  r1 = %g;  r2 = %.15g;  y2 = %.15g\n", R, r1, r2, y2)
   plot()
   circle(0, 0, R)
   circle(0, R - r1, r1, :blue)
   circle2(r2, y2, r2, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(0, R - r1, "中円:r1,(0,R-r1)", :blue, :center, delta=-delta/2)
       point(r2, y2, "小円:r2,(r2,y2)", :magenta, :center, delta=-delta/2)
   end
end;

draw(280/2, 168/2, true)

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

算額(その2037)

2024年08月22日 | Julia

算額(その2037)

兵庫県西宮市社家町 復元 西宮神社 天保13年(1843)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円5個,外円,菱形

外円の中に,菱形 1 個,天円 1 個,地円 2 個,小円 1 個を容れる。菱形の対角線の長い方が 8 寸,短い方が 6 寸のとき,小円の直径はいかほどか。

以下の図は,与えられた条件によるものではない。

菱形の対角線の長い方を a,短い方を b
外円の半径と中心座標を R, (0, 0)
天円の半径と中心座標を r1, (0, r1 - R)
地円の半径と中心座標を r2, (x2, y2)
小円の半径と中心座標を r3, (0, R - r3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, R::positive, r1::positive,
     r2::positive, x2::positive, y2::negative, r3::positive
R = r1 + b
eq5 = a^2 + (R - b)^2 - R^2
eq1 = dist2(0, R - 2b, a, R - b, 0, R - b, r3)
eq2 = dist2(0, R - 2b, a, R - b, x2, y2, r2)
eq3 = x2^2 + (y2 - r1 + R)^2 - (r1 + r2)^2
eq4 = x2^2 + y2^2 - (R - r2)^2;
res = solve([eq1, eq2, eq3, eq4, eq5], (r1, r2, x2, y2, r3))[2]

   ((a - b)*(a + b)/(2*b), b*(a - b)*(a + b)/a^2, (a - b)*(a + b)*sqrt(a^2 + b^2)/a^2, (a^2 - 3*b^2)/(2*b), a*b/sqrt(a^2 + b^2))

下図のように,菱形の対角線の長い方が 8 寸,短い方が 6 寸のとき,小円の直径は 2a*b/sqrt(a^2 + b^2) = 2.4 寸である。

「答」は「1 寸 4 分 2 厘有奇」となっているが,算額の「図」を見れば「菱形の対角線の長い方が 8 寸,短い方が 6 寸のとき」のものではない。このページの最初に掲載した図は「菱形の対角線の長い方が 8 寸,短い方が 3 寸のとき」のものである。「術」は,「(√2 - 1)*菱長*菱平/(菱長 + 菱平)」であるが,(「答」とは一致するが,)この計算式は適切とは思えない。

その他のパラメータは以下のとおりである。

  a = 4;  b = 3;  r1 = 1.16666666666667;  r2 = 1.3125;  x2 = 2.1875;  y2 = -1.83333333333333;  r3 = 2.4

function draw(a, b, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r1, r2, x2, y2, r3) = ((a - b)*(a + b)/(2*b), b*(a - b)*(a + b)/a^2, (a - b)*(a + b)*sqrt(a^2 + b^2)/a^2, (a^2 - 3*b^2)/(2*b), a*b/sqrt(a^2 + b^2))
   R = r1 + b
   @printf("a = %g;  b = %g;  r1 = %.15g;  r2 = %.15g;  x2 = %.15g;  y2 = %.15g;  r3 = %.15g\n", a, b, r1, r2, x2, y2, r3)
   plot([a, 0, -a, 0, a], [R - b, R, R - b, R - 2b, R - b], color=:green, lw=0.5)
   circle(0, 0, R)
   circle2(x2, y2, r2, :blue)
   circle(0, r1 - R, r1, :magenta)
   circle(0, R - b, r3, :orange)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, r1 - R, "天円:r1,(0,r1-R)", :magenta, :center, delta=-delta/2)
       point(x2, y2, "地円:r2\n(x2,y2)", :blue, :center, delta=-delta/2)
       point(0, R - b, "小円:r3,(0,R-b)", :orange, :center, delta=-delta/2)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(a, R - b, " (a,R-b)", :green, :left, :vcenter)
   end
end;

draw(8/2, 6/2, true)

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

算額(その2036)

2024年08月22日 | Julia

算額(その2036)

(25) 兵庫県太子堂町鵤 鵤太子堂 明治26年(1893)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円3個,正三角形,斜線2本

正三角形の中に 2 本の斜線を引き,全円,上円,下円を容れる。上円の直径が 4 寸のとき,下円の直径はいかほどか。

求めるものが違うだけで,算額(その968)と同じである(連立方程式は同じ)。
https://blog.goo.ne.jp/r-de-r/e/82cacbc7db96fa08db36ff4511baa626

正三角形の一辺の長さを 2a
斜線と正三角形の斜辺との交点座標を (b, y); y = √3(a - b)
全円の半径と中心座標を r1, (0, r1)
下円の半径と中心座標を r2, (0, r2)
上円の半径と中心座標を r3, (0,  2r1 + r3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, r1::positive, r2::positive, r3::positive
eq1 = dist2(-a, 0, b, √Sym(3)*(a - b), 0, r2, r2)
eq2 = dist2(-a, 0, b, √Sym(3)*(a - b), 0, 2r1 + r3, r3)
eq3 = (√Sym(3)*a - r1) - 2r1
eq4 = (√Sym(3)*a - 2r1 - r3) - 2r3
res = solve((eq1, eq2, eq3, eq4), (a, b, r1, r2))[1]

   (3*sqrt(3)*r3, 5*sqrt(3)*r3/7, 3*r3, 9*r3/4)

下円の半径 r2 は,上円の半径 r3 の 9/4 倍である。
上円の直径が 4 寸のとき,下円の直径は 9 寸である。

その他のパラメータは以下のとおりである。

  r3 = 2;  a = 10.3923048454133;  b = 2.47435829652697;  r1 = 6;  r2 = 4.5

function draw(r3, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (a, b, r1, r2) = (3√3r3, 5√3r3/7, 3r3, 9r3/4)
   @printf("r3 = %g;  a = %.15g;  b = %.15g;  r1 = %.15g;  r2 = %.15g\n", r3, a, b, r1, r2)
   plot([a, 0, -a, 0], [0, √3a, 0, 0], color=:green, lw=0.5)
   circle(0, r1, r1)
   circle(0, r2, r2, :blue)
   circle(0, 2r1 + r3, r3, :magenta)
   segment(-a, 0, b, √3(a - b), :orange)
   segment(a, 0, -b, √3(a - b), :orange)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, √3a, " √3a", :green, :left, :vcenter)
       point(a, 0, " a", :blue, :left, :vcenter)
       point(b, √3(a - b), " (b,√3(a-b))", :orange, :left, :vcenter)
       point(0, r1, "全円:r1,(0,r1)", :red, :center, delta=-delta/2)
       point(0, r2, "下円:r2,(0,r2)", :blue, :center, delta=-delta/2)
       point(0, 2r1 + r3, "上円:r3\n(0,2r1+r3)", :magenta, :center, :bottom, delta=delta/2)
   end
end;

draw(4/2, true)

 

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

算額(その2035)

2024年08月22日 | Julia

算額(その2035)

(25) 兵庫県太子堂町鵤 鵤太子堂 明治26年(1893)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円1個,正方形2個,扇

中心角 120° の扇面に円 1 個,正方形 2 個を容れる。扇型の半径が与えられたとき,正方形の一辺の長さを求めよ。

扇型の半径(扇長)と中心座標を R, (0, 0)
円の半径と中心座標を r, (0, R - r)
2 つの正方形が接する座標を (0, a)
とおき,以下の連立方程式を解く。



補助線をいくつか引くと,a が正方形の一辺の長さに等しいことがわかる。
⊿AOBは∠AOB=30°の直角三角形。AB=OA*sin(30°), OB=OA*cos(30°)
⊿CODは∠COD=15°の直角三角形。OD=R*cos(15°)

include("julia-source.txt");

using SymPy
@syms R::positive, a::positive, r::positive
eq1 = (R*cosd(Sym(15)) - a*cosd(Sym(30))) - 2a*sind(Sym(30))
eq2 = dist2(0, a, R*sind(Sym(15)), R*cosd(Sym(15)), 0, R - r, r);

res = solve([eq1, eq2], (a, r))[1]

   (R*(-sqrt(2) + sqrt(6))/2, R*(-438210300*sqrt(-158146253946563847*sqrt(2) - 91305782287379553*sqrt(6) + 158146253946563847*sqrt(3) + 273917346862138659) - 2 - sqrt(2) + sqrt(6) + 759002504*sqrt(-52715417982187949*sqrt(2) - 30435260762459851*sqrt(6) + 91305782287379553 + 52715417982187949*sqrt(3)))/6)

res[1] |> sympy.sqrtdenest |> simplify |> println
res[1](R => 10).evalf() |> println

   R*(-sqrt(2) + sqrt(6))/2
   5.17638090205041

正方形の一辺の長さは扇長の (√6 - √2)/2 倍である。
扇長が 10 寸のとき,正方形の一辺の長さは 5.17638090205041 寸である。

「術」は sqrt(扇長^2/(√3 + 2)) としているが,簡約化すると上で導いた式と同じになる。

扇長 = 10
sqrt(扇長^2/(√3 + 2))

   5.176380902050416

res[2] |> sympy.sqrtdenest |> simplify |> println
2res[2](R => 10).evalf() |> println

   R*(-sqrt(6) + sqrt(2) + 2)/6
   3.21574606529972

円の半径は長精度の整数を含む長い式であるが,簡約化でき,扇長の (√2 - √6 + 2)/6 倍である。
扇長が 10 寸のとき,円の直径は 3.21574606529972 寸である。

function draw(R, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   a = R*(-sqrt(2) + sqrt(6))/2
   r = R*(-sqrt(6) + sqrt(2) + 2)/6
   s = 2a*sind(30)
   @printf("R = %g;  a = %.15g;  r = %.15g;  s = %.15g\n", R, a, r, s)
   plot()
   circle(0, 0, R, beginangle=30, endangle=150)
   circle(0, R - r, r, :blue)
   r2 = cosd(30)a
   circle(0, 0, r2, :red, beginangle=30, endangle=150)
   plot!([sind(15)R, cosd(45)R, cosd(30)a, 0, sind(15)R], [cosd(15)R, sind(45)R, sind(30)a, a, cosd(15)R], color=:green, lw=0.5)
   plot!(-[sind(15)R, cosd(45)R, cosd(30)a, 0, sind(15)R], [cosd(15)R, sind(45)R, sind(30)a, a, cosd(15)R], color=:green, lw=0.5)
   plot!([cosd(150)R, 0, cosd(30)R], [sind(150)R, 0, sind(30)R], color=:red, lw=0.5)
   segment(0, 0, sind(15)R, cosd(15)R, :gray70)
   segment(0, 0, sind(30)R, cosd(30)R, :gray70)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, R, " R", :red, :left, :bottom, delta=delta/2)
       point(0, R - r, " R-r", :blue, :left, :vcenter)
       point(0, a, " a", :green, :left, :bottom, delta=delta/2)
       point(0, r2, " r2", :red, :left, delta=-delta/2)
   end
end;

draw(10, true)

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

算額(その2034)

2024年08月21日 | Julia

算額(その2034)

(17) 兵庫県姫路市飾磨区英賀宮町 英賀神社 明治12年(1879)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円7個,外円,正三角形2個

大円の中に小円6個,正三角形2個を容れる。大円の直径が 10 寸のとき,大きな正三角形の一辺の長さはいかほどか。


大きな正三角形は大円に内接するので,その一辺の長さは「大円の直径の √3/2 倍」である。
大円の直径が 10 寸のとき,内接する正三角形の一辺の長さは 10√3/2 = 8.660254037844386 寸である。

それだけなら,「小円6個と小さい正三角形」はお飾りに過ぎない。それではもったいないので,小円の直径を求めよう。

大円の半径と中心座標を R, (0, 0)
小円の半径と中心座標を r, (r, R/2 + r)
とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms R::positive, r::positive
eq1 = r^2 + (R/2 + r)^2 ⩵ (R - r)^2
res = solve(eq1, r)[1]
res |> println

   R*(-3 + 2*sqrt(3))/2

小円の半径 r は,大円の半径 R の (√3 - 3/2) 倍である。
大円の直径が 10 寸のとき,小円の直径は 10(√3 - 3/2) = 2.320508075688772 寸である。

function draw(R, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = (√3 - 3/2)R
   @printf("大円の直径が %g のとき,内接する正三角形の一辺の長さは %g, 小円の直径は %g である。\n", 2R, √3R, 2r)
   plot(R.*[0, cosd(30), -cosd(30), 0], R.*[-1, sind(30), sind(30), -1], color=:green, lw=0.5)
   plot!(R.*[0, -cosd(30)/2, cosd(30)/2, 0], R.*[1/2, -sind(30)/2, -sind(30)/2, 1/2], color=:magenta, lw=0.5)
   circle(0, 0, R)
   rotate(r, R/2 + r, r, :blue)
   rotate(-r, R/2 + r, r, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(r, R/2 + r, "小円:r\n(r,R/2+r)", :blue, :center, delta=-delta/2)
       point(0, R, " R", :red, :center, :bottom, delta=delta/2)
       point(0, R/2, " R/2", :red, :center, :bottom, delta=delta/2)
       point(cos(pi/6)R, sin(pi/6)R, "(cos(pi/6)R,sin(pi/6)R) ", :green, :right, delta=-delta/2)
       point(cos(pi/6)R/2, -sin(pi/6)R/2, "(cos(pi/6)R/2,-sin(pi/6)R/2)", :magenta, :right, :bottom, delta=delta/2)
   end
end;

draw(10/2, true)

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

算額(その2033)

2024年08月21日 | Julia

算額(その2033)

(17) 兵庫県姫路市飾磨区英賀宮町 英賀神社 明治12年(1879)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:正三角形,正方形

正三角形の中に正方形を容れる。正三角形の一辺の長さが 10 寸のとき,正方形の一辺の長さはいかほどか。

正三角形の一辺の長さを 2a,正方形の一辺の長さを 2b とおき,以下の方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive
eq1 = 2b/(a - b) ⩵ √Sym(3)
res = solve(eq1, b)[1] |> simplify
res |> println

   a*(-3 + 2*sqrt(3))

正方形の一辺の長さは,正三角形の一辺の長さの (2√3 - 3) 倍である。

2res(a => 10/2).evalf() |> println

   4.64101615137755

正方形の一辺の長さが 10 寸のとき,正三角形の一辺の長さは 10(2√3 - 3) = 4.641016151377544 寸である。 

function draw(a, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   b = (2√3 - 3)a
   plot([a, 0, -a, a], [0, √3a, 0, 0], color=:blue, lw=0.5)
   plot!([b, b, -b, -b, b], [0, 2b, 2b, 0, 0], color=:red, lw=0.5)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(a, 0, " a", :blue, :left, :bottom, delta=delta/2)
       point(b, 0, " b", :red, :left, :bottom, delta=delta/2)
       point(b, 2b, "(b,2b)", :red, :left, :bottom, delta=delta/2)
       point(0, √3a, "√3a", :blue, :left, :bottom, delta=delta/2)
   end
end;

draw(10/2, true)

 

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

算額(その2032)

2024年08月20日 | Julia

算額(その2032)

(17) 兵庫県姫路市飾磨区英賀宮町 英賀神社 明治12年(1879)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円4個,外円,正方形2個

直径が 10 寸の大円の中に 4 個の小円を容れる。大円に内接する正方形の一辺の長さはいかほどか。

大円の半径と中心座標を R, (0, 0)
小円の半径と中心座標を r, (R - r, 0)
大円に内接する正方形の一辺の長さを a1
とおき,順次方程式を立てて解く。

1. 大円に内接する正方形の一辺の長さ a1

include("julia-source.txt");

using SymPy
@syms R::positive, a1::positive, a2::positive,
     r::positive
a1 = 2R/√Sym(2)
a1 |> println
a1(R => 10/2).evalf() |> println

   sqrt(2)*R
   7.07106781186548

直径 10 寸の大円に内接する正方形の一辺の長さは 7.07106781186548 寸である。
「答」では「七寸〇七厘七毛壱六七五」としているが近似値としても不適切。

2. 小円の直径 2r

r = (R - a1/2)/2
2r |> println
2r(R => 10/2).evalf() |> println

   -sqrt(2)*R/2 + R
   1.46446609406726

function draw(R, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   a1 = 2R/√2
   d = -sqrt(2)*R/2 + R
   plot(a1/2 .*[1, 1, -1, -1, 1], a1/2 .*[-1, 1, 1, -1, -1], color=:green, lw=0.5)
   plot!([R - d, 0, d - R, 0, R - d], [0, R - d, 0, d - R, 0], color=:magenta, lw=0.5)
   circle(0, 0, R, :blue)
   circle42(0, R - d/2, d/2)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(R, 0, " R", :blue, :left, :bottom, delta=delta/2)
       point(0, R, " R", :blue, :left, :bottom, delta=delta/2)
       point(0, R - d/2, " 小円:r,(0,R-r)", :red, :left, :vcenter)
       point(R/√2, R/√2, "(R/√2,R/√2)", :green, :left, :bottom, delta=delta/2)
   end
end;

draw(10/2, true)

 

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

算額(その2031)

2024年08月19日 | Julia

算額(その2031)

京都府京都市上京区北野馬喰町 北野天満宮 明治12年(1879)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円4個,二等辺三角形

二等辺三角形の中に,甲円 2 個,乙円と丙円を 1 個ずつ容れる。上斜(斜辺)が 1014 寸,下斜(底辺)が 1428 寸のとき,甲円の直径はいかほどか。

斜辺,底辺を c, 2a とおく。高さは b = sqrt(c^2 - a^2) となる。
甲円の半径と中心座標を r1, (x1, r1)
乙円の半径と中心座標を r2, (0, 2r3 + r2)
丙円の半径と中心座標を r3, (0, r3)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, c::positive,
     r1::positive, x1::positive,
     r2::positive, r3::positive
@syms a, b, c, r1, x1, r2, r3
# b = sqrt(c^2 - a^2) 式には代入しない
eq1 = dist2(a, 0, 0, b, 0, 2r3 + r2, r2)
eq2 = dist2(a, 0, 0, b, x1, r1, r1)
eq3 = x1^2 + (2r3 + r2 - r1)^2 - (r1 + r2)^2
eq4 = x1^2 + (r1 - r3)^2 - (r1 + r3)^2;
# res = solve([eq1, eq2, eq3], (r1, r2, r3))

using NLsolve

function nls(func, params...; ini = [0.0])
   if typeof(ini) <: Number
       r = nlsolve((vout, vin) -> vout[1] = func(vin[1], params..., [ini]), ftol=big"1e-40")
       v = r.zero[1]
   else
       r = nlsolve((vout, vin)->vout .= func(vin, params...), ini, ftol=big"1e-40")
       v = r.zero
   end
   return Float64.(v), r.f_converged
end;

function H(u)
   (r1, x1, r2, r3) = u
   return [
       a^2*b^2 - 2*a^2*b*r2 - 4*a^2*b*r3 + 4*a^2*r2*r3 + 4*a^2*r3^2 - b^2*r2^2,  # eq1
       b*(a^2*b - 2*a^2*r1 - 2*a*b*x1 + 2*a*r1*x1 - b*r1^2 + b*x1^2),  # eq2
       x1^2 - (r1 + r2)^2 + (-r1 + r2 + 2*r3)^2,  # eq3
       x1^2 + (r1 - r3)^2 - (r1 + r3)^2,  # eq4
   ]
end;

a = 1428//2
c = 1014
b = sqrt(c^2 - a^2)

iniv = BigFloat[180, 290, 203, 115]
res = nls(H, ini=iniv)

   ([178.5, 285.6, 203.09333333333333, 114.24], true)

甲円,乙円,丙円の直径はそれぞれ 357 寸,406.18666666666667寸,228.48 寸である。

function draw(a, c, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   #b = sqrt(c^2 - a^2)
   (r1, x1, r2, r3) = res[1]
   @printf("上斜が %g,下斜が %g のとき,甲円の直径は %g である。\n", 2a, c, 2r1)
   plot([a, 0, -a, a], [0, b, 0, 0], color=:green, lw=0.5)
   circle2(x1, r1, r1)
   circle(0, 2r3 + r2, r2, :blue)
   circle(0, r3, r3, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, b, " b", :green, :left, :bottom, delta=delta)
       point(a, 0, " a", :green, :left, :bottom, delta=delta)
       point(x1, r1, "甲円:r1\n(x1,r1)", :red, :center, delta=-delta)
       point(0, 2r3 + r2, "乙円:r2\n(0,2r3+r2)", :blue, :center, delta=-delta)
       point(0, r3, "丙円:r3\n(0,r3)", :magenta, :center, delta=-delta)
   end
end;

draw(1428/2, 1014, true)

 

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

算額(その2030)

2024年08月19日 | Julia

算額(その2030)

福島県小野町 東堂山満福寺観音堂 天保8年(1837)
https://www.nippon.com/ja/japan-topics/c12803/

キーワード:円4個,直角三角形

外円の中に,直角三角形と,その 3 辺の中点を中心とする 3 個の円を容れる。鈎,股が 3 寸,4 寸のとき,外円の直径はいかほどか。

外円の半径と中心座標を R, (x, y)
鈎,股,弦を a, b, c
それぞれの中点を中心とする円の半径を r1, r2, r3
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy
@syms a::positive, b::positive, c::positive, R::positive, r1::positive, r2::positive, r3::positive, x::positive, y::positive
@syms a, b, c, R, r1, r2, r3, x, y
#c = sqrt(a^2 + b^2)
r1 = a/2
r2 = b/2
r3 = c/2
eq1 = x^2 + (r1 - y)^2 - (R - r1)^2
eq2 = (r2 - x)^2 + y^2 - (R - r2)^2
eq3 = (r2 - x)^2 + (r1 - y)^2 - (R - r3)^2
res = solve([eq1, eq2, eq3], (R, x, y))[1]  # 1 of 2

   ((a^5 - a^4*c - a^3*b^2 - a^3*c^2 - a^2*b^3 + a^2*c^3 - sqrt(2)*a^2*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) - sqrt(2)*a*b*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) + sqrt(2)*a*c*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) + b^5 - b^4*c - b^3*c^2 + b^2*c^3)/(4*(a^4 - 2*a^3*c - a^2*b^2 + a^2*c^2 + b^4 - 2*b^3*c + b^2*c^2)), (a^4*b^2 + a^3*b^3 - 3*a^3*b^2*c + sqrt(2)*a^3*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) - 3*a^2*b^3*c + 3*a^2*b^2*c^2 + sqrt(2)*a^2*b*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) - 2*sqrt(2)*a^2*c*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) - a*b^5 + a*b^4*c + a*b^3*c^2 - a*b^2*c^3 - sqrt(2)*a*b*c*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) + sqrt(2)*a*c^2*sqrt(a*b^3*(-a^2 + 2*a*b - b^2 + c^2)) + b^6 - b^5*c - b^4*c^2 + b^3*c^3)/(4*b*(a^4 - 2*a^3*c - a^2*b^2 + a^2*c^2 + b^4 - 2*b^3*c + b^2*c^2)), a*(a^4 - a^3*b - a^3*c + a^2*b*c - a^2*c^2 + a*b^3 - 3*a*b^2*c + a*b*c^2 + a*c^3 + b^4 - 3*b^3*c + 3*b^2*c^2 - b*c^3)/(4*(a^4 - 2*a^3*c - a^2*b^2 + a^2*c^2 + b^4 - 2*b^3*c + b^2*c^2)) + sqrt(2)*sqrt(-a*b^3*(a - b - c)*(a - b + c))*(b - c)*(a + b - c)/(4*(a^4 - 2*a^3*c - a^2*b^2 + a^2*c^2 + b^4 - 2*b^3*c + b^2*c^2)))

R, x, y を a, b, c を含む式で表すと,SymPy では簡約化できない複雑な長い式(省略)になる。
鈎,股として(弦は別途計算),具体的な数値を代入すればよい。

鈎,股が 3 寸,4 寸のとき,外円の直径は 2*72/23 = 6 + 6/23 である。

res[1](a => 3, b => 4, c => 5) |> println 
res[2](a => 3, b => 4, c => 5) |> println 
res[3](a => 3, b => 4, c => 5) |> println 

   72/23
   36/23
   24/23

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

draw(3, 4, true)

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

算額(その2029)

2024年08月19日 | Julia

算額(その2029)

(9) 兵庫県姫路市井ノ口宮山 荒川神社 明治3年(1870)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円2個,直角三角形,正方形

「問」は簡単で,「図のように大円の直径が 9 寸のとき,小円の直径はいかほどか」

これだけでは小円が内接する直角三角形大きさが定まらないが,特に断らない限り「直角三角形の辺(鈎,股,弦)の比は 3:4:5 である」ということであろう。

鈎 = 大円の直径
股 = 4鈎/3
弦 = 5鈎/3
そして,直角三角形に内接する円の直径は,「鈎 + 股 - 弦」である。
簡約化すると小円の直径は大円の直径の 2/3 である。
よって,大円の直径が 9 寸のとき,小円の直径は 6 寸である。

using SymPy
@syms 大円の直径, 鈎, 股, 弦
鈎 = 大円の直径
小円の直径 = (鈎 + 4鈎/3 - 5鈎/3)
小円の直径 |> println

   2*大円の直径/3

図を描くために直角三角形の頂点と,小円の中心座標を求める。

include("julia-source.txt");

using SymPy

@syms r1::positive, x::positive, y::negative,
     r2::positive, x2::positive, y2::positive,
     鈎::positive
鈎 = 2r1
eq1 =dist2(鈎/√Sym(2), 鈎/√Sym(2), x, y, x2, y2, r2)
eq2 =dist2(0, 0, x, y, x2, y2, r2)
eq3 =dist2(0, 0, 鈎/√Sym(2), 鈎/√Sym(2), x2, y2, r2)
eq4 = (x^2 + y^2) - (5*鈎/3)^2
eq5 = ((x - 鈎/√Sym(2))^2 + (y - 鈎/√Sym(2))^2) - (4*鈎/3)^2
res = solve([eq1, eq2, eq3, eq4, eq5], (x, y, r2, x2, y2))[1]  # 1 of 2

   (7*sqrt(2)*r1/3, -sqrt(2)*r1/3, 2*r1/3, sqrt(2)*r1, sqrt(2)*r1/3)

直角三角形の頂点座標 (7√2r1/3, -√2r1/3)
小円の中心座標 (√2r1, √2r1/3)

function draw(r1, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   鈎 = 2r1
   (x, y, r2, x2, y2) = (7√2r1/3, -√2r1/3, 2r1/3, √2r1, √2r1/3)
   plot([0, 鈎/√2, 0, -鈎/√2, 0], [0, 鈎/√2, 2鈎/√2, 鈎/√2, 0], color=:green, lw=0.5)
   plot!([-鈎/√2, -x, 0, x, 鈎/√2], [鈎/√2, y, 0, y, 鈎/√2], color=:green, lw=0.5)
   circle(0, 鈎/√2, r1, :blue)
   circle2(x2, y2, r2)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(0, 鈎/√2, "大円:r1,(0,鈎/√2)", :blue, :center, delta=-delta)
       point(x2, y2, "小円:r2\n(x2,y2)", :red, :center, delta=-delta)
       point(x, y, "(x,y)", :green, :left, :bottom, delta=delta)
       point(鈎/√2, 鈎/√2, "(鈎/√2,鈎/√2)", :green, :left, :bottom, delta=delta)
       point(0, 2鈎/√2, "(0,2鈎/√2)", :green, :left, :bottom, delta=delta)
   end
end;

draw(9/2, true)

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

算額(その2028)

2024年08月18日 | Julia

算額(その2028)

(8) 兵庫県山崎町門前 八幡神社 明治3年(1870)
近畿数学史学会:近畿の算額「数学の絵馬を訪ねて」,平成4年5月16日 初版第一刷,大阪教育図書株式会社,大阪市.
キーワード:円8個,外円,弦2本

長方形の中に斜線2本をひき,黒円 2 個と赤円 1 個を容れる。
長方形の長辺と短辺の長さが 6 寸,4 寸,赤円の直径が 3 寸のとき,黒円の直径はいかほどか。

注:条件が 3 つ与えられているが,赤円の直径は黒円の直径を求めるのには何の役割も持たない。長方形の長辺と短辺の長さだけが与えられれば,黒円の直径も,赤円の直径も別々に求めることができる。

方形の長辺と短辺の長さを 2a, b
黒円の半径と中心座標を r1, (a - r1, r1)
赤円の半径と中心座標を r2, (0, b - r2)
とおき,以下の方程式を(別々に)解く。

1. 黒円の直径

include("julia-source.txt");

using SymPy

@syms a::positive, b::positive,
     r1::positive, r2::positive
eq1 = a + b - sqrt(a^2 + b^2) - 2r1
res1 = solve(eq1, r1)[1]
res1 |> println
res1(a => 6/2, b => 4) |> println

   a/2 + b/2 - sqrt(a^2 + b^2)/2
   1.00000000000000

長方形の長辺と短辺の長さが 6 寸,4 寸 のとき,黒円の直径は 2 寸である。

2. 赤円の直径

赤円の直径は「問」で与えられているが,長方形の長辺と短辺の長さから計算できる。

eq2 = r2/(b - r2) - a/sqrt(a^2 + b^2)
res2 = solve(eq2, r2)[1]
res2 |> println
res2(a => 6/2, b => 4) |> println

   a*b/(a + sqrt(a^2 + b^2))
   1.50000000000000

長方形の長辺と短辺の長さが 6 寸,4 寸 のとき,赤円の直径は(「問」で述べられている通り) 3 寸である。

function draw(a, b, more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = a/2 + b/2 - sqrt(a^2 + b^2)/2
   r2 = a*b/(a + sqrt(a^2 + b^2))
   @printf("長方形の長辺と短辺の長さが %g,%g のとき,黒円の直径は %g,赤円の直径は %g である。\n", 2a, b, 2r1, 2r2)
   plot([a, a, -a, -a, a], [0, b, b, 0, 0], color=:green, lw=0.5)
   circle2(a - r1, r1, r1, :black)
   circle(0, b - r2, r2)
   plot!([-a, 0, a], [b, 0, b], color=:magenta, lw=0.5)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       hline!([0], color=:gray80, lw=0.5)
       vline!([0], color=:gray80, lw=0.5)
       point(a - r1, r1, "黒円:r1,(a-r1,r1)", :black, :center, delta=-delta)
       point(0, b - r2, "赤円:r2,(0,b-r2)", :red, :center, delta=-delta)
       point(a, b, "(a,b)", :green, :right, :bottom, delta=delta)
   end
end;

draw(6/2, 4, true)

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

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

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