Euler's identity: Difference between revisions

(→‎{{header|Groovy}}: Initial solution)
Line 547:
<pre>
0e0+1.2246467991473532e-16i
</pre>
 
=={{header|Scala}}==
This example makes use of Spire's numeric data types. Complex takes a type parameter determining the type of the coefficients of a + bi, and Real is Spire's exact (i.e. arbitrary precision) numeric data type.
 
<lang scala>import spire.math.{Complex, Real}
 
object Scratch extends App{
//Declare values with friendly names to clean up the final expression
val e = Complex[Real](Real.e, 0)
val pi = Complex[Real](Real.pi, 0)
val i = Complex[Real](0, 1)
val one = Complex.one[Real]
println(e.pow(pi*i) + one)
}</lang>
 
{{output}}
<pre>
(0 + 0i)
</pre>
 
Anonymous user