Error tolerance for testInvertPDMatrix()

9 views
Skip to first unread message

Tilmann

unread,
May 11, 2023, 11:37:18 AM5/11/23
to ode-users
demo_ode  has a test function testInvertPDMatrix(). When compiled with "double-precision" It uses a tolerance of 1e-10 to detect errors.

While playing around with it I very quickly found matrices that cause much larger errors, i.e. larger than 1e-6.

My question:
Does this indicate a problem with the math functions? After all, whoever wrote this probably expected errors to be much smaller.

I did not test single precision.
An example for a matrix causing larger errors can be found here: https://pastebin.com/raw/Vm6fqhPB

Best,
Til

Oleh Derevenko

unread,
May 11, 2023, 3:54:47 PM5/11/23
to ode-...@googlegroups.com

Hi Til,


I would not expect any solid reasoning in such cases (unless there is a clear note in documentation or commentaries within the code itself). Most likely, the error was chosen at random and a few checks were made that “it worked in general”.
If you did a more thorough testing and found errors about 1e-6 we just need to increase the constant. I would not worry about errors like that.

 

Oleh Derevenko

-- Skype with underscore

 

From: ode-...@googlegroups.com <ode-...@googlegroups.com> On Behalf Of Tilmann
Sent: Thursday, May 11, 2023 6:37 PM
To: ode-users <ode-...@googlegroups.com>
Subject: [ode-users] Error tolerance for testInvertPDMatrix()

 

Ви нечасто отримуєте електронні листи від tilma...@gmail.com. Дізнайтеся, чому це важливо




This e-mail may contain privileged and confidential information. If you are not the intended recipient, be aware that any use, disclosure, copying or distribution of this e-mail or any attachments is prohibited. If you have received this e-mail in error, please notify us immediately by returning it to the sender and delete this copy from your system. Thank you.

Oleh Derevenko

unread,
May 11, 2023, 6:16:36 PM5/11/23
to ode-...@googlegroups.com

Hi again.

 

So, I checked the code. The conclusion is “you can get arbitrarily large error as the matrix size grows”. And this is natural for computations with limited precision.

 

Next, in the ODE itself the function is only used in dBodySetMass and there it is inverting a 3x3 matrix. So, nothing to worry about.

 

If the function is needed for external logic in user application we should not decide for that application. The external application should handle its extremely large matrix cases on its own.

Basically, there are only two approaches to increasing accuracy: using larger precision floating point numbers (like Quad Double/Double Double) or ordering additions so that addends had binary exponents as close as possible (I have a class for this in my work project). Both approaches require extra computational complexity the ODE does not need by itself.

 

Oleh Derevenko

-- Skype with underscore

 

From: ode-...@googlegroups.com <ode-...@googlegroups.com> On Behalf Of Tilmann
Sent: Thursday, May 11, 2023 6:37 PM
To: ode-users <ode-...@googlegroups.com>
Subject: [ode-users] Error tolerance for testInvertPDMatrix()

 

Ви нечасто отримуєте електронні листи від tilma...@gmail.com. Дізнайтеся, чому це важливо

demo_ode  has a test function testInvertPDMatrix(). When compiled with "double-precision" It uses a tolerance of 1e-10 to detect errors.

--
You received this message because you are subscribed to the Google Groups "ode-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ode-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ode-users/81000eec-90dc-4403-bc34-c0a2cf10b472n%40googlegroups.com.

Tilmann

unread,
May 12, 2023, 4:20:51 AM5/12/23
to ode-users
Hi Oleh,

thanks for looking into this.

As you explained, this really looks like it's not a problem.

Thanks again,
Til
Reply all
Reply to author
Forward
0 new messages