math.rationalize silently ignores imaginary numbers
Open
bug
help wanted
- Dominant language
- JavaScript
- Stars
- 15.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Currently, `math.rationalize` seems to ignore imaginary numbers:
```js
// math.js version 9.5.1
// complex coefficient a = (2 + complex(3, 4))
let a = new math.OperatorNode("+", "add", [new math.ConstantNode(2), new math.ConstantNode(math.complex(3, 4))]);
console.log(a.evaluate()); // {re: 5, im: 4}
// polynomial a * x
let poly = new math.OperatorNode("*", "multiply", [a, new math.SymbolNode("x")]);
let coefficients = math.rationalize(poly, true).coefficients;
console.log(coefficients); // [0, 5]
```
I would expect `coefficients` to be `[0, 5+4i]` or for `rationalize` to throw an error.
Contributor guide
Assessment
This issue has not been assessed yet.