裏 RjpWiki

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

大学入学共通テスト2023のIIBの問1(2)

2023年01月19日 | Julia

 

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

算額(その102)

2023年01月19日 | Julia

算額(その102)

東京都千代田区 神田明神 平成30年(2018)3月
http://www.wasan.jp/tokyo/kanda.html

一辺が二の正五角形の頂点を結んでできた星の中に等円が六個入っている。等円一つの面積を求めよ。

一辺が二ということは,下図のように座標を決め,五角形が内接する円の半径を r とすると,r = 1 / sin(36/180*π)
更に,x1 = 2r1*cos(18/180*π), y1 = 2r1*sin(18/180*π)

「点 (x1, y1) から 直線 AB までの距離が等円の半径 r1 に等しい」とする方程式を解いて,r1 を得る。

using SymPy

function distance(x1, y1, x2, y2, x0, y0)
p1, p2 = sympy.Point(x1, y1), sympy.Point(x2, y2)
l = sympy.Line(p1, p2)
l.distance(sympy.Point(x0, y0))
end;

@syms r, x1, y1, r1;
r = 1 / sind(Sym(36));
x1 = 2r1*cosd(Sym(18));
y1 = 2r1*sind(Sym(18));
eq1 = distance(r*cosd(Sym(18)), r*sind(Sym(18)), -r*cosd(Sym(18)), r*sind(Sym(18)), x1, y1) - r1;

r1 = solve(eq1, r1)[1];
r1 |> println

   (-(5 - 3*sqrt(5))*sqrt(5 - sqrt(5))*(-3*sqrt(2) + sqrt(10)) + 4*(-5 + 3*sqrt(5))*sqrt(5 - 2*sqrt(5)))/(2*(5 - 3*sqrt(5))^2)

r1.evalf() |> println

   0.324919696232906

小円の面積は以下の通り。

(r1^2 * π).evalf() |>  println

   0.331666761173503

算額の答えは,「1 引く,2 を 平方根 5 で割,次数のπ倍」とあり,次数って何?また,π倍のパイが若干読み取りにくかったが,
1 - 2/√5 が r1^2 であることがわかれば,等円の面積は (1 - 2/√5)* π ということだ。r1 = √(1 - 2/√5) である。

r1 = (-(5 - 3*sqrt(5))*sqrt(5 - sqrt(5))*(-3*sqrt(2) + sqrt(10)) + 4*(-5 + 3*sqrt(5))*sqrt(5 - 2*sqrt(5)))/(2*(5 - 3*sqrt(5))^2) は簡単にならないが,r1^2 は簡単になる。実に短く 1 - 2/√5 である。

昔の算額は円の径を求めるものが多く,面積を求めるものは少ない。この問題が面積を求めるのには,そういう理由があったのだなと感動した。

r12 = expand(r1^2) |> simplify |> sympy.sqrtdenest |> simplify |>  println

   1 - 2*sqrt(5)/5

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, color=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 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")
   r = 1 / sind(36)
   r1 = sqrt(1 - 2/sqrt(5))
   println("r1 = $r1, S = $(π * r1^2)")
   plot()
   circle(0, 0, r)
   θ = 18:72:378
   x = r.*cosd.(θ)
   y = r.*sind.(θ)
   plot!(x, y, color=:black, lw=0.5)
   circle(0, 0, r1, :blue)
   for i in 1:5
       j = (i + 1) % 5 + 1
       segment(x[i], y[i], x[j], y[j])
       x1 = 2r1 * cosd(θ[i])
       y1 = 2r1 * sind(θ[i])
       circle(x1, y1, r1, :red)
   end
    if more
       x1 = 2r1*cosd(18)
       y1 = 2r1*sind(18)
       info = @sprintf("r1 = %.3f, 等円の面積 = %.3f\nx1 = %.3f, y1 = %.3f\n", r1, π*r1^2, x1, y1)
       point(-0.8, -1.4, info, :black, :left, mark=false)
       point(0, 0, "0 ", :red, :right)
       point(x[1], y[1], " A", :blue)
       point(-x[1], y[1], "B ", :blue, :right)
       point(2r1 * cosd(θ[1]), 2r1 * sind(θ[1]), "(x1,y1)", :blue, :center)
       vline!([0], color=:black, lw=0.5)
       hline!([0], color=:black, lw=0.5)
    end
end;

draw(true)
savefig("fig1.png")

   r1 = 0.32491969623290634, S = 0.3316667611735027

using Plots
function draw()
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r = 1 / sind(36)
   r1 = sqrt(1 - 2/sqrt(5))
   plot(showaxis=false)
   #circle(0, 0, r)
   θ = 18:72:378
   x = r.*cosd.(θ)
   y = r.*sind.(θ)
   plot!(x, y, color=:black, lw=0.5)
   circle(0, 0, r1, :red, fill=true)
   r2 = r*sind(18)/cosd(36)
   for i in 1:5
       j = i + 1
       #point(r2*cosd(θ[i]+36), r2*sind(θ[i]+36), string(i))
       #point(x[i], y[i], string(10+i))
       plot!([x[i], x[j], r2*cosd(θ[i]+36), x[i]], [y[i], y[j], r2*sind(θ[i]+36), y[i]], seriestype=:shape, fillcolor=:blue)
       #segment(x[1], y[1], x[3], y[3])
       x1 = 2r1 * cosd(θ[i])
       y1 = 2r1 * sind(θ[i])
       circle(x1, y1, r1, :red, fill=true)
   end
end;

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

算額(その101)

2023年01月18日 | Julia

算額(その101)

岩手県盛岡市の天満宮 文化 4 年(1807)
一関市博物館 平成29年度,中級問題
https://www.city.ichinoseki.iwate.jp/museum/wasan/h29/images/normal.pdf

正方形の中に半円 2 個,天円 1 個,地円 2 個がある。正方形の 1 辺が 8 寸のとき,天円径,地円径はいくらか。

正方形の一辺の長さの半分(半円の半径)を r として,下図のように記号を定め,方程式を解く。
x2 = r/2, x3 = r - x1 である。

using SymPy

@syms r::positive, x1::positive, x2::positive, x3::positive, r1::positive, r2::positive;
r = 8 // 2
x2 = r / 2
x3 = r - x1
eq1 = (r - x1)^2 + x1^2 - (r - r1)^2
eq2 = (r - x2)^2 + x2^2 - (r - r2)^2
eq3 = 2(x2 - x1)^2 - (r1 + r2)^2
res = solve([eq1, eq2, eq3], (x1, r1, r2))

   2-element Vector{Tuple{Sym, Sym, Sym}}:
    (-4*sqrt(2)*sqrt(11 - 6*sqrt(2))/7 + 2, -4/7 + 6*sqrt(2)/7, 4 - 2*sqrt(2))
    (4*sqrt(2)*sqrt(11 - 6*sqrt(2))/7 + 2, -4/7 + 6*sqrt(2)/7, 4 - 2*sqrt(2))

地円の径(直径)は (12√2 - 8) / 7 = 1.2815089640681632
天円の径(直径)は 8 - 4√2 = 2.3431457505076194

(12√2 - 8) / 7, 8 - 4√2

   (1.2815089640681632, 2.3431457505076194)

地円の中心座標 (x1, x1) は -4*sqrt(2)*(3 - sqrt(2))/7 + 2 から二重根号を外して (22 - 12√2) / 7 = 0.7184910359318367

sympy.sqrtdenest(-4*sqrt(Sym(2))*(3 - sqrt(Sym(2)))/7 + 2) |> println

   22/7 - 12*sqrt(2)/7

(22 - 12√2) / 7

   0.7184910359318367

using Plots
using Printf

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; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
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")
   (x1, r1, r2) = 4 .* (-sqrt(2)*sqrt(11 - 6*sqrt(2))/7 + 1/2, -1/7 + 3*sqrt(2)/14, 1 - sqrt(2)/2)
   (x1, r1, r2) = (-4*sqrt(2)*sqrt(11 - 6*sqrt(2))/7 + 2, -4/7 + 6*sqrt(2)/7, 4 - 2*sqrt(2))
   r = 8 // 2
   x2 = r / 2
   x3 = r - x1
    plot(r .*[0, 2, 2, 0, 0], r .*[0, 0, 2, 2, 0], color=:black, lw=0.5)
   circle(r, 0, r, :green, beginangle=0, endangle=180)
   circle(0, r, r, :green, beginangle=270, endangle=450)
   circle(x1, x1, r1)
   circle(x3, x3, r1)
   circle(x2, x2, r2, :blue)
    if more
       info = @sprintf("x1 = %.3f, x2 = %.3f, x3 = %.3f, r1 = %.3f, r2 = %.3f\n", x1, x2, x3, r1, r2) *
              @sprintf("地円の直径 = %.3f,  天円の直径 = %.3f\n", 2r1, 2r2)
       point(0.1, 1.2r, info, :black, :left, mark=false)
       point(x1, x1, " 地円 (x1,x1); 半径:r1", :red, :left)
       point(x2, x2, " 天円 (x2,x2); 半径:r2", :green, :left)
    end
end;

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

算額(その100)

2023年01月18日 | Julia

算額(その100)

東京都杉並区和田 立法寺 天明8年(1788)正月
http://www.wasan.jp/tokyo/ryuhoji.html

直角三角形の中に甲,乙 2 つの円と,正方形が入っている。正方形の一辺の長さと乙円の直径が等しい。

乙円の半径を x として,左右反転させて,下図のように記号を定め,方程式を解く。

using SymPy

function distance(x1, y1, x2, y2, x0, y0)
p1, p2 = sympy.Point(x1, y1), sympy.Point(x2, y2)
l = sympy.Line(p1, p2)
l.distance(sympy.Point(x0, y0))
end;

@syms x::positive, x2::positive, r::positive, x0::positive, y0::positive;
x = 1
eq1 = (x2 - x)^2 + (r - x)^2 - (r + x)^2
eq2 = (2x - x2)^2 + (2x - r)^2 - r^2
eq3 = x0 * (y0 - 4x) - 2x * y0
eq4 = distance(0, y0, x0, 0, x2, r) - r
res = solve([eq1, eq2, eq3, eq4], (r, x2, x0, y0))

   1-element Vector{NTuple{4, Sym}}:
    (25/16, 7/2, 25*sqrt(23)/28 + 173/28, -1676/49 + 400*sqrt(23)/49)

(25/16, 7/2, 25*sqrt(23)/28 + 173/28, -1676/49 + 400*sqrt(23)/49)

   (1.5625, 3.5, 10.460563860100642, 4.945563455614028)

using Plots
using Printf

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; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
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")
   x = 1
   (r , x2, x0, y0) = (25/16, 7/2, 25*sqrt(23)/28 + 173/28, -1676/49 + 400*sqrt(23)/49)
    plot([0, x0, 0, 0], [0, 0, y0, 0], color=:blue, lw=0.5)
    circle(x, x, x, :green)
   plot!([2x, 0, 0, 2x, 2x], [2x, 2x, 4x, 4x, 2x], color=:magenta, lw=0.5)
   circle(x2, r, r)
    if more
       info = @sprintf("x = %.0f, r = %.4f, x2 = %.1f, x0 = %.3f, y0 = %.3f\n", x, r, x2, x0, y0)
       point(1.7, 4.5, info, :black, :left, mark=false)
       point(x2, r, "甲円 (x2,r)", :red, :center)
       point(2x, 2x, "(2x,2x)", :magenta)
       point(x, x, "乙円 (x,x)", :green, :center)
       point(0, y0, " y0", :black, :left, :bottom)
       point(x0, 0, " x0", :black, :left, :bottom)
    end
end;

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

算額(その99)

2023年01月17日 | Julia

算額(その99)

東京都渋谷区渋谷 金王八幡神社 安政6年(1859)4月
http://www.wasan.jp/tokyo/konnou2.html

参照先の画像では問題文が全く読めない

下図のようjに記号を定め,方程式を解く。

しかし,解は複素数になる。もっとも,虚部はほとんど 0 なのだが,厳密に言えば「@syms R::positive」などとした場合には,「解なし」ということになる。

解の式は恐ろしく複雑になるが,数値にすると以下のようになる。最初の組が適切な解である。

using SymPy
@syms R::positive, r::positive, x::positive, y::positive;
@syms R, r, x, y;
eq1 = r^2 + y^2 - (r + 593)^2;
eq2 = r^2 + (y - R)^2 - (R - r)^2;
eq3 = (593 - r)^2 + R^2 - (R + r)^2;
res = solve([eq1, eq2, eq3], (R, r, y))

   3-element Vector{Tuple{Sym, Sym, Sym}}:
    ((-1186*sqrt(3) - 2965*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/6 - 593*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/6 + 1186*I/3 + 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/6 + 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/6)/(3*sqrt(3) - I), (593*sqrt(3) - 593*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/3 - 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/6 - 593*I/3 + 593*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/12 + 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/12)/(3*sqrt(3) - I), -593/3 + 4151/(9*(7/54 + 7*sqrt(3)*I/18)^(1/3)) + 593*(7/54 + 7*sqrt(3)*I/18)^(1/3))
    ((-1186*sqrt(3) - 4151*sqrt(3)*(28 + 84*sqrt(3)*I)^(1/3)/18 - 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/18 - 1186*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/9 - 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/9 + 593*98^(1/3)*I*(1 + 3*sqrt(3)*I)^(2/3)/18 + 1186*I/3 + 593*sqrt(3)*98^(1/3)*(1 + 3*sqrt(3)*I)^(2/3)/18 + 4151*I*(28 + 84*sqrt(3)*I)^(1/3)/18 + 2965*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/18)/(3*sqrt(3) - I), (593*sqrt(3) - 593*sqrt(3)*98^(1/3)*(1 + 3*sqrt(3)*I)^(2/3)/18 - 4151*sqrt(3)*(28 + 84*sqrt(3)*I)^(1/3)/36 - 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/36 - 593*98^(1/3)*I*(1 + 3*sqrt(3)*I)^(2/3)/18 - 593*I/3 + 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/9 + 4151*I*(28 + 84*sqrt(3)*I)^(1/3)/36 + 1186*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/9 + 2965*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/36)/(3*sqrt(3) - I), -593/3 + 593*(-1/2 - sqrt(3)*I/2)*(7/54 + 7*sqrt(3)*I/18)^(1/3) + 4151/(9*(-1/2 - sqrt(3)*I/2)*(7/54 + 7*sqrt(3)*I/18)^(1/3)))
    ((-1186*sqrt(3) - 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/9 - 1186*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/9 - 593*sqrt(3)*98^(1/3)*(1 + 3*sqrt(3)*I)^(2/3)/18 - 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/18 + 593*98^(1/3)*I*(1 + 3*sqrt(3)*I)^(2/3)/18 + 1186*I/3 + 2965*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/18 + 4151*sqrt(3)*(28 + 84*sqrt(3)*I)^(1/3)/18 + 4151*I*(28 + 84*sqrt(3)*I)^(1/3)/18)/(3*sqrt(3) - I), (593*sqrt(3) - 2965*2^(2/3)*I*(7 + 21*sqrt(3)*I)^(1/3)/18 - 593*2^(1/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(2/3)/18 - 593*2^(1/3)*I*(7 + 21*sqrt(3)*I)^(2/3)/9 - 593*98^(1/3)*I*(1 + 3*sqrt(3)*I)^(2/3)/18 - 593*I/3 + 593*2^(2/3)*sqrt(3)*(7 + 21*sqrt(3)*I)^(1/3)/18 + 4151*sqrt(3)*(28 + 84*sqrt(3)*I)^(1/3)/36 + 4151*I*(28 + 84*sqrt(3)*I)^(1/3)/36 + 593*sqrt(3)*98^(1/3)*(1 + 3*sqrt(3)*I)^(2/3)/18)/(3*sqrt(3) - I), -593/3 + 4151/(9*(-1/2 + sqrt(3)*I/2)*(7/54 + 7*sqrt(3)*I/18)^(1/3)) + 593*(-1/2 + sqrt(3)*I/2)*(7/54 + 7*sqrt(3)*I/18)^(1/3))

for j = 1:length(res)
   println("解 $j")
   println("R = $(res[j][1].evalf())")
   println("r = $(res[j][2].evalf())")
   println("y = $(res[j][3].evalf())")
   println()
end

   解 1
   R = 475.549077332269 - 6.93889390390723e-18*I
   r = 164.545086163906
   y = 739.458905004458 + 0.e-20*I

   解 2
   R = -1332.45890500446 + 1.38777878078145e-17*I
   r = -237.774538666135 + 3.46944695195361e-18*I
   y = -263.909827672189 + 0.e-17*I

   解 3
   R = -329.090172327811
   r = 666.229452502229 - 6.93889390390723e-18*I
   y = -1068.54907733227 + 0.e-18*I

解説したページ https://sites.google.com/site/seijiimura/home/09-san-gaku-no-mondai-ni-chousen/7-jin-wang-ba-fan-shen-sheno-suan-e
凡ミスがあるが,解としては正しい。ただし,右上の小円の中心座標はさらに求める必要がある。

ここで示した SymPy による方法では,必要な数値は(一度で)全て得られる。

算額では 463 寸ばかりとなっているが,中円の径は 475.549077332269 寸に間違いない。

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; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
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")
   R = 475.549077332269
   r = 164.545086163906
   y = 739.458905004458
    plot()
    circle(0, 0, 593, :green)
    circle(0, R, R, :blue)
    circle(0, -R, R, :blue)
   circle(593 - r, 0, r)
   circle(-593 + r, 0, r)
   circle(r, y, r)
   circle(-r, y, r)
   circle(r, -y, r)
   circle(-r, -y, r)
    if more
        point(0, R, "R ", :blue, :right)
        point(0, 593, "593 ", :green, :right)
        point(593-r, 0, "593-r ", :red, :top)
        point(r, y, "(r,y)", :red, :top)
        point(0, 0, "0 ", :brown, :top, :right)
        hline!([0], color=:black, lw=0.5)
        vline!([0], color=:black, lw=0.5)
    end
end;

 

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

算額(その98)

2023年01月13日 | Julia

算額(その98)

以下の解は不適切。「改訂版を参照のこと。

東京都渋谷区渋谷 金王八幡神社 安政6年(1859)4月
http://www.wasan.jp/tokyo/konnou2.html

金王八幡宮③「宝物館」(渋谷散歩③)
https://wheatbaku.exblog.jp/30049403/

参照先の画像では問題文が全く読めない。外円の半径を 1 として,方程式は 3 本立てられるが,条件が一つ足りない。
下図において,両脇の小円の中心の y 座標が小円の直径に等しいとすれば解が得られる。

using SymPy
@syms r1::positive, r2::positive, x::positive, y::positive, y2::positive;
y2 = 2(r1 + r2) - 1  # 外円の中心
y = 2r1  # 追加する条件
eq1 = x^2 + (2r1 + r2 - y)^2 - (r1 + r2)^2;
eq2 = x^2 + (y2 - y)^2 - (1 - r1)^2;
eq3 = x^2 + y^2 - 9r1^2;
solve([eq1, eq2, eq3], (r1, r2, x))

   1-element Vector{Tuple{Sym, Sym, Sym}}:
    (3/10, 3/5, 3*sqrt(5)/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; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
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")
   @syms r1::positive, r2::positive, x::positive, y::positive, y2::positive;
   (r1, r2, x) = (3/10, 3/5, 3*sqrt(5)/10)
   y2 = 2(r1 + r2) - 1
   y = 2r1
   println("r1 = $r1;  r2 = $r2;  x = $x;  y = $y")
    plot()
    circle(0, y2, 1, :green)
    circle(0, r1, r1, :magenta)
    circle(x, y, r1, :magenta)
    circle(-x, y, r1, :magenta)
    circle(0, 2r1 + r2, r2, :brown)
    circle(0, 0, 2r1, :blue, beginangle=0, endangle=180)
    segment(-2r1, 0, 2r1, 0, :blue)
    if more
        point(0, 2r1, "2r1 ", :brown, :right)
        point(0, 2r1+r2, "2r1+r2 ", :brown, :right)
        point(0, r1, "r1 ", :magenta, :right)
        point(x, y, "(x,y)", :magenta, :top)
       point(0, 2(r1 + r2) - 1, "y2 ", :green, :right)
        hline!([0, 2r1], color=:black, lw=0.5)
        vline!([0], color=:black, lw=0.5)
    end
end;

   r1 = 0.3;  r2 = 0.6;  x = 0.6708203932499369;  y = 0.6

 

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

算額(その97)

2023年01月11日 | Julia

算額(その97)

東京都台東区下谷池端 東淵寺 明治2年(1869)
http://www.wasan.jp/tokyo/tobuti.html

正方形の中に半円,大円,小円が図のように配置されている。大円の径が二寸四分八厘のとき,小円の径はいくつか。

大円の半径を 248 として,図のように記号を定めて方程式を解く。

using SymPy
@vars R, r, x, y (positive=true, real=true);
@syms R::positive, r::positive, x::positive, y::positive;
R =248
eq1 = x^2 + (y - r)^2 - 4r^2
eq2 = x^2 + y^2 - R^2
eq3 = x^2 + (R + 2r - y)^2 - (R + r)^2;

(r, x, y) = solve([eq1, eq2, eq3], (r, x, y))[1]

   (-31*sqrt(17)*(109 + 27*sqrt(17))^(2/3)/12 - 961*(109 + 27*sqrt(17))^(1/3)/27 - 1240/27 + 31*sqrt(17)*(109 + 27*sqrt(17))^(1/3)/3 + 1457*(109 + 27*sqrt(17))^(2/3)/108, 248*sqrt(6)*sqrt(-(109 + 27*sqrt(17))^(5/3)*(909*sqrt(17) + 3755) - 2*(109 + 27*sqrt(17))^(4/3)*(4627 + 1125*sqrt(17)) + 32*(109 + 27*sqrt(17))*(2943*sqrt(17) + 12137))/(9*(109 + 27*sqrt(17))^(3/2)), -1984/(81*(109/729 + sqrt(17)/27)^(1/3)) + 248/9 + 248*(109/729 + sqrt(17)/27)^(1/3))

小円の半径は,100.00743003769321 である。元の単位で径に直せばほぼ 1 寸ということで,算額の答えにあっている。

-31*sqrt(17)*(109 + 27*sqrt(17))^(2/3)/12 - 961*(109 + 27*sqrt(17))^(1/3)/27 - 1240/27 + 31*sqrt(17)*(109 + 27*sqrt(17))^(1/3)/3 + 1457*(109 + 27*sqrt(17))^(2/3)/108

   100.00743003769321


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; mark=true)
   mark && scatter!([x], [y], color=color, markerstrokewidth=0)
   annotate!(x, y, text(string, 10, position, color, vertical))
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")
    (r, x, y) = (-31*sqrt(17)*(109 + 27*sqrt(17))^(2/3)/12 - 961*(109 + 27*sqrt(17))^(1/3)/27 - 1240/27 + 31*sqrt(17)*(109 + 27*sqrt(17))^(1/3)/3 + 1457*(109 + 27*sqrt(17))^(2/3)/108, 248*sqrt(6)*sqrt(-(109 + 27*sqrt(17))^(5/3)*(909*sqrt(17) + 3755) - 2*(109 + 27*sqrt(17))^(4/3)*(4627 + 1125*sqrt(17)) + 32*(109 + 27*sqrt(17))*(2943*sqrt(17) + 12137))/(9*(109 + 27*sqrt(17))^(3/2)), -1984/(81*(109/729 + sqrt(17)/27)^(1/3)) + 248/9 + 248*(109/729 + sqrt(17)/27)^(1/3))
    R = 248
    println("r = $r;  x = $x;  y = $y")
    plot()
    circle(0,2r + R, R, :green)
    circle(0, r, r)
    circle(x, y, r)
    circle(-x, y, r)
    circle(0, 0, R + r, :blue, beginangle=0, endangle=180)
    segment(-R-r, 0, R+r, 0, :blue)
    l = r + R
    plot!([-l, l, l, -l, -l], [0, 0, 2l, 2l, 0], color=:black, lw=0.5)
    if more
        point(0, 2r + R, "2r+R ", :green, :right)
        point(0, r, "r ", :red, :right)
        point(x, y, "(x,y)", :red, :top)
        hline!([0], color=:black, lw=0.5)
        vline!([0], color=:black, lw=0.5)
    end
end;

   r = 100.00743003769321;  x = 191.57807116330426;  y = 157.48600778909824

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

算額(その96)

2023年01月11日 | Julia

算額(その96)

東京都台東区下谷池端 東淵寺 明治2年(1869)
http://www.wasan.jp/tokyo/tobuti.html

大円2個,地円3個,人円3個が図のように配置されている。大円の径が 34 寸のとき,人円の径はいくつか。

大円の半径を 34 とし,図のように地円,人円の半径を r2, r3,人円の中心座標を (x, y) として方程式を解く。

using SymPy

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

r1 = 34
eq1 = x^2+ (y-2r2-r3)^2 - (r1+r3)^2 |> expand;
eq2 = (2r2 - x)^2 + (y - r2)^2 - (r1 + r2)^2 |> expand;
eq3 = r2^2 + (r2 - r3)^2 - (r2 + r3)^2 |> expand;
eq4 = x^2 + (y - r2)^2 - (r1 + r2)^2 |> expand;
a = solve([eq1, eq2, eq3, eq4], (r2, r3, x, y))

   1-element Vector{NTuple{4, Sym}}:
    (-68*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 136*sqrt(5)/5 + 408/5, -17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5, -68*sqrt(10*sqrt(5) + 30)/5 + 136*sqrt(5)/5 + 408/5, 238/5 + 136*sqrt(5)/5)

人円の半径は 11.002631123499281 である。

-17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5

   11.002631123499281

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")
   r1 = 34
   (r2, r3, x, y) = (-68*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 136*sqrt(5)/5 + 408/5, -17*sqrt(10)*sqrt(sqrt(5) + 3)/5 + 34*sqrt(5)/5 + 102/5, -68*sqrt(10*sqrt(5) + 30)/5 + 136*sqrt(5)/5 + 408/5, 238/5 + 136*sqrt(5)/5)
   println("地 = $r2, 人 = $r3, x = $x, y= $y")
   plot()
   circle(x, y, r1, :red)
   circle(-x, y, r1, :red)
   circle(0, 2r2 + r3, r3, :blue)
   circle(r2, r3, r3, :blue)
   circle(-r2, r3, r3, :blue)
   circle(0, r2, r2, :magenta)
   circle(2r2, r2, r2, :magenta)
   circle(-2r2, r2, r2, :magenta)
   hline!([0], color=:black, lw=0.5)
   if more
       point(0, r2, "r2 ", :magenta, :right)
       point(x, y, "(x,y)", :red, :top)
       point(r2, r3, "(r2,r3)", :blue, :top)
       vline!([0], color=:black, lw=0.5)
   end
end;

   地 = 44.010524493997124, 人 = 11.002631123499281, x = 44.010524493997124, y= 108.42104898799428

 

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

算額(その95)

2023年01月11日 | Julia

算額(その95)

東京都台東区下谷池端 東淵寺 明治2年(1869)
http://www.wasan.jp/tokyo/tobuti.html

半円の中に等円 2 個と半円 1 個が入っている。外円の径を 2 寸 7 分 とすると等円の径はいくつか。

図のように記号を定め方程式を解く。

using SymPy

@syms R::positive, r::positive, x::positive, y::positive;

R = 27
eq1 = x^2 + (y - r)^2 - 4r^2 |> expand;
eq2 = x^2 + r^2 - (R - r)^2 |> expand;
eq3 = r^2 + y^2 - R^2 |> expand;
a = solve([eq1, eq2, eq3], (r, x, y));

方程式自体は簡単なものなのであるが,方程式の解 a をそのまま書き出すと,虚数単位 I が含まれたりする恐ろしい数式になる。それを .evalf() で数値になおすと以下の3組になる。
まだ I が残っているが 4.74210720465186e-23*I などで誤差の範囲で実数である。2 番目と 3 番目の解は不適切解である。
つまるところ r = 10.0929641600229, x = 13.5639203535985, y = 25.0426051852537 ということであろう。
よって等円の径は 1 寸 0 分 0 厘 9 毛である。

for i in 1:3
   println("r = $(a[i][1].evalf());  x = $(a[i][2].evalf());  y = $(a[i][3].evalf())")
end

   r = 10.0929641600229;  x = 13.5639203535985 + 4.74210720465186e-23*I;  y = 25.0426051852537 + 0.e-22*I
   r = -22.2346710141611 - 4.33680868994202e-19*I;  x = 43.928034724589 + 1.17139889977585e-22*I;  y = -15.3172910428713 - 0.e-21*I
   r = 17.5417068541382 + 4.33680868994202e-19*I;  x = 14.7733601500627*I;  y = -20.5253141423824 + 0.e-21*I

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")
   (R, r, x, y) = (27, 10.0929641600229, 13.5639203535985, 25.0426051852537)
   plot()
   circle(0, 0, R, :red, beginangle=0, endangle=180)
   circle(x, r, r, :blue)
   circle(-x, r, r, :blue)
   circle(0, y, r, :blue, beginangle=180, endangle=360)
   segment(-r, y, r, y, :blue)
   segment(-R, 0, R, 0, :red)
   if more
       point(0, y, "y ", :blue, :right)
       point(0, r, "r ", :blue, :right)
       point(x, r, "(x,r)", :blue, :top)
       point(x, 0, "  x", :blue, :bottom)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   end
end;

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

Julia v1.8.5 出ました

2023年01月10日 | Julia

Current stable release: v1.8.5 (January 8, 2023)

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

算額(その94)

2023年01月09日 | Julia

算額(その94)

東京都武蔵野市 西窪稲荷神社 嘉永5年(1852)
http://www.wasan.jp/tokyo/nisikubo.html

別サイトのPDF で見る
https://www.city.musashino.lg.jp/_res/projects/default_project/_page_/001/021/965/202103_bunkazai_omote-s10.pdf

径が 1 丈(= 10 尺)の 2 つの甲円の上に径 8 尺の乙円があり,丙円が図のように配置されている。乙円の弦と弧,丙円の径を求めよ。

甲円の半径を 10,丙円の半径を r として,以下のように記号を定め,方程式を解く。
乙円の弦は ab, 弧は arb である。

using SymPy
@syms r::positive, x::positive;
eq1 = 10^2 + (r + 8)^2 - (8 + 10)^2;
eq2 = x^2 +(r+8-10)^2 - 8^2;
solve([eq1, eq2], (r, x)) |> println

   Tuple{Sym, Sym}[(-8 + 4*sqrt(14), 2*sqrt(-65 + 20*sqrt(14)))]

(-8 + 4*sqrt(14), 2*sqrt(-65 + 20*sqrt(14)))

   (6.966629547095765, 6.271570053974948)

乙円の径は算額では丙円の径を 6 尺 9 寸 6 分余としているが 6.96663。
弦は算額で 6 尺 2 寸 7 分であるが 6.27157。

2*8*pi * asin(6.271570053974948/8)/2pi

   7.20797588918886

弧は算額で 7 尺 2 寸 5 分余であるが 7.20798 であった。

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")
   (r1, r2, r3, x2, x3, x, y) = [0.13839876084731936, 0.17954306798152128, 0.3287706665765487,
       0.45366714256276236, 0.9395827489780465, 1.2683534155545952, 1.268353415554595]
   (r, x) = (-8 + 4*sqrt(14), 2*sqrt(-65 + 20*sqrt(14)))
   println("径 = $r;  弦 = $(x);  弧 = $(2*8*pi * asin(x/8)/2pi)")
   plot()
   circle(0, r + 8, 8)
   circle(10, 0, 10, :green)
   circle(-10, 0, 10, :green)
   circle(0, 0, r, :blue)
   if more
       point(0, 0, "0 ", :black, :right)
       point(0, r, "r ", :red, :right)
       point(0, r + 8, "r+8 ", :red, :right)
       point(10, 0, " 10", :green)
       point(x, 10, "a\n(x,10)", :black, :center)
       point(-x, 10, "b\n(-x,10)", :black, :center)
       segment(-10, 10, 10, 10, :magenta)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   end
end;

   径 = 6.966629547095765;  弦 = 6.271570053974948;  弧 = 7.20797588918886

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

算額について中間報告

2023年01月06日 | Julia

まあ,SymPy 最強ということかな

解けない算額は少ない(解けないのは,小生の力不足)

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

算額(その93)

2023年01月06日 | Julia

算額(その93)

千葉県君津市 神野寺 明治20(1887)年4月
http://www.wasan.jp/chiba/jinyaji2.html

甲円の下に乙円,丙円,丁円がある。各円の径を求めよ。

甲円の半径を 1 として,以下のように記号を定め,方程式を解く。
なお,solve() では解が求まらないので,nlsolve() を使用し,数値的に解を求める。

using SymPy
@syms r1::positive, r2::positive, r3::positive, x1::positive, x2::positive, x3::positive, x::positive, y::positive;
r = 1
x1 = r1 
eq1 = x*x3 + y*(r3 - y) |> expand
eq2 = r3*x - y*(x - x3) |> expand
eq3 = x1^2 + (y - r1)^2 - (r + r1)^2 |> expand
eq4 = x2^2 + (y - r2)^2 - (r + r2)^2 |> expand
eq5 = x3^2 + (y - r3)^2 - (r + r3)^2 |> expand
eq6 = (x2 - x1)^2 + (r2 - r1)^2 - (r2 + r1)^2 |> expand
eq7 = (x3 - x2)^2 + (r3 - r2)^2 - (r3 + r2)^2 |> expand;

# solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], (r1, r2, r3, x2, x3, x, y))

eq1 |> println
eq2 |> println
eq3 |> println
eq4 |> println
eq5 |> println
eq6 |> println
eq7 |> println


   r3*y + x*x3 - y^2
   r3*x - x*y + x3*y
   r1^2 - 2*r1*y - 2*r1 + y^2 - 1
   -2*r2*y - 2*r2 + x2^2 + y^2 - 1
   -2*r3*y - 2*r3 + x3^2 + y^2 - 1
   r1^2 - 4*r1*r2 - 2*r1*x2 + x2^2
   -4*r2*r3 + x2^2 - 2*x2*x3 + x3^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=1e-14)
v = r.zero[1]
else
r = nlsolve((vout, vin)->vout .= func(vin, params...), ini, ftol=1e-14)
v = r.zero
end
return v, r.f_converged
end;

function H(u)
(r1, r2, r3, x2, x3, x, y) = u
return [
       r3*y + x*x3 - y^2,
       r3*x - x*y + x3*y,
       r1^2 - 2*r1*y - 2*r1 + y^2 - 1,
       -2*r2*y - 2*r2 + x2^2 + y^2 - 1,
       -2*r3*y - 2*r3 + x3^2 + y^2 - 1,
       r1^2 - 4*r1*r2 - 2*r1*x2 + x2^2,
       -4*r2*r3 + x2^2 - 2*x2*x3 + x3^2
      ];
end;

iniv = [0.1, 0.2, 0.3, 0.4, 0.7, 1.0, 1.1];
res = nls(H, ini=iniv)

   ([0.13839876084731936, 0.17954306798152128, 0.3287706665765487, 0.45366714256276236, 0.9395827489780465, 1.2683534155545952, 1.268353415554595], true)

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")
   (r1, r2, r3, x2, x3, x, y) = [0.13839876084731936, 0.17954306798152128, 0.3287706665765487,
       0.45366714256276236, 0.9395827489780465, 1.2683534155545952, 1.268353415554595]
   r = 1
   plot()
   circle(0, y, 1)
   circle(r1, r1, r1, :green)
   circle(-r1, r1, r1, :green)
   circle(x2, r2, r2, :blue)
   circle(-x2, r2, r2, :blue)
   circle(x3, r3, r3, :magenta)
   circle(-x3, r3, r3, :magenta)
   hline!([0], color=:black, lw=0.5)
   if more
       point(0, y, "y ", :red, :right)
       point(0, y-r, "y-r ", :red, :right)
       point(r1, r1, "(r1,r1)", :green, :top)
       point(x2, r2, "(x2,r2)", :green, :top)
       point(x3, r3, "(x3,r3)", :magenta, :top)
       point(x, 0, "   x", :magenta, :bottom)
       segment(0, y, x, 0, :black)
       vline!([0], color=:black, lw=0.5)
   end
end;

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

算額(その92)

2023年01月06日 | Julia

算額(その92)

千葉県君津市 鹿野山神野寺 明治20(1887)年4月
http://www.wasan.jp/chiba/jinyaji4.html

山口正義(2018): やまぶき4(第58号)
https://yamabukiwasan.sakura.ne.jp/ymbk58.pdf

長方形内に大円,中円,小円入っている。長方形の長辺の長さが25寸のとき,小円の径を求めよ。

長方形の長辺の長さを 2a,短辺の長さを b とおく。
大円の半径と中心座標を r1, (r1, b - r1)
中円の半径と中心座標を r2, (0, r2), (2r2, r2)
小円の半径と中心座標を r3, (0, 2r2 + r3)
とおき,連立方程式を解く。

include("julia-source.txt")

using SymPy
@syms r1::positive, r2::positive, r3::positive, a::positive, b::positive;
(r1, r2) = a .* (1//2, 1//3)
eq1 =(r1 - r2)^2 + (b - r1 - r2)^2 - (r1 + r2)^2
eq2 = r1^2 + (b - r1 - (2r2 + r3))^2 - (r1 + r3)^2
res = solve([eq1, eq2], (b, r3))

   1-element Vector{Tuple{Sym, Sym}}:
    (23*a*(-31/69 + 16*sqrt(6)/69)/16 + 71*a/48, a*(-31/69 + 16*sqrt(6)/69))

   r3 = 1.48403;  b = 20.6229
   小円の直径 = 2.96806

小円の半径は a*(16√6 - 31)/69 である。

2a = 25 寸のとき,小円の半径は 1.4840282399512403寸(直径は 2.968056479902481寸)である。

(25/2)*(16√6 - 31)/69

   1.4840282399512403

function draw(more=false)
   pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   a = 25//2
   (r1, r2) = a .* (1//2, 1//3)
   (b, r3) = (23*a*(-31/69 + 16*sqrt(6)/69)/16 + 71*a/48, a*(-31/69 + 16*sqrt(6)/69))
   @printf("r3 = %g;  b = %g\n", r3, b)
   @printf("小円の直径 = %g\n", 2r3)
   plot([a, a, -a, -a, a], [0, b, b, 0, 0], color=:black, lw=0.5)
   circle(r1, b - r1, r1)
   circle(-r1, b - r1, r1)
   circle(0, r2, r2, :green)
   circle(a - r2, r2, r2, :green)
   circle(r2 - a, r2, r2, :green)
   circle(0, 2r2 + r3, r3, :blue)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /  3  # size[2] * fontsize * 2
       point(r1, b - r1, "大円:r1,(r1,b-r1)", :red, :center, delta=-delta)
       point(a - r2, r2, "中円:r2,(a-r2,r2)", :green, :center, delta=-delta)
       point(0, 2r2 + r3, " 小円:r3,(0,2r2+r3)", :blue, :left, :vcenter)
       hline!([0], color=:gray, lw=0.5)
       vline!([0], color=:gray, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

 

 

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

算額(その91)

2023年01月06日 | Julia

算額(その91)

千葉県君津市 神野寺 明治20(1887)年4月
http://www.wasan.jp/chiba/jinyaji4.html

円内に正三角形,甲円,乙円,丙円がある。それぞれの径を求めよ。

外円の半径を 1 とする。甲円の半径は 1/2 である。次いで,順に乙円,丙円の中心座標と径を求める。SymPy を使わあなくても求めることができる。

乙円の半径は 1/4 中心座標は cosd(i)*3/4, sind(i)*3/4, i = 30, 150, 270
丙円の半径は 1/6 中心座標は cosd(i+60)*2/3, sind(i+60)*2/3, i = 30, 150, 270

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()
   circle(0, 0, 1, :black)
   plot!([0, cosd(-30), cosd(210), 0], [1, sind(-30), sind(210), 1], color=:magenta, lw=0.5)
   circle(0, 0, 1/2)
   for i = 30:120:270
       circle(cosd(i)*3/4, sind(i)*3/4, 1/4, :green)
       circle(cosd(i+60)*2/3, sind(i+60)*2/3, 1/6)
   end
   hline!([0], color=:black, lw=0.5)
   if more
       point(0, 0, "0 ", :red, :right)
       point(0, 1/2, "1/2 ", :red, :right)
       point(0, 2/3, "2/3 ", :blue, :right)
       point(cosd(30)*3/4, sind(30)*3/4, "(x,y)\nx=cosd(30)*3/4\ny=sind(30)*3/4", :green, :top)
       vline!([0], color=:black, lw=0.5)
   end
end;

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

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

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