简体   繁体   English

Python 对数据类型进行编码,即用于复数算术

[英]Python coding on datatypes i.e. for complex number arithmetic

In Python -在 Python -

x3 = 23/2j
print(x3)
#output = -11.5j

and when什么时候

x3 = 23j/2
print(x3)
#output = 11.5j

whats the reason什么原因

see, value of j is sq-root of -1, and so value of j-square j^2 = -1看,j 的值是 -1 的平方根,所以 j 平方 j^2 的值 = -1

Multiple both numerator and denominator by j in first equation在第一个方程中将分子和分母都乘以 j

x3 = (23 * j)/ (2j * j)

=> x3 = 23j/(-2) because j-square = -1 => x3 = 23j/(-2)因为 j 方 = -1

=> x3 = -23j/2 => x3 = -23j/2

Suppose you have 23j/2 ie a complex number and if you want j in denominator, you can shift it to denominator but the condition is you have to place a negative sign as it is an imaginary number( For ex. 2+3j, here 2 is real and 3 is imaginary part of the equation. You can also write it as 2-3/j) so your number becomes -23/2j.假设你有 23j/2 即一个复数,如果你想要 j 作为分母,你可以把它移到分母,但条件是你必须放一个负号,因为它是一个虚数(例如 2+3j,这里2 是实数,3 是等式的虚数部分。你也可以把它写成 2-3/j),这样你的数就变成了 -23/2j。 I hope this will be helpful for you我希望这对你有帮助

It's to do with syntax/representation of the complex part.这与复杂部分的语法/表示有关。 (ie the #j is one single unit) (即#j是一个单一的单位)

  1. 23/2j = 23/(2j) = -11.5j and NOT (23/2)*j . 23/2j = 23/(2j) = -11.5j不是(23/2)*j

  2. 23j/2 = (23j)/2 = 11.5j

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是在“全局”类中定义的变量,即在Python中无效 - Is a variable defined in a class “global” i.e. invalid in Python Python3确定对数是否“完美”,即浮点数没有余数 - Python3 Determine if logarithm is “perfect,” i.e., no remainder on float 如何在 python 中的句子前添加数字,即递增 - How to add numbers i.e. increment before a sentence in python Python版本设置为不存在的版本即python3.7.10 - Python version is set to non-existing version i.e. python3.7.10 如何在不进行Python类型转换的情况下保存十六进制文本字符串,即作为纯文本 - How to save text string of Hex without Python type conversion, i.e. just as plain text Python - 将字符串添加到剪贴板,以正确的格式粘贴到 Excel(即,分成行/列) - Python -- Adding string to clipboard that will paste to Excel in proper format (i.e., separated into rows/columns) Python 3 上的 Sqlite 和 Spatialite 并完全支持空间索引(即 rtree) - Sqlite on Python 3 with Spatialite and full support for spatial indices (i.e. rtree) 从 ip 地址获取本地主机名,即 Windows 10 上的 192.168.1.x python 3 - get local hostname from ip adress i.e. 192.168.1.x python 3 on windows 10 如何使用签名([start,] stop [,step])实现python方法,即左侧的默认关键字参数 - How to implement python method with signature like ([start ,] stop [, step]), i.e. default keyword argument on the left Python 闭包是否需要外部作用域超出作用域(即结束) - Does Python closure require the outer scope going out of scope(i.e. ended)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM