function [f1, f2, err] = exp_approx(x, N)
%% exp_approx: calculates an aproximation of exp(x)
% [f1, f2, err] = exp_approx(x,N)
% x ... function argument, N ... order of approximation
% f1 ... calculated value
% f2 ... "exact" value (given by built-in function)
% err ... relative error
% example: [fa, fp] = exp_approx(4, 30);
n = 0:N;
f = (x.^n)./factorial(n); % it is vectorized
f1 = sum(f); % approximative value
f2 = exp(x); % exact value
err = 100*abs(1 - f1/f2); % relative error (in [%])
end