复数符号 [英] Complex number notation
问题描述
我的DotNET应用程序内置了有限的脚本语言(在VBScript上宽松地建模),主要用于数字,点和向量的后处理.我刚刚添加了对复数的支持,但是我在这种表示法上苦苦挣扎.
My DotNET application has a limited scripting language build in (modelled loosely on VBScript) mainly for post-processing numbers, points and vectors. I've just added support for complex numbers, but I'm struggling with the notation.
我不想使用A + Bi表示法,因为如果已经将A或B定义为方程式,则该划分并不明确:
I don't want to use the A + Bi notation, since it is not a clear division if A or B are defined as equations already:
31 * 5 + 6 + -5i
31 * 5 + 6 + -5i
这可以解释为:
A = 31 * 5 + 6 B = -5i
A = 31 * 5 + 6 B = -5i
和:
A = 31 * 5 B = 6 + -5i
A = 31 * 5 B = 6 + -5i
我所知道的任何一种编程语言都没有对复数的本机支持.我认为类似以下内容的方法可能会起作用,但对此我表示感谢:
None of the programming languages I know have native support for complex numbers. I'm thinking something like the following might work, but I'd appreciate any input on this:
{31 * 5} + {6 + -5} i
{31 * 5} + {6 + -5}i
复杂(31 * 5,6 + -5)
complex(31 * 5, 6 + -5)
r {31 * 5} i {6 + -5}
r{31 * 5} i{6 + -5}
推荐答案
似乎您在示例中使用了显式乘法(即,您需要A * B而不是A B).
It seems you are using explicit multiplication in your examples (i.e. you require A * B, rather than A B ).
在这种情况下,为什么不直接在值后面直接使用i后缀
In that case why not simply use the i suffix directly following the value as in
myComplex = 12 + 6i
or
myOtherComplex = 12/7 + (6 * pi)i
然后您可能需要确定i或j,我都看过这两个...
Then you may need to decide about i or j, I've seen both...
这个i后缀的技巧与科学的用法没有什么不同,而是e(例如3.1415e7)
This i-suffix trick is not unlike the scientific notication and is e (3.1415e7 for example)
编辑(遵循David的评论)
Edit (following David's comments)
根据观众的不同,上面的格式可能会造成混淆,一种澄清方法可能是仅允许虚构的文字 ,并将其包含在从您现有的矢量符号衍生而来的复杂符号.当虚数或复数需要表达式来指定它们时,该语法将需要显式的函数式"语法,例如Imaginary(i)和Complex(r,i).
The format above can become confusing, depending on the audience, one way to clarify this may be to only allow for imaginary literals, and to include these into a complex notation derived from your existing vector notation. When imaginary numbers or complex number require an expression to designate them, the syntax would require the explicit "function-looking" syntax such as Imaginary(i) and Complex(r, i).
解析规则:
- 任何数字(带符号或无符号,整数或十进制,甚至exp表示法数字)直接后跟i是一个虚数:-7i或1.23i或5.76e4i,但不包括12 i(数字之间不允许有空格和后缀)
- 具有第一个实数和第二个虚数的两个值向量是一个复数:(1,7i)甚至(7,0i)
- 当"i"值是表达式时,使用虚构(i)格式. i表示时没有方法调用语法所隐含的i后缀.
- 当"r"或"i"参数是表达式时,以及每当我们希望避免歧义时,都使用Complex(r,i)格式.
简而言之:
- (7,1i),(0,-3.1415i),(13,0i),Complex(13,0)或Complex(7x + 3,sin(y)+2)都是复数
- 6i,-1.234e5i,虚数(1.234)或虚数(sqrt(19x + 5y))都是虚数
- (12,23,34)是R ^ 3中的向量
- I ^ 2中的向量中的(12i,-2i)(不是复数,因为第一个元素不是实数)
- (((0,0i),(1,-9.2i),(12,0i))或((0,21i),Complex(12,3),(44,-55i))是C中的向量^ 3
这似乎足够一致和简单,但是话又说回来,只有真正的最终用户才能知道.
That's seems consistent and simple enough, but then again, only the true end-users can tell.
这篇关于复数符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!