algebra/phi-function: fix and improve