在python 3.2中求解积分的系统方程

时间:2014-03-21 16:07:21

标签: python python-3.x continuous-integration integral

我需要在python 3.2中解决积分的系统方程。

我需要解决的等式:更新

 integral_from_0_N of (x * f(x))  dx  =  constant  // here , constant > 0 , N > 0

,其中

f(x) = g(j,k) * (x/k)^(j-1) * exp(-x/k)   // here,  k > 0 , j > 0 

在这里,

g(j,k) = j / [ k* g1 (1+j, constant1/k)  - k* g1 (1+j, constant2/k)  + exp(-constant2/k)  * k^(1-j) * constant2^j  - exp(-constant1/k)  * k^(1-j) * constant1^j ]

constant1 >= 0 , constant 2 > 0  

其中

     g1( p, q) = integral_from_q_to_inf of (t^(p-1) * exp(-t)) dt

我需要找到k和j的解决方案。这是python代码。


  from sympy import S, Eq, solve, integrals
  import sympy as sym
  import scipy.integrate as integ

  x, b, c, m, v, L, u = S('x, b, c, m, v, L, u'.split()) 
  equations = [Eq(m, integ.quad(xf(x, b, c), L, u))]

 def xf(x, b,c):
    return x*f(x,b,c)

 def f(x, b, c):
    return g(x, b,c) * (x/b)**(c-1) * sym.exp(-x/b)

 def g(x, b, c):
     c = 1+c  // TypeError: unsupported operand type(s) for +: 'int' and 'tuple'
     L = 1 
     u = 10
     ff1 = b*g1(c, L/b)

 def g1(a,z):
   x = symbols('x')
   return sym.integrate(x**(a-1) * sym.exp(-2*x), (x,z, sym.oo))  

我收到了错误:

  quadpack.error: Supplied function does not return a valid float.

任何帮助将不胜感激!

0 个答案:

没有答案