Skip to content

Big Functions

SimpleArt edited this page Nov 11, 2020 · 3 revisions

It may be necessary for some usage to define mathematical operations, such as exponentiation, over intervals beyond their usual domain. This is especially the case when one desires evaluations at infinity or near singularities. We define several such functions below.

bigexp

def bigexp(x):
    if x < -math.log(solver.realmax): return 0.0
    elif x > math.log(solver.realmax): return inf
    else: return exp(x)

bigpow

def bigpow(x, y):
    if y < 0:
        res = bigpow(x, -y)
        if res == 0: return inf
        else: return 1/res
    elif y < 1 or abs(x) < solver.realmax**(1/y):
        return x**y
    else:
        return (inf*solver.sign(x))**y

Note the conventions chosen here are 1/0.0 == inf and (-inf)**y == inf if y is a positive non-integer.

biglog

def biglog(x, b = math.e):
    if b <= 0 or b == 1:
        return nan
    elif b == inf:
        if x == inf: return nan
        else: return 0.0
    elif b != math.e:
        return biglog(x)/biglog(b)
    elif x == 0:
        return -inf
    else:
        return math.log(x)

Clone this wiki locally