The Matlab code can be used to create a point symmetric function with respect to a given point of symmetry.
It also shows the principle that:
The linear average of a point symmetric function is equal to its DC offset.
If a function f(x) is point symmetric with respect to any point on the x-axis, its linear average (as well as its integral from -infinity to +infinity) is zero.
Let’s see the code:
Point = [2; 3]; % Point of Symmetry
HowManyPoints = 10; % Number of points for left and right part
Left_X = Point(1)-HowManyPoints:Point(1)-1; % default unit step
Left_Y = randi(100,1,HowManyPoints); % random Y values
Left = [Left_X;Left_Y];
Right = 2*Point-Left; % Point reflection formula
AllPoints =[Left, Right]; % Joining left and right parts
% Sorting AllPoints according to X direction for the plot function
[~, sortedX] = sort(AllPoints(1,:));
AllPoints = AllPoints(:,sortedX);
% Extract X and Y components
X = AllPoints(1,1:end);
Y = AllPoints(2,1:end);
area(X,Y, 'FaceColor', 'blue'); % show area under the curve
scatter(Point(1),Point(2),'filled','black'); % show point of symmetry
TOTAL_AREA = trapz(X, Y);
PERIOD = 2*HowManyPoints;
DC_OFFSET = Point(2);
t = annotation('textarrow','String',sprintf('AREA=%d\nPERIOD=%d\nOFFSET=%d\n',TOTAL_AREA, PERIOD, DC_OFFSET));
t.HorizontalAlignment = 'Left';
text(Point(1)+1,Point(2)+1, 'Point of symmetry');
As expected, the area under the curve (considering it negative when the function is negative) corresponds to the area below the linear average line (equal to the offset * period).