Skip to content

Commit

Permalink
dovrebbe andare
Browse files Browse the repository at this point in the history
  • Loading branch information
lukefleed committed May 3, 2021
1 parent 8fee2d2 commit e218eb2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lezione-08/es3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function S = es3(f,a,b,N)
h = (b-a)/N;
somma1 = 0;
somma2 = 0;
fine = N/2 -1;
for i = 1:fine
somma1 += f(a + 2*i*h);
somma2 += f(a + (2*i -1)*h);
end
S = (h/3)*(f(a)+f(b) + 2*somma1 + 4*somma2);

9 changes: 9 additions & 0 deletions lezione-08/script3.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
f = @(x) exp(x);
N = 100:100:1000;
for i = 100:100:1000
Y(i/100) = abs((e-1)-es3(f,0,1,i));
end
ly = log(Y);
ln = log(N);
p= polyfit(ln,ly,1);
p(1)

0 comments on commit e218eb2

Please sign in to comment.