【发布时间】:2021-12-31 10:37:53
【问题描述】:
我的代码是
import numpy as np
from scipy import integrate
from math import *
import cmath
f = lambda y, x: cmath.sqrt(1 - x**2 - y**2)
hemisphere = integrate.dblquad(f, -1, 1, lambda x: -1, lambda x: 1)
print(hemisphere)
我得到的错误是
TypeError: can't convert complex to float
因为根是负数,所以它包含复数。
我能做些什么让它正常工作吗?
非常感谢。
【问题讨论】:
-
这个模块可能无法实现如此复杂的集成。我相信通过一些手工计算,可以使用here 描述的技术。