math domain error

hinsen at cnrs-orleans.fr hinsen at cnrs-orleans.fr
Mon Jun 28 10:09:37 EDT 1999


SC Zhong <sai at dft.chem.cuhk.edu.hk> writes:

> I used the Numerical modules to find the square root of a matrix and
> get the "math domain error", what is it?  The matrix I have is
> 1096*1096 dimension.  When I tested the program with smaller problem,
> it seems to work.  Please advice.
>
> /var/tmp/chk_overlap-> Traceback (innermost last):
>   File ".//pop", line 412, in ?
>     popMatrix = LdinAnalysis(alphacoefficientsMatrix)
>   File ".//pop", line 345, in LdinAnalysis
>     M(overlapMatrix, eigvecsT))),eigvecsTInverse)))
> ValueError: math domain error

You don't show the code that being executed, so I'll have to guess a bit. I
suppose you transform your matrix to diagonal form, take the square root of
the eigenvalues, and then transform back, right? Then you can get a math
domain error if any eigenvalue becomes negative. First of course you must
make sure that no eigenvalue can be *really* negative (i.e. that your matrix
is positive definite). But you could still get very small negative
eigenvalues due to numerical errors in the calculation. If that's your
problem, it is safe in most cases to set those eigenvalues to zero (e.g. with
eigenvalues = Numeric.maximum(eigenvalues, 0.)). --
-----------------------------------------------------------------------------
-- Konrad Hinsen  | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique
Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron  | Fax: 
+33-2.38.63.15.17 45071 Orleans Cedex 2  | Deutsch/Esperanto/English/ France 
| Nederlands/Francais
-----------------------------------------------------------------------------
--


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




More information about the Python-list mailing list