CLS
DEFDBL A-Z
'nizhe vvoditsja vasha funkcija
DEF fnx (x) = x ^ 3 - 3 * x ^ 2 + 9 * x - 8
INPUT "vvedite tochnost opredelenija kornja:"; e
PRINT "vvedite granicy promezhutka"
DO
INPUT "a"; a: INPUT "b"; b
IF (fnx(a) * fnx(b)) > 0 THEN PRINT "vashi dannye ne podhodjat dlja dannog metoda"
LOOP UNTIL (fnx(a) * fnx(b)) < 0
DO
x = (a + b) / 2
IF (fnx(a) * fnx(x)) > 0 THEN a = x ELSE b = x
d = ABS((b - a) / x)
n = n + 1
LOOP UNTIL d <= e OR n = 10 ^ 3
PRINT "otvet: x="; x
PRINT "f(x)="; fnx(x)
PRINT "kolichestvo provedennyh vychislenij:"; n
Тестирование выполнено в программе QB64 ( Скачать )