(p, x, prec)
return p1
univariate series inversion ``1/p`` modulo ``O(x**prec)``

    The Newton method is used.

    Examples
    ========

    >>> from sympy.polys.domains import QQ
    >>> from sympy.polys.rings import ring
    >>> from sympy.polys.ring_series import _series_inversion1
    >>> R, x = ring('x', QQ)
    >>> p = x + 1
    >>> _series_inversion1(p, x, 4)
    -x**3 + x**2 - x + 1
univariate series inversion ``1/p`` modulo ``O(x**prec)``
univariate series inversion 1 / p modulo O ( x ** prec )
def _series_inversion1(p, x, prec):
    """
    univariate series inversion ``1/p`` modulo ``O(x**prec)``

    The Newton method is used.

    Examples
    ========

    >>> from sympy.polys.domains import QQ
    >>> from sympy.polys.rings import ring
    >>> from sympy.polys.ring_series import _series_inversion1
    >>> R, x = ring('x', QQ)
    >>> p = x + 1
    >>> _series_inversion1(p, x, 4)
    -x**3 + x**2 - x + 1

    """
    ring = p.ring
    zm = ring.zero_monom
    if zm not in p:
        raise ValueError('no constant term in series')
    if _has_constant_term(p - p[zm], x):
        raise ValueError('p cannot contain a constant term depending on parameters')
    if p[zm] != ring(1):
        # TODO add check that it is a unit
        p1 = ring(1)/p[zm]
    else:
        p1 = ring(1)
    for precx in _giant_steps(prec):
        tmp = p1.square()
        tmp = rs_mul(tmp, p, x, precx)
        p1 = 2*p1 - tmp
    return p1
def _series_inversion1 ( p , x , prec ) : ring = p . ring zm = ring . zero_monom if zm not in p : raise ValueError ( 'no constant term in series' ) if _has_constant_term ( p - p [ zm ] , x ) : raise ValueError ( 'p cannot contain a constant term depending on parameters' ) if p [ zm ] != ring ( 1 ) : # TODO add check that it is a unit p1 = ring ( 1 ) / p [ zm ] else : p1 = ring ( 1 ) for precx in _giant_steps ( prec ) : tmp = p1 . square ( ) tmp = rs_mul ( tmp , p , x , precx ) p1 = 2 * p1 - tmp return p1