I am trying to check if there is any Matlab/Python procedure to underestimate f(x)=abs(log(x)) by using a piecewise linear function g(x). That is g(x) needs to be less or equal to, f(x). I found some similar procedures in this question.
How to fit a curve by a series of segmented lines in Matlab?. Using this method, I found a function, but it overestimates the function f(x). See the picture and code below. Could you please help to modify this code to find how to underestimate this function?
x = 0.000000001:0.001:1;
y = abs(log2(x));
%# Find section sizes, by using an inverse of the approximation of the derivative
numOfSections = 5;
indexes = round(linspace(1,numel(y),numOfSections));
derivativeApprox = diff(y(indexes));
inverseDerivative = 1./derivativeApprox;
weightOfSection = inverseDerivative/sum(inverseDerivative);
totalRange = max(x(:))-min(x(:));
sectionSize = weightOfSection.* totalRange;
%# The relevant nodes
xNodes = x(1) + [ 0 cumsum(sectionSize)];
yNodes = abs(log2(xNodes));
figure;plot(x,y);
hold on;
plot (xNodes,yNodes,'r');
scatter (xNodes,yNodes,'r');
legend('abs(log2(x))','adaptive linear interpolation');



