Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ns = 5 : 21;
- n = length(ns);
- y_theory = zeros(n, 1);
- y_fact = zeros(n, 1);
- y_runge = zeros(n, 1);
- for i = 1 : n
- error = 0;
- h = 0.4 / ns(i);
- for j = 1 : ns(i)
- error = error + h^3 * exp(-(h * (j - 1))) / 24;
- end;
- y_theory(i) = error;
- y_fact(i) = abs(Rectangle(0, 0.4, ns(i)) + exp(-0.4) - 1);
- y_runge(i) = (Rectangle(0, 0.4, idivide(ns(i), 2, 'floor')) - Rectangle(0, 0.4, ns(i))) / (2^2 - 1);
- end;
- semilogy(ns, y_theory, ns, y_fact, '--', ns, y_runge, '-.');
- legend ('теоретическая погрешность', 'фактичекая погрешность', 'Рунге');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement