terrylyons / libalgebra

This C++ headers only library provides tools for manipulating elements of algebras; the tensor algebra, free lie algebra etc. Early versions can be found in sourceforge. It is capable of calculations over many rings including the arbitrary precision rationals from gmp/mpir . The associated library libalgebra_tests has many examples of how to use the code. the pypy package wraps a version of it - with a simple interface (and vastly reduced functionality)
12 stars 2 forks source link

Bug in tensor exp when arg has non-zero unit term #27

Open inakleinbottle opened 3 years ago

inakleinbottle commented 3 years ago

So I discovered a strange bug in the exp function when it is given a tensor with a non-zero unit element. I suspect the problem is in an optimisation of the multiplication logic but I will have to check. This only effects dense vectors, and presumably hybrid vectors when the dense part is sufficiently large.

dense_tensor_functions_float:26:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected 0 +/- 3e-08 but was 5.10864
dense_tensor_functions_double:26:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected 0 +/- 2e-15 but was 5.10864
dense_tensor_functions_rational:16:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected ...
terrylyons commented 3 years ago

Thank goodness for unit tests. This case needs care. It is tempting to use exp(c+l)=exp(c)exp(l). Since exp(c) is scalar one can use separate optimisations in its calculation. However, it is not required that scalar is commutative. I think we assume it is unital and a bi-module over the rationals. We also need that the tensor algebra is a left and a right module over the scalars. For example the scalars could ? be the truncated tensor algebra.

The series for the exponential function in the tensor algebra has a very different flavour in the case where there is / is not a constant term. In the latter case it’s convergence is algebra. In the former case it is analysis.

Log has similar issues. The involution as well.

Does the bug already show when width = 1?

Terry

On 25 Aug 2021, at 18:29, inakleinbottle @.***> wrote:



So I discovered a strange bug in the exp function when it is given a tensor with a non-zero unit element. I suspect the problem is in an optimisation of the multiplication logic but I will have to check. This only effects dense vectors, and presumably hybrid vectors when the dense part is sufficiently large.

dense_tensor_functions_float:26:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected 0 +/- 3e-08 but was 5.10864 dense_tensor_functions_double:26:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected 0 +/- 2e-15 but was 5.10864 dense_tensor_functions_rational:16:1: error: Failure in tensor_exp_two_letters_plus_unit: Expected ...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/terrylyons/libalgebra/issues/27, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABQWN66POVGOTY5XSDASHZ3T6UK7TANCNFSM5CZQHIOA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.