asc-community/AngouriMath

Incorrect work with large values in the matrix

alex0alex0 opened this issue · 1 comments

The version I use: 0.0.0-master-1643285211-942237d
-->

Unexpected behaviour or bug: Incorrect work with large values in the matrix. For example I want to invert a matrix:

var Ex0 = MathS.Matrix(new Entity[4, 4]
{
{ 112085.589993654798036004649475216865539550781250, 637642819921.509799957275390625, 20692733745923116440.0, 985012471441596398530723840.0 },
{ 637642819921.509799957275390625, 20692733745923116440.0, 985012471441596398530723840.0, 53035823659846109665657533505732608.0 },
{ 20692733745923116440.0, 985012471441596398530723840.0, 53035823659846109665657533505732608.0, 3088144109088191970827418502918634458841088.0 },
{ 985012471441596398530723840.0, 53035823659846109665657533505732608.0, 3088144109088191970827418502918634458841088.0, 190454802288659943182846234171424053458511757049856.0}
});
var Ex1 = Ex0.Inverse; // ComputeInverse() does not work

The result is wrong. I check by Excel.
Thanks
-->

Thanks for the report! Interesting bug.

Desired behaviour: Ex0 * Ex1 gives identity matrix.

Observationsn

  • If I remove the fractional parts of the numbers, it works fine (e. g. .5).
  • If I keep the fractional part for one number, it still works fine
  • If I keep the fr. part for two or three numbers, there's a hell with rational numbers, the fractions become huge. But still, the returned result is roughly equal to identity matrix
  • If I use the original fr. power from this issue (a very long one), their product gets far from identity

Workaround

For now, you can round your huge numbers to integers, then the inversion works.