def random_complex_number(a=2, b=-1, c=3, d=1, rational=False):
"""
Return a random complex number.
To reduce chance of hitting branch cuts or anything, we guarantee
b <= Im z <= d, a <= Re z <= c
"""
A, B = uniform(a, c), uniform(b, d)
if not rational:
return A + I*B
return nsimplify(A, rational=True) + I*nsimplify(B, rational=True)
评论列表
文章目录