def maclaurin_ln(value,k):
    """
    Compute maclaurin's series approximation for ln(1+x).
    """
    
    global first_value    
    first_value = 0.0
    
    #attempt to Approximate ln(1+x) for a given value
    try:
        
        error(value)
        for item in xrange(1,k,2):
            next_value =(value**item)/float(item)
            first_value += next_value
            
        for item in xrange(2,k,2):
            next_value = -1*(value**item)/float(item)
            first_value += next_value
            
        return first_value

    #Raise TypeError if input is not within
    #the interval of convergence
    except TypeError,exception:
        print exception

    Compute maclaurin's series approximation for ln(1+x).
    
recipes/Python/577290_Maclaurinsseriesln1x/recipe-577290.py