numpy (matrix solver) - python vs. matlab

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu May 3 23:52:55 EDT 2012


On Thu, 03 May 2012 19:30:35 +0200, someone wrote:

> On 05/02/2012 11:45 PM, Russ P. wrote:
>> On May 2, 1:29 pm, someone<newsbo... at gmail.com>  wrote:
>>
>>>> If your data starts off with only 1 or 2 digits of accuracy, as in
>>>> your example, then the result is meaningless -- the accuracy will be
>>>> 2-2 digits, or 0 -- *no* digits in the answer can be trusted to be
>>>> accurate.
>>>
>>> I just solved a FEM eigenvalue problem where the condition number of
>>> the mass and stiffness matrices was something like 1e6... Result
>>> looked good to me... So I don't understand what you're saying about 10
>>> = 1 or 2 digits. I think my problem was accurate enough, though I
>>> don't know what error with 1e6 in condition number, I should expect.
>>> How did you arrive at 1 or 2 digits for cond(A)=10, if I may ask ?
>>
>> As Steven pointed out earlier, it all depends on the precision you are
>> dealing with. If you are just doing pure mathematical or numerical work
>> with no real-world measurement error, then a condition number of 1e6
>> may be fine. But you had better be using "double precision" (64- bit)
>> floating point numbers (which are the default in Python, of course).
>> Those have approximately 12 digits of precision, so you are in good
>> shape. Single-precision floats only have 6 or 7 digits of precision, so
>> you'd be in trouble there.
>>
>> For any practical engineering or scientific work, I'd say that a
>> condition number of 1e6 is very likely to be completely unacceptable.
> 
> So how do you explain that the natural frequencies from FEM (with
> condition number ~1e6) generally correlates really good with real
> measurements (within approx. 5%), at least for the first 3-4 natural
> frequencies?

I would counter your hand-waving ("correlates really good", "within 
approx 5%" of *what*?) with hand-waving of my own:

"Sure, that's exactly what I would expect!"

*wink*

By the way, if I didn't say so earlier, I'll say so now: the 
interpretation of "how bad the condition number is" will depend on the 
underlying physics and/or mathematics of the situation. The 
interpretation of loss of digits of precision is a general rule of thumb 
that holds in many diverse situations, not a rule of physics that cannot 
be broken in this universe.

If you have found a scenario where another interpretation of condition 
number applies, good for you. That doesn't change the fact that, under 
normal circumstances when trying to solve systems of linear equations, a 
condition number of 1e6 is likely to blow away *all* the accuracy in your 
measured data. (Very few physical measurements are accurate to more than 
six digits.)



-- 
Steven



More information about the Python-list mailing list