-
-
Notifications
You must be signed in to change notification settings - Fork 30
Complex
Arthur Guiot edited this page Oct 7, 2018
·
6 revisions
Starting v1.2.0, TheoremJS now supports complex numbers. All the following methods are chainable (except toString
and arg
).
Here is how to create a complex number in TheoremJS:
t.complex(0, 1) // i
t.i // i
t.complex(1, 1) // 1 + i
t.complex(2) // 2
This will return the absolute value of a complex number.
t.complex(3, 4).abs() //= t.complex(5, 0)
This will return the argument of a complex number
t.complex(1, 1).arg() //= pi / 4 => BigNumber
It will clone the complex number.
t.complex(2, 3).clone() //= t.complex(2, 3)
This will multiply the imaginary part by -1
t.complex(1, 1).conjugate() //= t.complex(1, -1)
This will divide a complex a
by another complex b
const a = t.complex(2, 3)
const b = t.complex(3, -5)
a.div(b).toString() //= "-0.26470588235294117647 + 0.55882352941176470588i"
const a = t.complex(2, 3)
const b = t.complex(3, 3).minus(t.complex(1, 0)
a.eq(b) //= true
This will return the exponential of a complex number. (You can also do it by using t.exp
)
t.complex(2, 3).exp().toString() //= "-7.31511009490109891372481413925 + 1.04274365623590274091988122355i"
t.complex(2, 3).ln().toString() //= "1.28247380404213 + 0.982793723247329i"
t.complex(100, 0).log(10).toString() //= "1.99992155781462 + 0i"
You can also use t.ln
and t.log
t.complex(3, -4).minus(t.complex(2, 4)) //= t.complex(1, -8)
This will multiply the complex number by t.complex(-1, -1)
t.complex(2, 3).negated() //= t.complex(-2, -3)
t.complex(18, -12).plus(t.complex(-3, 2)) //= t.complex(15, -10)
Will elevate any complex a
to complex power b
const a = t.complex(3, 2)
const b = t.complex(4, -2)
a.pow(b).toString() //= "535.424019276695978424428817368 - 115.76768825678578727266368994i"
t.complex(2, 3).times(t.complex(4, 5)) //= t.complex(-7, 22)
t.complex(1, 1).toString() // "1 + 1i"
t.i.toString() // "0 + 1i"
t.complex(2) // "2 + 0i"
Any questions? Don't hesitate to create an issue and tell me about your problem 😊.
Copyright © 2017-2018 Arthur Guiot