作为一名程序员,你会如何解释虚数?
作为一名程序员,我认为擅长数学是我的工作,但我很难理解虚数。 我尝试过谷歌和 wikipedia 但没有运气,所以我希望程序员可以向我解释,给我一个 <= 0 的数字平方的例子,一些示例用法等......
As a programmer I think it is my job to be good at math but I am having trouble getting my head round imaginary numbers. I have tried google and wikipedia with no luck so I am hoping a programmer can explain in to me, give me an example of a number squared that is <= 0, some example usage etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我想这个博客条目是一个很好的解释:
关键词是旋转(与负数的方向相反,负数就像虚数一样奇怪:< em>什么都没有?)
就像负数建模翻转一样,<虚数可以模拟任何在二维“X”和“Y”之间旋转的东西。 或者任何具有循环、循环关系的东西
I guess this blog entry is one good explanation:
The key word is rotation (as opposed to direction for negative numbers, which are as stranger as imaginary number when you think of them: less than nothing ?)
Like negative numbers modeling flipping, imaginary numbers can model anything that rotates between two dimensions “X” and “Y”. Or anything with a cyclic, circular relationship
问题:我不仅是一名程序员,而且还是一名数学家。
解决方案:无论如何,都要努力前进。
复数并没有什么真正神奇的地方。 他们创立的初衷是认为实数存在问题。 如果你有一个方程 x^2 + 4,它永远不会为零,而 x^2 - 2 两次为零。 因此,数学家们非常生气,希望始终存在次数至少为 1 的多项式的零(想要一个“代数闭”域),并创建了一些任意数 j,使得 j = sqrt(-1)。 所有的规则都从那里开始落实(尽管它们以不同的方式更准确地重新组织 - 具体来说,你实际上不能正式地说“嘿这个数字是负数的平方根”)。 如果有j这个数,就可以得到j的倍数。 你可以将实数加到 j 上,这样你就得到了复数。 复数运算与二项式运算类似(故意如此)。
复合体的真正问题并不在于这一切,而在于事实上您无法定义一个系统来获得小于和大于的普通规则。 所以实际上,你已经到达了根本没有定义它的地方。 在二维空间中这是没有意义的。 因此,老实说,我实际上无法回答“给我一个 <= 0 的数字平方的例子”,尽管如果您将其平方视为实数而不是复数,则“j”是有意义的。
至于用途,我个人在处理分形时最常使用它们。 曼德布罗分形背后的想法是,它是一种绘制 z = z^2 + c 及其沿实虚轴散度的方法。
Problem: not only am I a programmer, I am a mathematician.
Solution: plow ahead anyway.
There's nothing really magical to complex numbers. The idea behind their inception is that there's something wrong with real numbers. If you've got an equation x^2 + 4, this is never zero, whereas x^2 - 2 is zero twice. So mathematicians got really angry and wanted there to always be zeroes with polynomials of degree at least one (wanted an "algebraically closed" field), and created some arbitrary number j such that j = sqrt(-1). All the rules sort of fall into place from there (though they are more accurately reorganized differently-- specifically, you formally can't actually say "hey this number is the square root of negative one"). If there's that number j, you can get multiples of j. And you can add real numbers to j, so then you've got complex numbers. The operations with complex numbers are similar to operations with binomials (deliberately so).
The real problem with complexes isn't in all this, but in the fact that you can't define a system whereby you can get the ordinary rules for less-than and greater-than. So really, you get to where you don't define it at all. It doesn't make sense in a two-dimensional space. So in all honesty, I can't actually answer "give me an exaple of a number squared that is <= 0", though "j" makes sense if you treat its square as a real number instead of a complex number.
As for uses, well, I personally used them most when working with fractals. The idea behind the mandelbrot fractal is that it's a way of graphing z = z^2 + c and its divergence along the real-imaginary axes.
你可能还会问为什么会有负数存在? 它们的存在是因为您想要表示某些方程的解,例如:x + 5 = 0。同样的事情也适用于虚数,您想要紧凑地表示以下形式的方程的解:x^2 + 1 = 0。
这是一种方法我已经看到它们在实践中被使用。 在 EE 中,您经常处理正弦波或可以分解为正弦波的函数。 (例如,参见傅立叶级数)。
因此,您经常会看到以下形式的方程的解:
f(t) = A*cos(wt)
此外,您通常希望表示从该函数移动某个相位的函数。 90 度相移将为您提供一个正弦函数。
g(t) = B*sin(wt)
通过组合这两个函数(称为同相和正交分量),您可以获得任意相移。
h(t) = Acos(wt) + iB*sin(wt)
这里的关键是在线性系统中:如果 f(t) 和 g(t) 求解方程,则 h (t) 也将求解相同的方程。 所以,现在我们有了方程 h(t) 的通用解。
h(t) 的好处在于,
它可以紧凑地写为h(t) = Cexp(wt+theta)
利用 exp(iw) = cos(w)+i*sin(w) 的事实,
。 这些确实没有什么特别深奥的地方。 它只是利用数学恒等式来简洁地表示各种方程的通用解。
You might also ask why do negative numbers exist? They exist because you want to represent solutions to certain equations like: x + 5 = 0. The same thing applies for imaginary numbers, you want to compactly represent solutions to equations of the form: x^2 + 1 = 0.
Here's one way I've seen them being used in practice. In EE you are often dealing with functions that are sine waves, or that can be decomposed into sine waves. (See for example Fourier Series).
Therefore, you will often see solutions to equations of the form:
f(t) = A*cos(wt)
Furthermore, often you want to represent functions that are shifted by some phase from this function. A 90 degree phase shift will give you a sin function.
g(t) = B*sin(wt)
You can get any arbitrary phase shift by combining these two functions (called inphase and quadrature components).
h(t) = Acos(wt) + iB*sin(wt)
The key here is that in a linear system: if f(t) and g(t) solve an equation, h(t) will also solve the same equation. So, now we have a generic solution to the equation h(t).
The nice thing about h(t) is that it can be written compactly as
h(t) = Cexp(wt+theta)
Using the fact that exp(iw) = cos(w)+i*sin(w).
There is really nothing extraordinarily deep about any of this. It is merely exploiting a mathematical identity to compactly represent a common solution to a wide variety of equations.
好吧,对于程序员来说:
这基本上就是全部了。 复数只是实数对,为此定义了 +、* 和 == 的特殊重载。 这些操作实际上就是这样定义的。 然后事实证明,这些具有这些运算的数字对与数学的其余部分非常吻合,因此它们得到了一个特殊的名称。
它们不像“计数”中的数字,而更像“可以用 +、-、*、... 进行操作,并且与‘常规’数字混合时不会引起问题”。 它们很重要,因为它们填补了实数留下的漏洞,就像没有数字的平方为 -1 一样。 现在您有了
complex(0, 1) *complex(0, 1) == -1.0
这是一个有用的符号,因为在这些情况下您不必再专门处理负数。 (而且,事实证明,当您使用复数时,基本上不再需要所有其他特殊情况)Well, for the programmer:
That's basically all there is. Complex numbers are just pairs of real numbers, for which special overloads of +, * and == get defined. And these operations really just get defined like this. Then it turns out that these pairs of numbers with these operations fit in nicely with the rest of mathematics, so they get a special name.
They are not so much numbers like in "counting", but more like in "can be manipulated with +, -, *, ... and don't cause problems when mixed with 'conventional' numbers". They are important because they fill the holes left by real numbers, like that there's no number that has a square of -1. Now you have
complex(0, 1) * complex(0, 1) == -1.0
which is a helpful notation, since you don't have to treat negative numbers specially anymore in these cases. (And, as it turns out, basically all other special cases are not needed anymore, when you use complex numbers)如果问题是“虚数存在吗?” 或“虚数是如何存在的?” 那么这就不是程序员的问题了。 这甚至可能不是数学家的问题,而是形而上学家或数学哲学家的问题,尽管数学家可能觉得有必要证明他们在该领域的存在。 从讨论数字到底是如何存在的开始是很有用的(仅供参考,很多研究这个问题的数学家都是柏拉图主义者)。 有些人坚持认为虚数(正如早期怀特海所做的那样)是一种实际的便利。 但是,如果虚数仅仅是一种实际的便利,那么这对数学来说又意味着什么呢? 你不能仅仅将虚数解释为纯粹的实用工具或一对实数,而不必考虑这两对以及它们“实用”的一般后果。 其他人则坚持虚数的存在,认为虚数的不存在会破坏大量使用虚数的物理理论(量子力学深陷复杂的希尔伯特空间)。 我相信这个问题超出了本网站的范围。
如果您的问题更加实际,例如如何在软件中表达虚数,那么上面的答案(一对实数,以及它们的定义操作)就是它。
If the question is "Do imaginary numbers exist?" or "How do imaginary numbers exist?" then it is not a question for a programmer. It might not even be a question for a mathematician, but rather a metaphysician or philosopher of mathematics, although a mathematician may feel the need to justify their existence in the field. It's useful to begin with a discussion of how numbers exist at all (quite a few mathematicians who have approached this question are Platonists, fyi). Some insist that imaginary numbers (as the early Whitehead did) are a practical convenience. But then, if imaginary numbers are merely a practical convenience, what does that say about mathematics? You can't just explain away imaginary numbers as a mere practical tool or a pair of real numbers without having to account for both pairs and the general consequences of them being "practical". Others insist in the existence of imaginary numbers, arguing that their non-existence would undermine physical theories that make heavy use of them (QM is knee-deep in complex Hilbert spaces). The problem is beyond the scope of this website, I believe.
If your question is much more down to earth e.g. how does one express imaginary numbers in software, then the answer above (a pair of reals, along with defined operations of them) is it.
我不想把这个网站变成数学溢出,但对于那些感兴趣的人:查看 Paul J. Nahin 的“An Imaginary Tale: The Story of sqrt(-1)”。 它以有趣和令人兴奋的方式讲述了虚数的所有历史和各种应用。 七年前,当我读到这本书时,我决定攻读数学学位(当时我正在考虑艺术)。 读得好!!
I don't want to turn this site into math overflow, but for those who are interested: Check out "An Imaginary Tale: The Story of sqrt(-1)" by Paul J. Nahin. It talks about all the history and various applications of imaginary numbers in a fun and exciting way. That book is what made me decide to pursue a degree in mathematics when I read it 7 years ago (and I was thinking art). Great read!!
要点是添加您定义的数字作为二次方程的解,例如 x2= -1。 说出该方程 i 的一个解,然后根据该方程得出 i 的计算规则。
这类似于当您只知道正数时将负数定义为 2 + x = 1 等方程的解,或者当您只知道整数时将分数定义为 2x = 1 等方程的解。
The main point is that you add numbers which you define to be solutions to quadratic equations like x2= -1. Name one solution to that equation i, the computation rules for i then follow from that equation.
This is similar to defining negative numbers as the solution of equations like 2 + x = 1 when you only knew positive numbers, or fractions as solutions to equations like 2x = 1 when you only knew integers.
最简单的方法可能是停止尝试理解数字如何成为负数的平方根,而继续假设它是负数。
因此(使用i作为-1的平方根):
根据数学标准规则进行计算(记住第四行的i平方等于-1)。
It might be easiest to stop trying to understand how a number can be a square root of a negative number, and just carry on with the assumption that it is.
So (using the i as the square root of -1):
works according to the standard rules of maths (remembering that i squared equals -1 on line four).
虚数是实数乘以虚数单位
i
。i
定义为:因此:
使用此定义,您可以获得负数的平方根,如下所示:
最终答案是实数
sqrt(3)
乘以由虚数单位i
。An imaginary number is a real number multiplied by the imaginary unit
i
.i
is defined as:So:
Using this definition you can obtain the square root of a negative number like this:
And your final answer is the real number
sqrt(3)
multiplied by the imaginary uniti
.简短的回答:实数是一维的,虚数为方程添加了第二个维度,如果相乘,就会发生一些奇怪的事情......
A short answer: Real numbers are one-dimensional, imaginary numbers add a second dimension to the equation and some weird stuff happens if you multiply...
如果您有兴趣寻找一个简单的应用程序并且熟悉矩阵,
有时使用复数将完全实数矩阵转换为复空间中的三角形矩阵很有用,并且它使计算变得更容易。
结果当然是完全真实的。
If you're interested in finding a simple application and if you're familiar with matrices,
it's sometimes useful to use complex numbers to transform a perfectly real matrice into a triangular one in the complex space, and it makes computation on it a bit easier.
The result is of course perfectly real.
到目前为止,答案很好(真的很像德文的!)
还有一点:
复数的第一个用途之一(尽管当时不这么称呼)是作为求解三阶方程的中间步骤。
link
再说一次,这纯粹是一个用来回答实际问题的工具具有物理意义的实数。
Great answers so far (really like Devin's!)
One more point:
One of the first uses of complex numbers (although they were not called that way at the time) was as an intermediate step in solving equations of the 3rd degree.
link
Again, this is purely an instrument that is used to answer real problems with real numbers having physical meaning.
在电气工程中,电感器的阻抗 Z 为 jwL,其中 w = 2*pi*f(频率)和 j (sqrt(-1)) 表示它领先 90 度,而对于电容器 Z = 1/jwc = -j/wc 为 -90deg/wc,因此它滞后于简单电阻 90 度。
In electrical engineering, the impedance Z of an inductor is jwL, where w = 2*pi*f (frequency) and j (sqrt(-1))means it leads by 90 degrees, while for a capacitor Z = 1/jwc = -j/wc which is -90deg/wc so that it lags a simple resistor by 90 deg.