I’m working on simulating the Schrodinger equation in Roblox so I created a complex number datatype, and I thought someone else might also find a use for it so I’m posting it here:
https://www.roblox.com/library/7067172895/Complex-Numbers-Datatype-module
As of now I have these functions remade for complex numbers:
- sin(z)
- cos(z)
- tan(z)
- sqrt(z)
- ln(z)
- exp(z)
As well as the regular +,-,*,/,^ operators, and some complex number specific functions for convenience, like .conj(z)
Here’s some sample output:
In order:
- i * i = -1
- i ^ i = e^(-pi/2)
- e^(i*pi) = -1 (or it would, if math.pi was infinitely precise )
- cos(i*pi) = cosh(pi) = nothing special, just showing off complex cos
- Complex number from real and imaginary components