"""
Title: HyperSage - a Sage library for tetration and hyper operations.
Creator: Andrew Robbins
Contributor: Jay D. Fox
Date: 2008-04-25
Description:

    hyper/parabolic.py 
    
"""

from sage.all import *

def is_hyperbolic(expr, x, x0):
    """
    is_hyperbolic(f(x), x, x0) -- is x0 a hyperbolic fixed point of f?
    """
    if expr.subs(x=x0) != x0:
        return False
    if diff(expr, x).subs(x=x0) == 1:
        return False
    return True

def hyperbolic_flow(expr, t, x, x0=0, n=5):
    """
    hyperbolic_flow(f(x), t, x)

    The power series (flow) for a hyperbolic function.
    Currently only implemented for a fixed point of 0.
    """
    # is it a hyperbolic function?
    if not is_hyperbolic(expr, x, x0):
        raise ValueError, "x0 == f(x0) must be a hyperbolic fixed point (f'(x0) != 1)"
    pass
