Use scipy.integrate.quad to integrate complex numbers

后端 未结 2 1640
别那么骄傲
别那么骄傲 2020-11-28 08:37

I\'m using right now the scipy.integrate.quad to successfully integrate some real integrands. Now a situation appeared that I need to integrate a complex integrand. quad see

2条回答
  •  离开以前
    2020-11-28 09:18

    I realize I'm late to the party, but perhaps quadpy (a project of mine) can help. This

    import quadpy
    import numpy
    
    val, err = quadpy.quad(lambda x: numpy.exp(1j * x), 0, 1)
    print(val)
    

    correctly gives

    (0.8414709848078964+0.4596976941318605j)
    

提交回复
热议问题