Algandmed

f[x_] := Sin[x]; 
n = 10; 
a = 0; 
b = (π/2); 
h = ((b - a)/n);

Ristkülikvalem

N[h Sum[f[xi + (h/2)], {xi, a, b - h, h}]]

Graafiline interpretatsioon

jaotused = 
      N[Table[{{xi, 0}, {xi, f[xi + (h/2)]}, {xi + h, f[xi + (h/2)]}, {xi + h, 
              0}, {xi, 0}}, {xi, a, b - h, h}]]; 
Plot[f[x], {x, a, b}, 
      Prolog -> {Thickness[0.001], Hue[0.5], Polygon /@ jaotused, 
          GrayLevel[0], Line /@ jaotused}, 
      AspectRatio -> Automatic];

Ristkülikvalem vasakpoolsete ristkülikutega

N[h Sum[f[xi], {xi, a, b - h, h}]]

Graafiline interpretatsioon

jaotused = 
      N[Table[{{xi, 0}, {xi, f[xi]}, {xi + h, f[xi]}, {xi + h, 0}, {xi, 
              0}}, {xi, a, b - h, h}]]; 
Plot[f[x], {x, a, b}, 
      Prolog -> {Thickness[0.001], Hue[0.5], Polygon /@ jaotused, 
          GrayLevel[0], Line /@ jaotused}, 
      AspectRatio -> Automatic];

Ristkülikvalem parempoolsete ristkülikutega

N[h Sum[f[xi + h], {xi, a, b - h, h}]]

Graafiline interpretatsioon

jaotused = 
      N[Table[{{xi, 0}, {xi, f[xi + h]}, {xi + h, f[xi + h]}, {xi + h, 
              0}, {xi, 0}}, {xi, a, b - h, h}]]; 
Plot[f[x], {x, a, b}, 
      Prolog -> {Thickness[0.001], Hue[0.5], Polygon /@ jaotused, 
          GrayLevel[0], Line /@ jaotused}, 
      AspectRatio -> Automatic];

Trapetsvalem

N[(1/2) h Sum[f[xi] + f[xi + h], {xi, a, b - h, h}]]

Graafiliselt:

jaotused = 
      N[Table[{{xi, 0}, {xi, f[xi]}, {xi + h, f[xi + h]}, {xi + h, 0}, {xi, 
              0}}, {xi, a, b - h, h}]]; 
Plot[f[x], {x, a, b}, 
      Prolog -> {Thickness[0.001], Hue[0.5], Polygon /@ jaotused, 
          GrayLevel[0], Line /@ jaotused}, 
      AspectRatio -> Automatic];

Simpsoni valem

N[(1/6) h Sum[
          f[xi] + 4 f[xi + (h/2)] + f[xi + h], {xi, a, b - h, h}]]

Graafiliselt:

jaotused = 
      N[Table[poly = 
            InterpolatingPolynomial[{{xi, f[xi]}, {xi + (h/2), 
                  f[xi + (h/2)]}, {xi + h, f[xi + h]}}, x]; {{xi, 0}, {xi, 
              f[xi]}, Sequence @@ 
              Table[{xj, poly /. x -> xj}, {xj, xi, 
                  xi + h, (h/4)}], {xi + h, f[xi + h]}, {xi + h, 0}, {xi, 
              0}}, {xi, a, b - h, h}]]; 
Plot[f[x], {x, a, b}, 
      Prolog -> {Thickness[0.001], Hue[0.5], Polygon /@ jaotused, 
          GrayLevel[0], Line /@ jaotused}, 
      AspectRatio -> Automatic];

Weddly valem

N[((3 h Sum[f[xi] + 5 f[xi + (h/6)] + f[xi + ((2 h)/6)] + 6 f[xi + ((3 h)/6)] + f[xi + ((4 h)/6)] + 5 f[xi + ((5 h)/6)] + 1 f[xi + h], {xi, a, b - h, h}])/(6 10))]

Bode valem

N[((2 h Sum[7 f[xi] + 32 f[xi + (h/4)] + 12 f[xi + ((2 h)/4)] + 32 f[xi + ((3 h)/4)] + 7 f[xi + h], {xi, a, b - h, h}])/(45 4)), 
      10]

Simpsoni kubatuurvalem

F[x_, y_] := ((y^2)/(3 (x + 2)));
a = 0;
b = 3;
c = -2;
d = 2;
n = 3;
m = 4;
h = ((b - a)/n);
k = ((d - c)/m);

N[Sum[x0 = xi; y0 = yi; x1 = xi + (h/2); y1 = yi + (h/2); x2 = xi + h; 
        y2 = yi + 
            h; ((h k (F[x0, y0] + F[x2, y0] + F[x0, y2] + F[x2, y2] + 4 (F[x1, y0] + F[x0, y1] + F[x2, y1] + F[x1, y2]) + 16 F[x1, y1]))/(9 4)), {xi, a, b - h, h}, {yi, c, d - k, k}]]

NIntegrate[F[x, y], {x, a, b}, {y, c, d}]

Monte Carlo meetod

f[x_] := (x^2);
a = 0;
b = 1;
n = 1000;

SeedRandom[];
punktid = 
        Table[{Random[Real, {a, b}], 
            Random[Real, {0, f[b]}]}, {n}];
m = 
        Count[punktid /. {x_, y_} -> y < f[x], 
          True];
N[(m/n)]

Graafiline interpretatsioon

Plot[f[x], {x, -0.1, 1.1}, AspectRatio -> Automatic, 
        Epilog -> {AbsolutePointSize[3], 
            Point /@ punktid}];

NIntegrate[f[x], {x, a, b}]