add special function psi and remove more copypasta from algorithms.py