我在Stack-overflow上阅读了不同python问题的答案。当我遇到一个答案时,他在答案中使用了函数imag和real来查找sinx和cosx的值,如下所示
>>> e = 2.718281828459045
>>> X = 0.1
>>> (e**(X*1j)).imag # sin(X)
0.09983341664682815
>>> (e**(X*1j)).real # cos(X)
0.9950041652780258所以我被图像和真实的功能弄糊涂了。
发布于 2021-05-30 12:02:13
numpy.real()函数返回复数参数的实数部分。
Syntax: numpy.real(arr)
Parameters :
arr : [array_like] Input array.
Return : [ndarray or scalar] The real component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float.基本示例:
import numpy as np
arr = np.array([1 + 3j, 5 + 7j, 9 + 11j])
gfg = arr.real
print (gfg)输出:
[1. 5. 9.]因此,在您的代码中,它试图找到值的虚构和实数部分。
下面是你的代码的一般数学公式e^ix = cos(x)+isin(x)。Real是Cosx,虚构是sinx。
https://stackoverflow.com/questions/67757521
复制相似问题