julia矩陣運算
Julia| 復數 (Julia | Complex Numbers)
The syntax to represent the complex number in Julia is:
在Julia中表示復數的語法為:
Syntax:
句法:
A+Bim
Here, A and B are the values, and im is the global constant which is bound to the complex number i representing the principal square root of -1.
這里, A和B是值, im是全局常數,該常數綁定到表示-1的主平方根的復數i上 。
Example 1:
范例1:
# Julia program to demonstrate the example
# of complex numbers and operations on it
println(1+2im)
println((1+2im)+(2+4im))
# variables
x = 10+23im
println("x: ", x)
println("typeof(x): ", typeof(x))
Output
輸出量
1 + 2im
3 + 6im
x: 10 + 23im
typeof(x): Complex{Int64}
復數的各種運算 (Various operations on Complex Numbers)
Example 2:
范例2:
# Julia program to demonstrate the example
# of complex numbers and operations on it
x = 1+2im
y = 2.34+78.909im
println("x: ", x)
println("y: ", y)
# operations
add = x+y
sub = x-y
mul = x*y
div = x/y
exp = x^2
# printing
println("add: ", add)
println("sub: ", sub)
println("mul: ", mul)
println("div: ", div)
println("exp: ", exp)
Output
輸出量
x: 1 + 2im
y: 2.34 + 78.909im
add: 3.34 + 80.909im
sub: -1.3399999999999999 - 76.909im
mul: -155.478 + 83.589im
div: 0.02569885734584168 - 0.011910741155137315im
exp: -3 + 4im
Reference: Julia Complex Numbers
參考: Julia復數
翻譯自: https://www.includehelp.com/julia/complex-numbers-and-operations.aspx
julia矩陣運算