Complex Numbers Datatype

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:
ce205113f4dd8a23f08dacbcd8d73a77
In order:

  1. i * i = -1
  2. i ^ i = e^(-pi/2)
  3. e^(i*pi) = -1 (or it would, if math.pi was infinitely precise :cold_sweat:)
  4. cos(i*pi) = cosh(pi) = nothing special, just showing off complex cos
  5. Complex number from real and imaginary components
10 Likes

how have you managed to obtain the value of i and e?
nevermind got it