Repository: sympy/sympy
File: sympy/integrals/manualintegrate.py (Python)

Code before:

def exp_rule(integral):
    integrand, symbol = integral
    if isinstance(integrand.args[0], Symbol):
        return ExpRule(integrand, symbol, E, integrand.args[0])


def powsimp_rule(integral):
    """
    Strategy that simplifies the exponent of a power.
    exp(a*x**2) * exp(b*x) -> exp((a*x**2 + b*x))
    For example, this is useful for the ErfRule.
    """
    integrand, symbol = integral
    a = Wild('a', exclude=[symbol])
    b = Wild('b', exclude=[symbol])
    k = Wild('k', exclude=[symbol])

    match = integrand.match(k**(a*symbol**2) * k**(b*symbol))

    if not match:
        return

    simplified = powsimp(integrand, combine='exp')

    return None if simplified == integrand else RewriteRule(integrand, symbol, simplified, integral_steps(simplified, symbol))


def orthogonal_poly_rule(integral):
    orthogonal_poly_classes = {
        jacobi: JacobiRule,
        gegenbauer: GegenbauerRule,
        chebyshevt: ChebyshevTRule,
        chebyshevu: ChebyshevURule,
        legendre: LegendreRule,
        hermite: HermiteRule,
        laguerre: LaguerreRule,
        assoc_laguerre: AssocLaguerreRule
        }
    orthogonal_poly_var_index = {
        jacobi: 3,
        gegenbauer: 2,
        assoc_laguerre: 2
        }
    integrand, symbol = integral
    for klass in orthogonal_poly_classes:
        if isinstance(integrand, klass):
            var_index = orthogonal_poly_var_index.get(klass, 1)
            if (integrand.args[var_index] is symbol and not
                any(v.has(symbol) for v in integrand.args[:var_index])):
                    return orthogonal_poly_classes[klass](integrand, symbol, *integrand.args[:var_index])

Review comment (suggestion):
This line is long. There is no need for it to be long though:
```python
if simplified != integrand:
    steps = integral_steps(simplified, symbol)
    return RewriteRule(integrand, symbol, simplified, steps)
```

Code after:

def exp_rule(integral):
    integrand, symbol = integral
    if isinstance(integrand.args[0], Symbol):
        return ExpRule(integrand, symbol, E, integrand.args[0])


def powsimp_rule(integral):
    """
    Strategy that simplifies the exponent of a power.
    exp(a*x**2) * exp(b*x) -> exp((a*x**2 + b*x))
    For example, this is useful for the ErfRule.
    """
    integrand, symbol = integral
    a = Wild('a', exclude=[symbol])
    b = Wild('b', exclude=[symbol])
    k = Wild('k', exclude=[symbol])

    match = integrand.match(k**(a*symbol**2) * k**(b*symbol))

    if not match:
        return

    simplified = powsimp(integrand, combine='exp')

    if simplified != integrand:
        steps = integral_steps(simplified, symbol)
        return RewriteRule(integrand, symbol, simplified, steps)


def orthogonal_poly_rule(integral):
    orthogonal_poly_classes = {
        jacobi: JacobiRule,
        gegenbauer: GegenbauerRule,
        chebyshevt: ChebyshevTRule,
        chebyshevu: ChebyshevURule,
        legendre: LegendreRule,
        hermite: HermiteRule,
        laguerre: LaguerreRule,
        assoc_laguerre: AssocLaguerreRule
        }
    orthogonal_poly_var_index = {
        jacobi: 3,
        gegenbauer: 2,
        assoc_laguerre: 2
        }
    integrand, symbol = integral
    for klass in orthogonal_poly_classes:
        if isinstance(integrand, klass):
            var_index = orthogonal_poly_var_index.get(klass, 1)
            if (integrand.args[var_index] is symbol and not