MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / integrated_monomial_coeffs

Function integrated_monomial_coeffs

SLiCAP/SLiCAPmath.py:2262–2317  ·  view source on GitHub ↗

Returns a dictionary with key-value pairs: - key: monomial of variables - coefficient of this monomial with x integrated over the range x_lower ... x_upper. If doit=True the integration will be performed, else integral operators will be returned. :param expr: Sym

(expr, variables, x, x_lower, x_upper, doit=True, 
                               wf=1, method="auto", CDS=False, tau=None, 
                               points=1000, numeric=True)

Source from the content-addressed store, hash-verified

2260 return integratedCoeffs, exponents
2261
2262def integrated_monomial_coeffs(expr, variables, x, x_lower, x_upper, doit=True,
2263 wf=1, method="auto", CDS=False, tau=None,
2264 points=1000, numeric=True):
2265 """
2266 Returns a dictionary with key-value pairs:
2267
2268 - key: monomial of variables
2269 - coefficient of this monomial with x integrated over the range
2270 x_lower ... x_upper.
2271
2272 If doit=True the integration will be performed, else integral operators
2273 will be returned.
2274
2275 :param expr: Sympy expression
2276 :type param: sympy.expr
2277
2278 :param variables: List or tuple with variables
2279 (currently only two variables accepted)
2280
2281 :type variables: list with sympy.Symbol objects
2282
2283 :param x: integration variable
2284 :type x: sympy.Symbol
2285
2286 :param x_lower: start value integration
2287 :type x_lower: sympy.Symbol, int or float
2288
2289 :param x_upper: end value integration
2290 :type x_upper: sympy.Symbol, int or float
2291
2292 :param doit: True/False; If True, the integration will be performed,
2293 else integral operators will be returned.
2294 :type doit: bool
2295
2296 :return: Dictionary with key-value pairs:
2297
2298 - key (sympy.Expr): monomial
2299 - value (sympy.Expr): integrated monomial coefficient
2300
2301 :rtype: sympy.expr, int or float
2302 """
2303
2304 if len(variables) == 2:
2305 integrated_coeffs, orders = _integrateCoeffs2(
2306 expr, variables, x, x_lower, x_upper, doit=doit,
2307 wf=wf, method=method, CDS=CDS, tau=tau,
2308 points=points, numeric=numeric)
2309 else:
2310 raise NotImplementedError(
2311 "Only two-variable monomials are implemented.")
2312 new_coeffs = {}
2313 for key in integrated_coeffs.keys():
2314 newkey = variables[0]**(key[0]-orders[0]) * \
2315 variables[1]**(key[1]-orders[1])
2316 new_coeffs[newkey] = integrated_coeffs[key]
2317 return new_coeffs
2318
2319def integrate_monomial_coeffs(expr, variables, x, x_lower, x_upper, doit=True,

Callers 2

SLiCAPmath.pyFile · 0.85

Calls 1

_integrateCoeffs2Function · 0.85

Tested by

no test coverage detected