%% Plot Digamma and Polygamma Functions
% Define the domain.

X = 0:0.05:5;

% Calculate the digamma and the next three polygamma functions.

Y = zeros(4,101);
for i = 0:3
    Y(i+1,:) = psi(i,X);
end

% Plot the digamma and the next three polygamma functions.

plot(X,Y)
axis([0 5 -10 10])
legend('\psi','\psi_1','\psi_2','\psi_3','Location','Best')
title('Digamma and The Next Three Polygamma Functions','interpreter','latex')
xlabel('$x$','interpreter','latex')
ylabel('$\psi_k(x)$','interpreter','latex')

%
% Copyright 2020 The MathWorks, Inc.