# Demo entry 6762313

Tên của bạn

Submitted by ф on Oct 11, 2018 at 17:11
Language: Matlab. Code size: 2.6 kB.

```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
90
91
92
93
94
95
96
97
98
99
100
101
102	x=-1;
f1=func(x);
h=zeros(50,1);
B=(1:50)';
ho=1;
for i=1:50
h(i)=ho;
ho=ho/2;
end
%производные
dy1=double(-2000*(2*x-8)/(x^2-8*x+92)^2);
dy2=double(-4000*(x^2-8*x+92)+4000*(2*x-8)^2)/(x^2-8*x+92)^3;
fprintf('               df = %6f15 and ddf=%6f15\n',dy1,dy2)
% 5 формул
F11=(func(x+h)-func(x))./h;
F12=(func(x+h)-func(x-h))./(2*h);
F14=(-func(x+2*h)+8*func(x+h)-8*func(x-h)+func(x-2*h))./(12*h);
F22=(func(x+h)-2*func(x)+func(x-h))./(h.^2);
F24=(-func(x+2*h)+16*func(x+h)-30*func(x)+16*func(x-h)-func(x-2*h))./(12*h.^2);
%точности
O11=(abs(F11-dy1));
O12=abs(F12-dy1);
O14=abs(F14-dy1);
O22=abs(F22-dy2);
O24=abs(F24-dy2);
% графики

plot(1:50,O11)
semilogy((1:50),O11)
xlabel('Step');
ylabel('Log(accuracy)');
grid on;
title('O11');

figure;
plot(1:50,O12)
semilogy((1:50),O12)
xlabel('Step');
ylabel('Log(accuracy)');
grid on;
title('O12');

figure;
plot(1:50,O14)
semilogy((1:50),O14)
xlabel('Step');
ylabel('Log(accuracy)');
grid on;
title('O14');

figure;
plot(1:50,O22)
semilogy((1:50),O22)
xlabel('Step');
ylabel('Log(accuracy)');
grid on;
title('O22');

figure;
plot(1:50,O24)
semilogy((1:50),O24)
xlabel('Step');
ylabel('Log(accuracy)');
grid on;
title('O24');

% точность и шаги
for j=1:50
if O11(j,1)==min(O11)
step=j;
fprintf('            Min_o11 = %d when step is %d\n',min(O11),step)
end
if O12(j,1)==min(O12)
step=j;
fprintf('            Min_O12 = %d when step is %d\n',min(O12),step)
end
if O14(j,1)==min(O14)
step=j;
fprintf('            Min_O14 = %d when step is %d\n',min(O14),step)
end
if O22(j,1)==min(O22)
step=j;
fprintf('            Min_O22 = %d when step is %d\n',min(O22),step)
end
if O24(j,1)==min(O24)
step=j;
fprintf('            Min_O24 = %d when step is %d\n',min(O24),step)
end
end
%таблица
disp('                     --------------------***------------------------')
disp('          step       O11         O12         O14           O22          O24')
XX=[B O11 O12 O14 O22 O24];
disp(XX);
```

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.