function int_zad1
a = 0;
b = 3;
I_a1 = af1(b) - af1(a);
I_a2 = af2(b) - af2(a);
I_a3 = af3(b) - af3(a);
I_a4 = af4(b) - af4(a);
It = trapezoidal(@f3, a, b)
error_t = abs(It - I_a3)
Ir = rectangular(@f3, a, b)
error_r = abs(Ir - I_a3)
Is = Simpson(@f3, a, b)
error_s = abs(Is - I_a3)
Is2 = Simpson2(@f3, a, b)
error_s2 = abs(Is2 - I_a3)
end
function y = f1(x)
y=x^2;
end
function y = f2(x)
y= sin(x);
end
function y = f3(x)
y=1/(1+25*x^2);
end
function y = f4(x)
y= 1/(1+cos(x));
end
function y = af1(x)
y=(1/3)*x^3;
end
function y = af2(x)
y = -cos(x);
end
function y = af3(x)
y=(1/5)*atan(5*x);
end
function y = af4(x)
y=tan(x/2);
end
function I = rectangular(f, a, b) %kwadratura lewego prostokata
I= f(a)*(a-b);
end
function I = trapezoidal(f, a, b)
I=((b-a)/2)*(f(a)+f(b));
end
function I = Simpson(f, a, b)
I=((b-a)/6)*(f(a)+4*f(a +(b-a)/2)+f(b));
end
function I = Simpson2(f, a, b)
I=((b-a)/8)*(f(a)+3*f(a +(b-a)/3)+ 3*f(a+2*(a-b)/3)+f(b));
end
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}