cancel
Showing results for 
Search instead for 
Did you mean: 

Large numbers calculation problem (determinant calculation)

Former Member
0 Kudos

Hello experts,

I have really interesting problem. I am calculatig determinant in ABAP with a large numbers (in CRM 5.0 system).

My formula for determinant is :

FORM calculate_determinant USING det TYPE zsppo_determinant

CHANGING value TYPE f .

value =

( 1 * det-a11 * det-a22 * det-a33 * det-a44 ) + ( -1 * det-a11 * det-a22 * det-a34 * det-a43 ) +

( -1 * det-a11 * det-a23 * det-a32 * det-a44 ) + ( 1 * det-a11 * det-a23 * det-a34 * det-a42 ) +

( -1 * det-a11 * det-a24 * det-a33 * det-a42 ) + ( 1 * det-a11 * det-a24 * det-a32 * det-a43 ) +

( -1 * det-a12 * det-a21 * det-a33 * det-a44 ) + ( 1 * det-a12 * det-a21 * det-a34 * det-a43 ) +

( 1 * det-a12 * det-a23 * det-a31 * det-a44 ) + ( -1 * det-a12 * det-a23 * det-a34 * det-a41 ) +

( -1 * det-a12 * det-a24 * det-a31 * det-a43 ) + ( 1 * det-a12 * det-a24 * det-a33 * det-a41 ) +

( 1 * det-a13 * det-a21 * det-a32 * det-a44 ) + ( -1 * det-a13 * det-a21 * det-a34 * det-a42 ) +

( -1 * det-a13 * det-a22 * det-a31 * det-a44 ) + ( 1 * det-a13 * det-a22 * det-a34 * det-a41 ) +

( 1 * det-a13 * det-a24 * det-a31 * det-a42 ) + ( -1 * det-a13 * det-a24 * det-a32 * det-a41 ) +

( -1 * det-a14 * det-a21 * det-a32 * det-a43 ) + ( 1 * det-a14 * det-a21 * det-a33 * det-a42 ) +

( 1 * det-a14 * det-a22 * det-a31 * det-a43 ) + ( -1 * det-a14 * det-a22 * det-a33 * det-a41 ) +

( -1 * det-a14 * det-a23 * det-a31 * det-a42 ) + ( 1 * det-a14 * det-a23 * det-a32 * det-a41 )

.

ENDFORM.

Det values are also f type. Problem is, that for several numbers I got the right values and for another det values I got wrong values... I also try to retype variable value on type p, but without success. Maybe I used wrong types or there is some ABAP rounding of numbers which cause wrong result.

Any good ideas of solutions. <text removed>. Thanks for your time.

Edited by: Matt on Sep 14, 2010 9:17 AM

View Entire Topic
Former Member
0 Kudos

Hi Lubos,

phew! that sounds far from SAP scope, but from Maths' numerical methods. Let's see if I can remember something about my lessons at University...

- One issue can arise when adding and subtracting terms which are very similar, because the error tends to arise quite fast. Try to add the positive terms on one hand, and the negative terms on the other hand, then subtract one from the other.

- Please take into account that the determinant value can be significantly close to zero when the condition number of the matrix is low, that is, when the range is 4 but the whole determinant is close to 0. Instead, try a [Singular Value Decomposition|http://en.wikipedia.org/wiki/SVD_(mathematics)] or an [LU decomposition|http://en.wikipedia.org/wiki/LU_decomposition]

I hope this helps. Kind regards,

Alvaro