23/07/08 09:57:43.79 vZit7BjaH.net
# AB=20,BC=23,DA=78である□ABDAの面積が最大になるときのDAの長さを求めよ
# 答は有効数字2桁でよい。
AB=20
BC=23
CD=78
ABC2S=\(A,B,C) abs(Im((A-C)*Conj(B-C)))/2
f=\(b,c,print=FALSE){
A=0i
B=AB+0i
C=BC*exp(1i*b)+B
D=CD*exp(1i*(b+c))+C
S=ABC2S(A,B,C)+ABC2S(A,D,C)
DA=round(abs(D-A))
if(print){
Plot(0,1.5*max(c(AB,BC,CD)))
pta(A)
pta(B)
pta(C)
pta(D)
Polygon(A,B,C,D)
text(mean(Re(c(A,B,C,D))),mean(Im(c(A,B,C,D))),round(S,2))
text(mean(Re(c(D,A))),mean(Im(c(D,A))),DA)
}
invisible(S)
}
opt=optim(runif(2,0,pi),\(x) f(x[1],x[2]),control=list(fnscale=-1))
ans=optim(opt$par,\(x) f(x[1],x[2]),control=list(fnscale=-1))
f(ans$par[1],ans$par[2],print=TRUE)