Advertisement
Albinutte

matlab_simpson

Dec 24th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.43 KB | None | 0 0
  1. ns = 5 : 21;
  2. n = length(ns);
  3.  
  4. y_theory = zeros(n, 1);
  5. y_fact = zeros(n, 1);
  6. y_runge = zeros(n, 1);
  7. for i = 1 : n
  8.     y_theory(i) = 0.4 / 2880 * (0.4 / (ns(i) - 1))^4;
  9.     y_fact(i) = abs(Simpson(0, 0.4, ns(i)) + exp(-0.4) - 1);
  10.     y_runge(i) = abs(Simpson(0, 0.4, ns(i) * 2) - Simpson(0, 0.4, ns(i))) / (2^2 - 1);
  11. end;
  12.  
  13. semilogy(ns, y_theory, ns, y_fact, '--', ns, y_runge, '-.');
  14. legend('теор.', 'факт.', 'Рунге');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement