← Back
Editing: utils.cpython-311.pyc
� d�cw � �T � d dl Zn# e$ r Y nw xY w d dlmZ n# e$ r Y nw xY wd� ZdS )� N��xc �N � � t � � � }t � fd�t |� � D � � � � }t |z � t d|� � � � � }|dz g}t |� � D ]2}|� |d |z � � � � � �3t j d� � g}t d|� � D ]<}|� || � t |dz � � |z � � �=d� |D � � }|S )a� Given a series f(x) = a[1]*x + a[2]*x**2 + ... + a[n-1]*x**(n - 1), use the Lagrange inversion formula to compute a series g(x) = b[1]*x + b[2]*x**2 + ... + b[n-1]*x**(n - 1) so that f(g(x)) = g(f(x)) = x mod x**n. We must have a[0] = 0, so necessarily b[0] = 0 too. The algorithm is naive and could be improved, but speed isn't an issue here and it's easy to read. c 3 �>