(eq, x)
return solns
Given an expression assumed to be in the form
        ``F(X, a..f) = a*log(b*X + c) + d*X + f = 0``
    where X = g(x) and x = g^-1(X), return the Lambert solution if possible:
        ``x = g^-1(-c/b + (a/d)*W(d/(a*b)*exp(c*d/a/b)*exp(-f/a)))``.
Given an expression assumed to be in the form
        ``F(X, a..f) = a*log(b*X + c) + d*X + f = 0``
    where X = g(x) and x = g^-1(X), return the Lambert solution if possible:
        ``x = g^-1(-c/b + (a/d)*W(d/(a*b)*exp(c*d/a/b)*exp(-f/a)))``.
Given an expression assumed to be in the form F ( X a .. f ) = a * log ( b * X + c ) + d * X + f = 0 where X = g ( x ) and x = g^ - 1 ( X ) return the Lambert solution if possible : x = g^ - 1 ( - c / b + ( a / d ) * W ( d / ( a * b ) * exp ( c * d / a / b ) * exp ( - f / a ))) .
def _lambert(eq, x):
    """
    Given an expression assumed to be in the form
        ``F(X, a..f) = a*log(b*X + c) + d*X + f = 0``
    where X = g(x) and x = g^-1(X), return the Lambert solution if possible:
        ``x = g^-1(-c/b + (a/d)*W(d/(a*b)*exp(c*d/a/b)*exp(-f/a)))``.
    """
    eq = _mexpand(expand_log(eq))
    mainlog = _mostfunc(eq, log, x)
    if not mainlog:
        return []  # violated assumptions
    other = eq.subs(mainlog, 0)
    if (-other).func is log:
        eq = (eq - other).subs(mainlog, mainlog.args[0])
        mainlog = mainlog.args[0]
        if mainlog.func is not log:
            return []  # violated assumptions
        other = -(-other).args[0]
        eq += other
    if not x in other.free_symbols:
        return [] # violated assumptions
    d, f, X2 = _linab(other, x)
    logterm = collect(eq - other, mainlog)
    a = logterm.as_coefficient(mainlog)
    if a is None or x in a.free_symbols:
        return []  # violated assumptions
    logarg = mainlog.args[0]
    b, c, X1 = _linab(logarg, x)
    if X1 != X2:
        return []  # violated assumptions

    u = Dummy('rhs')
    rhs = -c/b + (a/d)*LambertW(d/(a*b)*exp(c*d/a/b)*exp(-f/a))

    # if W's arg is between -1/e and 0 there is a -1 branch solution, too.

    # Check here to see if exp(W(s)) appears and return s/W(s) instead?

    solns = solve(X1 - u, x)
    for i, tmp in enumerate(solns):
        solns[i] = tmp.subs(u, rhs)
    return solns
def _lambert ( eq , x ) : eq = _mexpand ( expand_log ( eq ) ) mainlog = _mostfunc ( eq , log , x ) if not mainlog : return [ ] # violated assumptions other = eq . subs ( mainlog , 0 ) if ( - other ) . func is log : eq = ( eq - other ) . subs ( mainlog , mainlog . args [ 0 ] ) mainlog = mainlog . args [ 0 ] if mainlog . func is not log : return [ ] # violated assumptions other = - ( - other ) . args [ 0 ] eq += other if not x in other . free_symbols : return [ ] # violated assumptions d , f , X2 = _linab ( other , x ) logterm = collect ( eq - other , mainlog ) a = logterm . as_coefficient ( mainlog ) if a is None or x in a . free_symbols : return [ ] # violated assumptions logarg = mainlog . args [ 0 ] b , c , X1 = _linab ( logarg , x ) if X1 != X2 : return [ ] # violated assumptions u = Dummy ( 'rhs' ) rhs = - c / b + ( a / d ) * LambertW ( d / ( a * b ) * exp ( c * d / a / b ) * exp ( - f / a ) ) # if W's arg is between -1/e and 0 there is a -1 branch solution, too. # Check here to see if exp(W(s)) appears and return s/W(s) instead? solns = solve ( X1 - u , x ) for i , tmp in enumerate ( solns ) : solns [ i ] = tmp . subs ( u , rhs ) return solns