算額(その803)
藤田貞資:精要算法(下巻),天明元年(1781) http://www.wasan.jp/seiyou/seiyou.html
三辺(大斜,中斜,小斜)が 28 寸,25 寸,17 寸の不等辺三角形の内部の 1 点から 3 つの頂点を結ぶ線分を引き,できる三角形の面積が等しくなるようにするとき,大斜と小斜の交点から件の点までの距離(甲斜)を求めよ。
大斜と小斜の交点を原点とし,大斜,中斜,小斜の長さを L, M, S とおき,三角形内部の 1 点の座標を (x1, y1),中斜と小斜の交点を (x2, y2) として,以下の連立方程式を解く。
include("julia-source.txt");
# julia-source.txt ソース https://blog.goo.ne.jp/r-de-r/e/ad3a427b84bb416c4f5b73089ae813cf
using SymPy
@syms x1, y1, x2, y2, L, M, S, d
eq1 = x2^2 + y2^2 - S^2
eq2 = (L - x2)^2 + y2^2 - M^2
eq3 = S*sqrt(dist(0, 0, x2, y2, x1, y1)) - L*y1
eq3 = dist(0, 0, x2, y2, x1, y1) - (L*y1/S)^2
eq3 = numerator(apart(eq3, d))
eq4 = M*sqrt(dist(L, 0, x2, y2, x1, y1)) - L*y1
eq4 = dist(L, 0, x2, y2, x1, y1) - (L*y1/M)^2
eq4 = numerator(apart(eq4, d))
res = solve([eq1, eq2, eq3, eq4], (x1, y1, x2, y2));
res[2]
((3*L^2 - M^2 + S^2)/(6*L), sqrt(-L^4 + 2*L^2*M^2 + 2*L^2*S^2 - M^4 + 2*M^2*S^2 - S^4)/(6*L), (L^2 - M^2 + S^2)/(2*L), sqrt(-(L - M - S)*(L - M + S)*(L + M - S)*(L + M + S))/(2*L))
2 組の解が得られるが, 2 番目のものが適解である。
甲斜はピタゴラスの定理で計算する。
甲斜は,大斜の 2 乗の 2 倍と,小斜の 2 乗の 2 倍の和から中斜の 2 乗を引き,平方根を取ったものを 3 で割ることで得られる。
甲斜 = sqrt(res[2][1]^2 + res[2][2]^2) |> simplify
甲斜 |> println
sqrt(2*L^2 - M^2 + 2*S^2)/3
大斜,中斜,小斜が 28 寸,25 寸,17 寸のとき,甲斜は 13 寸である。
甲斜(L => 28, M => 25, S => 17).evalf() |> println
13.0000000000000
function draw(more)
pyplot(size=(500, 500), grid=false, aspectratio=1, label="", fontfamily="IPAMincho")
(L, M, S) = (28, 25, 17)
(x1, y1, x2, y2) = ((3*L^2 - M^2 + S^2)/(6*L), sqrt(-L^4 + 2*L^2*M^2 + 2*L^2*S^2 - M^4 + 2*M^2*S^2 - S^4)/(6*L), (L^2 - M^2 + S^2)/(2*L), sqrt(-(L - M - S)*(L - M + S)*(L + M - S)*(L + M + S))/(2*L))
plot([0, 28, x2, 0], [0, 0, y2, 0], color=:magenta, lw=0.5)
segment(0, 0, x1, y1, :red)
segment(28, 0, x1, y1, :blue)
segment(x2, y2, x1, y1, :blue)
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)
point(x1, y1, "(x1,y1)", :blue, :left, :bottom, delta=delta)
point(x2, y2, "(x2,y2)", :magenta, :left, :bottom, delta=delta)
point(L/2, 0, "大斜", :black, :center, :bottom, delta=delta, mark=false)
point((L + x2)/2, y2/2, "中斜", :black, :left, :bottom, delta=delta, mark=false)
point(x2/2, y2/2, "小斜", :black, :right, :bottom, delta=delta, mark=false)
point(x1/2, y1/2, "甲斜", :red, :right, :bottom, delta=delta, mark=false)
end
end;