将SymPy表达式与不涉及x的复杂因子进行积分

时间:2018-11-04 09:59:02

标签: python sympy

我想用sympy.integrate集成复杂的功能。我意识到这会花费太多时间(至少我在2.5小时后停止了进程)。

我打算尽可能简单地给程序提供一个方程式。 假设我有一个功能:

alpha*x**(-rho/(rho - 1))*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)

我唯一要整合的部分是

MainPart = x**(-rho/(rho - 1))

IntegMainPart=sympy.integrate(MainPart)

剩下的只是参数,它们将是

Rest=alpha*(-gamma*l*rho + gamma*l - gamma*pi*rho + gamma*pi - l*rho - pi*rho)/(gamma*mu)

所以我有可能只参与重要的部分并将其集成,而不是像其他部分那样整合

IntegMainPart*Rest

1 个答案:

答案 0 :(得分:1)

SymPy能够正确处理不涉及积分变量的因素。您无需手动删除它们。这就是我的积分方式。

$obj.City

SymPy 1.3一次打印积分。

# Instantiate a new customer-data object.
$customer = [CustomerData]::new()

# Parse the JSON data in custom objects ([pscustomobject]).
# In this case, you'll get a single-element array containing an array
# of [pscustomobject] instances.
$jsondata = ConvertFrom-Json '[{"key":"city","previousValue":"New York","updatedValue":"Palm City"},{"key":"zipcode","previousValue":"100012","updatedValue":"02118"},{"key":"coaddress","updatedValue":""},{"key":"streetaddress","previousValue":"9253 Del Monte Road","updatedValue":"90 Kent Ave"},{"key":"SSN","updatedValue":""},{"key":"companyName","previousValue":"Nutrics","updatedValue":"NutriTiger"}]'


# Loop over all custom objects and update the corresponding
# customer-data properties.
foreach($obj in $jsonData) {
   $propName = $obj.key
   $customer.$propName = $obj.UpdatedValue
}