|
RANDOMIZE
DEF FNF(X, Y) = A * X + B * Y - E
DEF FNG(X, Y) = C * X + D * Y - F
LET A=INT(RND*10)+1
LET B=INT(RND*10)+1
LET C=INT(RND*10)+1
LET D=INT(RND*10)+1
LET E=INT(RND*10)-5
LET F=INT(RND*10)-5
PRINT A;"* X +";B;"* Y=";E
PRINT C;"* X +";D;"* Y=";F
LET XH = 100
LET XL = -XH
DO
LET XM = (XH + XL) / 2
LET YM = (F - C * XM) / D !' G(X,Y)=0 を Y=GG(X)の形に変形し、XMを代入
LET YH = (F - C * XH) / D !' G(X,Y)=0 を Y=GG(X)の形に変形し、XHを代入
IF FNF(XM, YM) * FNF(XH, YH) < 0 THEN LET XL = XM ELSE LET XH = XM
LOOP UNTIL ABS(FNF(XM, YM)) < 1E-8 AND ABS(FNG(XM, YM)) < 1E-8
PRINT "X,Y="; XM; YM
PRINT "X,Y=";(D*E-B*F)/(A*D-B*C);(A*F-C*E)/(A*D-B*C) !'検算
END
|
|