-3

I have written this optimization procedure using numpy where I have to perform the following calculation:

formula

B is a symmetric negative semi-definite matrix and I the identity matrix. The problem is that the values of B can be too big (>1e25) and when subtracting by the diagonal matrix some elements don't because there is enough precision. Is there any way to overcome this problem or do I need to rewrite it using another library like mpmath?

Bill Bell
  • 21,021
  • 5
  • 43
  • 58
Joao Caetano
  • 45
  • 1
  • 3

1 Answers1

0

You need to re-implement, but the implementation may be simple: change your numeric representation. Since you didn't specify the base type you're using, or the actual value range (1e25 versus what?), I can't make a definite recommendation.

However, note that numpy has several types with greater precision, including longdouble (80 bits), float96, and float128. If you need more than 128 bits (38 digits of precision), then mpmath is the way to go.

Prune
  • 76,765
  • 14
  • 60
  • 81