Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect work with large values in the matrix #561

Open
alex0alex0 opened this issue Feb 8, 2022 · 1 comment
Open

Incorrect work with large values in the matrix #561

alex0alex0 opened this issue Feb 8, 2022 · 1 comment
Labels
Bug A serious math/runtime error

Comments

@alex0alex0
Copy link

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
-->

@WhiteBlackGoose WhiteBlackGoose added the Bug A serious math/runtime error label Feb 9, 2022
@WhiteBlackGoose
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A serious math/runtime error
Projects
None yet
Development

No branches or pull requests

2 participants