clc;
clear;
close all;
x = linspace(0,2,1000);
f = 3*x.^2 + 2*x;
I_trapz = trapz(x,f);
I_quad = quad(@(x) 3*x.^2 + 2*x,0,2);
fprintf('Integralis ar trapz: %.6f\n',I_trapz);
fprintf('Integralis ar quad: %.6f\n',I_quad);
fprintf('Analitiskais: 12\n');
figure;
area(x,f);
grid on;
xlabel('x');
ylabel('f(x)');
title('Laukums zem funkcijas f(x) = 3x^2 + 2x');
To embed this project on your website, copy the following code and paste it into your website's HTML: