裏 RjpWiki

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

算額(その374)

2023年08月07日 | Julia

算額(その374)

長野県埴科郡坂城町 諏訪社 文化2年(1805)
中村信弥「改訂増補長野県の算額」

http://www.wasan.jp/zoho/zoho.html
県内の算額1(78)

大小の半円が交わる中に,甲円,乙円を入れる。小円の径が 27 寸,乙円の径が 9寸のとき,甲円の径を求めよ。

算額(その373)に似ているが,この問題ではヒントとなる (0, 2r1)-(2r1, 0) の線分が描かれていないので,条件が足りないなあと思って先送りしていた。

追記: 2024/03/16
乙円の中心座標 (x4, y4) については特に条件を設定しなかったのであるが,暗黙の了解で(?)「乙円の中心は,大円と小円の中心を結ぶ線分上にある」とするようである。そのような条件にすると,中村が指摘した「二百五十分之七十の誤写」のとおりになる。

大円の半径と中心座標を r1, (r1, 0)
小円の半径と中心座標を r2, (0, r2);  r2 = 27/2
甲円の半径と中心座標を r3, (x3, r3)
乙円の半径と中心座標を r4, (x4, y4); r4 = 9/2
大円と小円の交点座標を (x0, y0)
として,以下の連立方程式解く。

include("julia-source.txt");

using SymPy
@syms r1::positive,  r2::positive, r3::positive, r4::positive,
   x3::positive, x4::positive, y4::positibe, x0::positive, y0::positive;

eq1 = (x3 - r1)^2 + r3^2 - (r1 - r3)^2  # 甲円が大円に内接する
eq2 = (r1 - x4)^2 + y4^2 - (r1 - r4)^2  # 乙円が大円に内接する
eq3 = x4^2 + (r2 - y4)^2 - (r2 - r4)^2  # 乙円が小円に内接する
eq4 = x3^2 + (r2 - r3)^2 - (r2 + r3)^2  # 甲円が小円に外接する
eq5 = (2r2 - y0)*r1 - r2*x0  # (x0, y0) は大円と小円の交点
eq5 = y4/(r1 - x4) - r2/r1  # こちらの条件を使う
eq6 = (x0 - r1)^2 + y0^2 - r1^2;
eq7 = x0^2 + (y0 - r2)^2 - r2^2;
res = solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7], (r1, r3, x3, x4, y4, x0, y0))

   1-element Vector{NTuple{7, Sym{PyCall.PyObject}}}:
    (2*r4*(r2 - r4)/(r2 - 2*r4), 4*r2*r4^2*(r2 - r4)^2/(-r2^2 + r2*r4 + r4^2)^2, 4*r2*r4*(r2 - r4)/(r2^2 - r2*r4 - r4^2), 2*r4*(r2 - r4)^2/(r2^2 - 2*r2*r4 + 2*r4^2), r2^2*r4/(r2^2 - 2*r2*r4 + 2*r4^2), 4*r2^2*r4*(r2 - 2*r4)*(r2 - r4)/(r2^2 - 2*r2*r4 + 2*r4^2)^2, 8*r2*r4^2*(r2 - r4)^2/(r2^2 - 2*r2*r4 + 2*r4^2)^2)

2res[1][2] |> println
2res[1][2](r2 => 27//2, r4 => 9//2) |> println
2res[1][2](r2 => 27//2, r4 => 9//2).evalf() |> println

   8*r2*r4^2*(r2 - r4)^2/(-r2^2 + r2*r4 + r4^2)^2
   432/25
   17.2800000000000

小円の径が 27 寸,乙円の径が 9 寸のとき,甲円の径は 432/25 =  17.28 寸 = 17 寸 7/25 分である。

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

r1 = 18;  r3 = 8.64;  x3 = 21.6;  x4 = 7.2;  y4 = 8.1;  x0 = 12.96;  y0 = 17.28

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r2, r4) = (27, 9) .// 2
   (r1, r3, x3, x4, y4, x0, y0) = (
       2*r4*(r2 - r4)/(r2 - 2*r4),
       4*r2*r4^2*(r2 - r4)^2/(-r2^2 + r2*r4 + r4^2)^2,
       4*r2*r4*(r2 - r4)/(r2^2 - r2*r4 - r4^2),
       2*r4*(r2 - r4)^2/(r2^2 - 2*r2*r4 + 2*r4^2),
       r2^2*r4/(r2^2 - 2*r2*r4 + 2*r4^2),
       4*r2^2*r4*(r2 - 2*r4)*(r2 - r4)/(r2^2 - 2*r2*r4 + 2*r4^2)^2,
       8*r2*r4^2*(r2 - r4)^2/(r2^2 - 2*r2*r4 + 2*r4^2)^2)
   @printf("小円の径が 27 寸,乙円の径が 9 寸のとき,甲円の直径は %.10g 寸\n", 2r3)
   @printf("r1 = %g;  r3 = %g;  x3 = %g;  x4 = %g;  y4 = %g;  x0 = %g;  y0 = %g\n", r1, r3, x3, x4, y4, x0, y0)
   plot()
   circle(r1, 0, r1, :black, beginangle=0, endangle=180)
   circle(0, r2, r2, :blue, beginangle=270, endangle=450)
   circle(x3, r3, r3)
   circle(x4, y4, r4, :orange)
   if more == true
       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)
       segment(0, 2r2, 2r1, 0, :gray)
       segment(0, r2, r1, 0, :green)
       point(r1, 0, "大円:r1 ", :black, :right, :bottom)
       point(x3, r3, "甲円:r3\n(x3,r3)\n", :red, :center, :top, delta=-delta/2)
       point(x4, y4, "乙円:r4=$r4\n(x4,y4)", :orange, :center, :bottom, delta=delta/2)
       point(0, r2, " 小円\n r2=$r2", :blue, :left, :bottom)
       point(x0, y0, "(x0,y0)\n", :black, :left, :bottom)
   end
end;

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

算額(その373)

2023年08月07日 | Julia

算額(その373)

山形県山形市旅籠町 湯殿山神社
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

直角三角形の 2 つの辺それぞれを直径とする大半円と中半円があり,2 つの等円が入っている。大半円の直径が与えられたとき,中半円の直径を求めよ。

大半円の半径と中心座標を r1, (r1, 0)
中半円の半径と中心座標を r2, (0, r2)
等円の半径と中心座標を r3, (r3, y31) および (x3, y32)
大半円と中半円の交点座標を (x0, y0)
とする。

以下の連立方程式を nlsolve() で解き,数値解を求める。

include("julia-source.txt");

using SymPy

@syms r1::positive, r2::positive, r3::positive, y31::positive,
     x3::positive, y32::positive, x0::positive, y0::positive;

eq1 = (r1 - r3)^2 + y31^2 - (r1 + r3)^2
eq2 = (r1 - x3)^2 + y32^2 - (r1 - r3)^2
eq3 = x3^2 + (r2 - y32)^2 - (r2 - r3)^2
eq4 = sqrt(x0^2 + y0^2) * sqrt(4r1^2 + 4r2^2) - 2r1*2r2
eq5 = (x0^2 + y0^2)/((2r1 - x0)^2 + y0^2) - r2^2/r1^2
eq6 = y0/(2r1 - x0) - r2/r1
eq7 = distance(0, 2r2, 2r1, 0, r3, y31) - r3^2;
# res = solve([eq1, eq2, eq3, eq4, eq5, eq6, eq7])

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)
   (r2, r3, x3, y31, y32, x0, y0) = u
   return [
       y31^2 + (r1 - r3)^2 - (r1 + r3)^2,  # eq1
       y32^2 - (r1 - r3)^2 + (r1 - x3)^2,  # eq2
       x3^2 - (r2 - r3)^2 + (r2 - y32)^2,  # eq3
       -4*r1*r2 + sqrt(4*r1^2 + 4*r2^2)*sqrt(x0^2 + y0^2),  # eq4
       (x0^2 + y0^2)/(y0^2 + (2*r1 - x0)^2) - r2^2/r1^2,  # eq5
       y0/(2*r1 - x0) - r2/r1,  # eq6
       -r3^2 + (-r1*(r1*r3 + 2*r2^2 - r2*y31)/(r1^2 + r2^2) + r3)^2 + (-r2*(2*r1^2 - r1*r3 + r2*y31)/(r1^2 + r2^2) + y31)^2,  # eq7
   ]
end;

r1 = 10
iniv = [big"0.735", 0.245, 0.430, 0.990, 0.495, 0.700, 0.955] .* r1
res = nls(H, ini=iniv);
println(res);
   (BigFloat[7.364773268277131843543802900503553345300188559250709059836081841354806617265332, 2.445735829117338727593748564700272182455934087389288548663153970404609644379193, 4.27028686542385572015136287764767660467637682250915731571476513356507761504113, 9.890876258688789657450970376693568285214500451690718312230118896022365345155555, 4.923138689794054227478994166323836685186339000292746456092958149436942045604101, 7.033185377446014888320211825529028530741347528474622758676476217579965993488618, 9.549764970689061667860842518627745663621779873444347024592820593189972532890017], true)

大円の半径が 10 のとき,中円の半径は 7.36477 あまりである。

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   (r2, r3, x3, y31, y32, x0, y0)  = res[1]
   @printf("r2 = %g;  r3 = %g;  x3 = %g;  y31 = %g;  y32 = %g;  x0 = %g;  y0 = %g\n",  r2, r3, x3, y31, y32, x0, y0)
   plot()
   circle(r1, 0, r1, beginangle=0, endangle=180)
   circle(0, r2, r2, :blue, beginangle=-90, endangle=90)
   circle(x3, y32, r3, :green)
   circle(r3, y31, r3, :green)
   segment(0, 2r2, 2r1, 0, :black)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(r1, 0, " r1", :red, :left, :bottom, delta=delta/2)
       point(0, r2, " r2", :blue, :left, :vcenter)
       point(r3, y31, "(r3,y31)", :green, :center, delta=-delta/2)
       point(x3, y32, "(x3,y32)", :green, :center, delta=-delta/2)
       point(x0, y0, "  (x0,y0)", :green, :left, :vcenter, delta=-delta/2)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

算額(その372)

2023年08月07日 | Julia

算額(その372)

山形県山形市旅籠町 湯殿山神社
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

円を折って弓形を作り,弓形の中に大円と小円4個を入れる。大円の直径が与えられたとき,小円の直径を求めよ。



外円の半径と中心座標を r0, (0, 2r1 - r0)
大円の半径と中心座標を r1, (0, r1)
等円の半径と中心座標を r2, (x21, r2) および (x22, y22)
として,以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

@syms r0::positive, r1::positive, r2::positive, x21::positive,
     x22::positive, y22::positive;

eq1 = x21^2 + (r1 - r2)^2 - (r1 + r2)^2
eq2 = x22^2 + (r1 - y22)^2 - (r1 + r2)^2
eq3 = x22^2 + (2r1 - r0 - r2)^2 - (r0 -r2)^2
eq4 = x21^2 + (r2 - r0 + 2r1)^2 - (r0 - r2)^2
eq5 = x22^2 + (y22 - r0 + 2r1)^2 - (r0 + r2)^2
res = solve([eq1, eq2, eq3, eq4, eq5], (r0, r2, x21, x22, y22))

   2-element Vector{NTuple{5, Sym}}:
    (3*r1/2, r1/4, r1, sqrt(6)*r1/2, 3*r1/4)
    (r1*(9 - sqrt(33))/2, r1*(7 - sqrt(33))/4, r1*sqrt(7 - sqrt(33)), r1*sqrt(-27 + 5*sqrt(33)), r1*(-13/4 + 3*sqrt(33)/4))

1 組目のものが適解である。

大円の半径 r1 と 等円の半径 r2 の比は r2/r1 = 1/4。したがって,大円の直径の 1/4 が等円の直径である

res[1][2] / r1 |> println

   1/4

r1 = 1 としたとき,以下のようになる。
r0 = 1.5;  r1 = 1;  r2 = 0.25; , x21 = 1; , x22 = 1.22474; , y22 = 0.75

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 1
   (r0, r2, x21, x22, y22) = (3*r1/2, r1/4, r1, sqrt(6)*r1/2, 3*r1/4)
   @printf("r0 = %g;  r1 = %g;  r2 = %g; , x21 = %g; , x22 = %g; , y22 = %g\n", r0, r1, r2, x21, x22, y22)
   x0 = sqrt(r0^2 - (2r1 - r0)^2)
   θ = round(Int64, atand(2r1 - r0, x0))
   plot()
   circle(0, r1, r1)
   #circle(0, 2r1 - r0, r0, :blue, beginangle=330, endangle=570)
   circle(0, 2r1 - r0, r0, :blue, beginangle=-θ, endangle=180 + θ)
   circle(0, 2r1 - r0, r0, :gray85, beginangle=180 + θ, endangle=360 - θ)
   circle(0, r0 - 2r1, r0, :blue, beginangle=θ, endangle=180 - θ)
   circle(0, r0 - 2r1, r0, :gray85, beginangle=180 - θ, endangle=360 + θ)
   circle(x21, r2, r2, :green)
   circle(-x21, r2, r2, :green)
   circle(x22, y22, r2, :green)
   circle(-x22, y22, r2, :green)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, 2r1, " 2r1", :red, :left, :bottom)
       point(0, r1, " r1", :red)
       point(0, -r1, " -r1", :gray)
       point(0, 2r1 - r0, " 2r1-r0", :blue)
       point(0, r0 - 2r1, " r0-2r1", :gray)
       point(x21, r2, "(x21,r2)", :green, :center, delta=-delta/3)
       point(x22, y22, "(x22,y22)", :green, :center, delta=-delta/3)
       point(x0, 0, "  x0", :blue, :left, :bottom)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

 

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

算額(その371)

2023年08月07日 | Julia

算額(その371)

山形県山形市旅籠町 湯殿山神社
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

外円の中に 3 個の円弧を描き,等円 3 個を入れる。外円の直径が与えられたとき,等円の直径を求めよ。

外円の半径と中心座標を R, (0, 0)
上の等円の半径と中心座標を r, (0, R - r)
右下の等円の半径と中心座標を r, (√3(R-r)/2, (r-R)/2)
右下の円弧の半径と中心座標を R, (√3R/2, -R/2)
とする。

以下の連立方程式を解く。
eq1 と eq2 はr2 を含まないので先に解く。得られた解に基づいて eq2 を解く。

include("julia-source.txt");

using SymPy

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

l = sqrt(a^2 + 4r1^2)
eq1 = r3/(a - (2r1 + r3)) - 2r1/l
eq2 = r1/(a - r1) - 2r1/l
eq3 = distance(0, 2r1, a, 0, 2r1 - r2, 2r1 - r2) - r2^2
res = solve([eq1, eq2], (r3, a))

   1-element Vector{Tuple{Sym, Sym}}:
    (r1/4, 8*r1/3)

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

(r3, a) = (r1/4, 8*r1/3)
eq3 = distance(0, 2r1, a, 0, 2r1 - r2, 2r1 - r2) - r2^2
res = solve([eq3], (r2))

   2-element Vector{Tuple{Sym}}:
    (r1/2,)
    (3*r1,)

r2 = r1/2 が適解である。

r2 = r1/2
r3 = r1/4
r3/r2 |> println

   1/2

乙円の半径は甲円の半径の 1/2,丙円の半径は乙円の半径の 1/2

 r1 = 1;  r2 = 0.5;  r3 = 0.25;  a = 2.66667

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   r1 = 1
   (r3, a) = (r1/4, 8*r1/3)
   r2 = r1/2
   @printf("r1 = %g;  r2 = %g;  r3 = %g;  a = %g\n", r1, r2, r3, a)
   plot([a, 0, -a, 0, a], [0, 2r1, 0, -2r1, 0], color=:black, lw=0.5)
   plot!([2r1, 2r1, -2r1, -2r1, 2r1], [-2r1, 2r1, 2r1, -2r1, -2r1], color=:green, lw=0.5)
   circle(r1, 0, r1, :blue)
   circle(-r1, 0, r1, :blue)
   circle(2r1 + r3, 0, r3)
   circle(-2r1 - r3, 0, r3)
   circle4(2r1 - r2, 2r1 - r2, r2, :magenta)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, 2r1, " 2r1", :green, :left, :bottom)
       point(r1, 0, "r1", :blue)
       point(2r1 + r3, 0, "2r1+r3", :red, :center)
       point(a, 0, "a", :black, :center)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

算額(その370)

2023年08月07日 | Julia

算額(その370)

一〇一 大宮市高鼻町 氷川神社 明治31年(1898)
埼玉県立図書館:埼玉県史料集 第二集『埼玉の算額』,昭和44年,誠美堂印刷所,埼玉県与野市.

山形県山形市旅籠町 湯殿山神社
山形算額勝負-湯殿山神社を目指せ-

https://www.sci.yamagata-u.ac.jp/wasan/pdf/20180711SSEP.pdf

外円の中に 3 個の円弧を描き,等円 3 個を入れる。外円の直径が与えられたとき,等円の直径を求めよ。

外円の半径と中心座標を R, (0, 0)
上の等円の半径と中心座標を r, (0, R - r)
右下の等円の半径と中心座標を r, (√3(R-r)/2, (r-R)/2)
右下の円弧の半径と中心座標を R, (√3R/2, -R/2)
とする。

以下の連立方程式を解く。

include("julia-source.txt");

using SymPy

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

eq = (sqrt(Sym(3))R/2)^2 + (R-r + R//2)^2 - (R + r)^2
res = solve([eq], (r))

   Dict{Any, Any} with 1 entry:
     r => 2*R/5

等円の半径は外円の半径の 2/5 である。

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   R = 1
   r = (2/5)R
   @printf("R = %g;  r = %g\n", R, r)
   plot()
   circle(0, 0, R, :black)
   rotate(0, R - r, r)
   rotate(0, R, R, :blue, beginangle=210, endangle=330)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(0, R, " R", :red, :left, :bottom)
       point(0, R - r, " R-r", :red, :left, :vcenter)
       point(√3R/2, -R/2, "(√3R/2,-R/2)  ", :blue, :center, :bottom, delta=delta/1.5)
       point(√3(R-r)/2, (r-R)/2, "(√3(R-r)/2,(r-R)/2)", :red, :center, :bottom, delta=delta/1.5)
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

 

 

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

算額(その369)

2023年08月07日 | Julia

算額(その369)

番外編 2023 鳥取大学工学部等前期日程数学
https://blog.goo.ne.jp/mh0920-yh/e/8075ae29b935640983c8fcc18a38a222

⊿ABC において,∠A = 60°,AB = 8,AC = 6 とする。⊿ABC の垂心を H とするとき,ベクトルAH をベクトルAB,ベクトルAC を用いて表わせ。

include("julia-source.txt");

using SymPy

@syms xa::positive, ya::positive,
     xb::positive, yb::positive,
     xc::positive, yc::positive,
     xh::positive, yh::positive,
     x::positive, y::positive;

図のように記号を定める。
頂点 A, B, C の座標をそれぞれ (xa, ya), (xb, yb), (xc, yc) とする。
頂点 B を原点に,頂点C が x 軸上に来るように三角形を置く。すなわち,xb = yb = yc = 0 とする。
xa, ya, xc を決める。

xb = yb = yc = 0
eq1 = (xa - xb)^2 + ya^2 - 8^2  # ピタゴラスの定理
eq2 = (xc - xa)^2 + ya^2 - 6^2  # ピタゴラスの定理
eq3 = ((8^2 + 6^2 - (xc - xb)^2))/(2*8*6) - cos(PI/3)  # 第2余弦定理
res1 = solve([eq1, eq2, eq3], (xa, ya, xc))
(xa, ya, xc) = res1[1]

   (20*sqrt(13)/13, 12*sqrt(39)/13, 2*sqrt(13))

(xa, ya, xc) = (20*sqrt(13)/13, 12*sqrt(39)/13, 2*sqrt(13)) である。

次に,BH⊥AC,CH⊥AB であることから,垂心 H の座標 (xh, yh) を求める。

eq1 = y/(x - xb) * ya/(xc - xa) - 1
eq2 = y/(xc - x) * ya/(xa - xb) - 1
res2 = solve([eq1, eq2], (x, y))

   Dict{Any, Any} with 2 entries:
     y => 10*sqrt(39)/39
     x => 20*sqrt(13)/13

(x, y) = (20*sqrt(13)/13, 10*sqrt(39)/39) である。

次に,ベクトルAB の a 倍とベクトルAC の b 倍の和がベクトルAH になるので,以下の方程式が成り立つ。

@syms a, b
(x, y) = (res2[x], res2[y])
(xh, yh) = ((xa, ya) .- (xb, 0)).*a .+ ((xa, ya) .- (xc, 0)).*b .- ((xa, ya) .- (x, y))

   (20*sqrt(13)*a/13 - 6*sqrt(13)*b/13, 12*sqrt(39)*a/13 + 12*sqrt(39)*b/13 - 2*sqrt(39)/3)

連立方程式を解き,a, b を求める。

solve([xh, yh], (a, b))

   Dict{Any, Any} with 2 entries:
     b => 5/9
     a => 1/6

a = 1/6, b = 5/9 である。

   xa = 5.547;  ya = 5.76461;  xc = 7.2111;
   AB = 8;  BC = 6;  AC = 7.2111
   xh = 5.547;  yh = 1.60128
   a = 0.166667, b = 0.555556

using Plots

function draw(more)
    pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
   xb = yb = yc = 0
   (xa, ya, xc) = (20*sqrt(13)/13, 12*sqrt(39)/13, 2*sqrt(13))
   (xh, yh) = (20*sqrt(13)/13, 10*sqrt(39)/39)
   (a, b) = (1/6, 5/9)
   @printf("xa = %g;  ya = %g;  xc = %g;\n", xa, ya, xc)
   @printf("AB = %g;  BC = %g;  AC = %g\n", sqrt((xa - xb)^2 + ya^2), sqrt((xc - xa)^2 + ya^2), xc - xb)
   @printf("xh = %g;  yh = %g\n", xh, yh)
   @printf("a = %g, b = %g\n", a, b)
   plot([0, xc, xa, 0], [0, 0, ya, 0], color=:black, lw=0.5)
   #segment(xa - (xa - xb)*a, ya - ya*a, xh, yh)
   plot!([xa, xa - (xa - xb)*a], [ya, ya - ya*a], arrow=0.6, color=:red, lw=0.5)
   plot!([xa - (xa - xb)*a, xh], [ya - ya*a, yh], arrow=0.6, color=:blue, lw=0.5)
   plot!([xa - (xa - xc)*b, xh], [ya - ya*b, yh], arrow=0.5, color=:red, lw=0.5)
   plot!([xa, xa - (xa - xc)*b], [ya, ya - ya*b], arrow=0.5, color=:blue, lw=0.5)
   plot!([xa, xh], [ya, yh], arrow=0.6, color=:green, lw=0.5)
   if more
       delta = (fontheight = (ylims()[2]- ylims()[1]) / 500 * 10 * 2) /3  # size[2] * fontsize * 2
       point(xa, ya, " A")
       point(0, 0, "  B", :green, :left, :bottom)
       point(xc, 0, " C", :green, :left, :bottom)
       point(x, y, " H")
       point(xa - (xa - xb)*a, ya - ya*a, " a*AB")
       point(xa - (xa - xc)*b, ya - ya*b, " b*AC")
       hline!([0], color=:black, lw=0.5)
       vline!([0], color=:black, lw=0.5)
   else
       plot!(showaxis=false)
   end
end;

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

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

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