#
# PYTHON • MyCompiler
# Polygamma
# https://[Log in to view URL]
# Função Polygamma
#
# 2026 Maio Dom, 24 — Seg, 25
# by
# j
#
import matplotlib.pyplot as plt
import numpy as np
import math
def pyg(m,z):
max = 3000
psi = 0.00
for k in range(0,max+1):
if ( (z+k) != 0 ):
psi += 1/((z + k)**(m+1))
psi = ((-1)**(m+1))*math.factorial(m)*psi
return psi
def graf():
plt.style.use('dark_background')
x = []
y = []
xmin = -2
xmax = 4
n = 500
max = 3500
pico = 100
delta = (xmax - xmin)/n
for m in range(0,5):
z = xmin
x.clear()
y.clear()
while ( z <= xmax ):
psi = pyg(m,z)
# if ( ( abs( z - 1) < 0.01 ) and ( m == 3 ) ):
# print(z,psi)
if (abs(psi) < pico):
x.append(z)
y.append(psi)
z += delta
lbl = '$ ψ^' + str(m) + '$'
plt.plot(x,y,'.',label=lbl)
tit = 'Polygamma Function'
# plt.axis('equal')
plt.title(tit)
plt.legend()
# plt.xticks([])
# plt.yticks([])
plt.xlim([-2, 4])
plt.ylim([-pico, pico])
plt.grid(False)
plt.show()
graf()
To embed this project on your website, copy the following code and paste it into your website's HTML: