% This function evaluates on the given points on [0,pi] a piecewise linear
% function "approximating" very roughly function g(x)=sin(2*x) on [0,pi]

function res = nonDiffSin2(points)

n = length(points);
res  = zeros(size(points));
ind1 = round(n/4);
ind2 = round(n/2);
ind3 = round(3/4*n);

res(1:ind1)       = (4/pi)*points(1:ind1);
res(ind1+1:ind2)  = -(4/pi)*points(ind1+1:ind2)+2;
res(ind2+1:ind3)  = -(4/pi)*points(ind2+1:ind3)+2;
res(ind3+1:end)   = (4/pi)*points(ind3+1:end)-4;

% figure
% plot(points,res)