lab8B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Program Lab8_B2;
var x, eps, korin, a, b, d: real;
function f(x: real): real;
begin
f := x - 0.785 * sqrt(1 - x * x);
end;
function fp(x: real): real;
begin
fp:= (f(x) + eps) - f(x) / eps;
end;
function fpp(x: real): real;
begin
fpp := (fp(x) / (x + eps)) - f(x) / eps;
end;
procedure nuton(x, eps: real; var korin: real);
begin
var n, i: integer;
n := 1000;
i := 1;
while abs(f(x)) > eps do
begin
x:= x - F(x) / fp(x);
if i >= n then begin
writeln('koreniv ne znaydeno');
korin:= 0; halt;
i:= i + 1;
end;
korin:= x;
end;
end;
begin
//writeln('vvedit promijok'); read(a, b);
writeln('vvedit tochnist'); readln(eps);
a := 0.5;
b := 0.7;
if f(a) * fpp(b) > 0 then begin
x := a;
end
else x := b;
nuton(x, eps, korin);
writeln('korin = ', korin);
d := f(korin);2
end.