Closed rwmorton closed 6 months ago
The expression \sqrt{-1}
is a Number. It needs to be evaluated to be recognized as a complex number. The domain of an expression can be observed with the .domain
property.
const expr = ce.parse("\\sqrt{-1}")
console.log('expr.isComplex =', expr.isComplex)
// -> false
console.log('expr.domain =', expr.domain)
// -> Numbers
console.log(`expr.N().value = ${x}`)
// ["Complex", 0, 1]
console.log(`expr.N().isComplex = ${expr.N().isComplex}`)
// -> true
console.log(`expr.N().domain = ${expr.N().domain}`)
// ComplexNumbers
Wow that's awesome, thank you!
On the compute-engine demo plugging in
sqrt(-2)
gives2i
which is correct. However when testing theBoxedExpression.isComplex
value it returnsfalse
despite the evaluated value being["Complex", 0, 1]
.Here is a code sample to demonstate:
and the output is: