裏 RjpWiki

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

算額(その837)

2024年04月05日 | Julia

算額(その837)

二 岩手県花巻市大田 清水寺 嘉永三年(1850)

山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市. http://www.wasan.jp/yamamura/yamamura.html

外円の中に交差する 2 個の甲円,隙間に乙円 3 個,丙円 2 個が入っている。外円の直径が 20 寸のとき丙円の直径はいかほどか。

この問題は,算額(その452)と実質的に同じである。甲乙丙円が収まっているのが円と正方形であることと,90° 回転しているところが違う。

外円の半径と中心座標を R, (0, 0)
甲円の半径と中心座標を r1, (0, r2)
乙円の半径と中心座標を r2, (0, 0), (0, 2r2)
丙円の半径と中心座標を r3, (R - r3, 0)
とし,以下の連立方程式を解く。

include("julia-source.txt")

using SymPy

@syms R::positive, r1::positive, r2::positive, r3::positive;
r2 = R/3
r1 = 2r2
eq1 = r2^2 + (R - r3)^2 - (r1 + r3)^2
res = solve(eq1, r3)[1]
res |> println

   R/5

丙円の半径は外円の半径の 1/5 である。
外円の直径が 20 寸のとき,丙円の直径は 4 寸である。

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = 20/2
   r2 = R/3
   r1 = 2r2
   r3 = R/5
   @printf("R = %g; r3 = %g\n", R, r3)
   @printf("丙円の直径 = %g\n", 2r3)
   plot()
   circle(0, 0, R, :green)
   circle22(0, r2, r1, :red)
   circle(0, 0, r2, :blue)
   circle22(0, 2r2, r2, :blue)
   circle2(R - r3, 0, 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, r2, "甲円:r1\n(0,r2)", :red, :center, :bottom, delta=delta)
       point(0, R - r2, "乙円:r2\n(0,R-r2)", :blue, :center, :bottom, delta=delta)
       point(R - r3, 0, "丙円:r3\n(R-r3,0)", :black, :center, :bottom, delta=delta)
       point(R, 0, " R", :green, :left, :vcenter)
       point(0, R, "R", :green, :center, :bottom, delta=delta/2)
   end
end;

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

算額(その836)

2024年04月05日 | Julia

算額(その836)

二 岩手県花巻市大田 清水寺 嘉永三年(1850)

山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.
http://www.wasan.jp/yamamura/yamamura.html

一辺の長さが 12.071 寸の菱形の中に同じ大きさの菱形(同菱)が 3 個入っている。同菱の一辺の長さはいかほどか。

大きな菱形の対角線の長さを 2a, 2b, a > b
同菱の対角線の長さを 2b, 2a1, b > a1
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::positive, b::positive, a1::positive, 菱面::positive
eq1 = a^2 + b^2 - 菱面^2
eq2 = a1/b - b/a
eq3 = a1 + 2b - a
res = solve([eq1, eq2, eq3], (a, b, a1))

   1-element Vector{Tuple{Sym{PyCall.PyObject}, Sym{PyCall.PyObject}, Sym{PyCall.PyObject}}}:
    (菱面*sqrt(10 - 7*sqrt(2))*(2*sqrt(2) + 3)/2, 菱面*(1 + sqrt(2))*sqrt(10 - 7*sqrt(2))/2, 菱面*sqrt(10 - 7*sqrt(2))/2)

同菱面 = sqrt(res[1][2]^2 + res[1][3]^2) |> simplify
同菱面 |> println

   菱面*sqrt(3 - 2*sqrt(2))

二重根号を外すと,同菱面 = 菱面*(√2 - 1) となる。

外側の菱形の一辺の長さが 12.071 寸のとき,内部の小さな菱形の一辺の長さはほぼ 5 寸である。

12.071*(√2 - 1)

   4.999971911405631

術では,菱面/(√2 + 1) となっているが,分母を有理化すると同じである。

@syms d
apart(1/(1 + √Sym(2)), d) |> sympy.sqrtdenest |> println

   -1 + sqrt(2)

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

   a = 11.1521;  b = 4.61937;  a1 = 1.913406;  菱面 = 12.071000

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   菱面 = 12.071
   (a, b, a1) = (菱面*sqrt(10 - 7*sqrt(2))*(2*sqrt(2) + 3)/2, 菱面*(1 + sqrt(2))*sqrt(10 - 7*sqrt(2))/2, 菱面*sqrt(10 - 7*sqrt(2))/2)
   同菱面 = sqrt(b^2 + a1^2)
   @printf("a = %g;  b = %g;  a1 = %.6f;  菱面 = %.6f\n", a, b, a1, 菱面)
   @printf("同菱面 = %g\n", 同菱面)
   plot([a, 0, -a, 0, a], [0, b, 0, -b, 0], color=:blue, lw=0.5)
   plot!([-a, -a1 - b, -a1, 0, a1, a1 + b, a], [0, a1, 0, b, 0, a1, 0], color=:red, lw=0.5)
   plot!([-a, -a1 - b, -a1, 0, a1, a1 + b, a], -1 .* [0, a1, 0, b, 0, a1, 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, :vcenter)
       point(0, b, "b", :blue, :center, :bottom, delta=delta)
       point(a1, 0, "a1 ", :red, :right, :bottom, delta=delta)
       point(a1 + b, a1, " (a1+b,a1)", :red, :left, :bottom, delta=delta)
   end
end;

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

算額(その835)

2024年04月05日 | Julia

算額(その835)

二 岩手県花巻市大田 清水寺 嘉永三年(1850)

山村善夫:現存 岩手の算額,昭和52年1月30日,熊谷印刷,盛岡市.

http://www.wasan.jp/yamamura/yamamura.html

長方形の中に対角線を引き,区画された領域に甲円と乙円を入れる。甲円の直径が 1.5 寸,長方形の長辺が 4 寸のとき,長方形の短辺はいかほどか。

長方形の長辺と短辺の長さをそれぞれ 2a, 2b
甲円の半径と中心座標を r1, (a - r1, 0)
乙円の半径と中心座標を r2, (0, b - r2)
とおき,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms a::positive, b::positive, r1::positive, r2::positive
eq1 = r1/(a - r1) - b/sqrt(a^2 + b^2)
eq2 = r2/(b - r2) - a/sqrt(a^2 + b^2)
res = solve([eq1, eq2], (b, r2));
res[2]

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

2 組の解が得られるが,2 番目のものが適解である。

res[2][1](r1 => 15//10, a => 4) |> println
res[2][2](r1 => 15//10, a => 4) |> println

   3
   4/3

部分式に共通のものがあるので,計算手順は若干簡単にできる。

甲円の直径が 1.5 寸,長方形の長辺が 4 寸のとき,長方形の短辺の長さは 3 寸,乙円の直径は 4/3 寸である。

(r1, a) = (15//20, 4//2)
t = a - 2*r1
b = r1*sqrt(a/t)
r2 = b/(1 + sqrt(1 + r1^2/(t*a)))
println("2b = $(2b);  2(r2) = $(2r2)")

   2b = 3.0;  2(r2) = 1.3333333333333333

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r1, a) = (15//20, 4//2)
   t = a - 2*r1
   b = r1*sqrt(a/t)
   r2 = b/(1 + sqrt(1 + r1^2/(t*a)))
   @printf("a = %g;  b = %g;  r1 = %.6f;  r2 = %.6f\n", a, b, r1, r2)
   @printf("平 = %g\n", 2b)
   plot(a .* [1, 1, -1, -1, 1], b .* [-1, 1, 1, -1, -1], color=:blue, lw=0.5)
   circle2(a - r1, 0, r1)
   circle22(0, b - r2, r2, :green)
   segment(-a, -b, a, b, :magenta)
   segment(-a, b, a, -b, :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(a, 0, " a", :blue, :left, :vcenter)
       point(0, b, "b", :blue, :center, :bottom, delta=delta/2)
       point(a - r1, 0, "甲円:r1,(a-r1,0)", :red, :center, delta=-delta/2)
       point(0, b - r2, "乙円:r2,(0,b-r2)", :green, :center, delta=-delta/2)
   end
end;

 

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

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

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