clc; clear; close all;

reps = 1;

% point and time to evaluate the analytical solution
x = 0; y = 0; t = 270;

% the first two implementations use built-in function "trapz"
% utilizing Matkab ability to evaluate functions for matrix inputs
% faster than the second implementation, but requires more memory
tic;
for i = 1:reps
    p_matrix = real(1i * ExactSolution_trapz_matrix(x,y,t));
end
toc;

% a little bit slower, but because we evaluate the function only
% in a vector, we save memory a can perform finer integration
tic;
for i = 1:reps
    p_vector = real(1i * ExactSolution_trapz_vector(x,y,t));
end
toc;

% uses Matlab inline (anonymous) functions and is by far the fastest
% uses built-in function "integral2"
% already inlcudes real(1i * p) in the function itself
tic;
for i = 1:reps
    p = ExactSolution(x,y,t);
end
toc;

% display, if the results differ
% taking smaller AbsTol and RelTol for integral2 doesn't improve the result
format long
p_matrix
p_vector
p
format short