W
W
WTFAYD2018-05-29 16:52:55
C++ / C#
WTFAYD, 2018-05-29 16:52:55

How to compare the accuracy of an analytical algorithm and its software implementation?

Hello!
Let's say there is some analytical algorithm that calculates something. Just an arithmetic algorithm: standard arithmetic operations, trigonometric operations, nothing else. There is its software implementation in the C language - that is, the same thing, but implemented in the programming language.
This algorithm is my diploma, and one of the requirements is to analyze the accuracy of the software implementation of the algorithm relative to its analytical version. Can you please tell me if there are any differences in accuracy and what they depend on? In which direction to dig? As far as I understand, it depends on the bitness of the processor, the types used and the amount of their memory in the program, etc.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mercury13, 2018-05-29
@WTFAYD

Is there a subtraction of close numbers? Any cycles like high-order SLAEs and solving difurs? Alternating rows? If not, you can write that the contribution of machine arithmetic to the accuracy of the algorithm is negligible.
And if there is, you need to investigate who and how can multiply the rounding errors.
For the sake of experiment, you can also compare the results in float and double.
An example of an algorithm that is analytically stable but not computationally stable: e −x head-on for sufficiently large x. It is connected with the same subtraction of close numbers: the intermediate members of the series can be quite large, and as a result, 0.0 ... 01 comes out.
UPD. I found this book: info.alnam.ru/book_clm.php?id=26

G
Griboks, 2018-05-29
@Griboks

Perhaps you want to compare the errors of the results of the algorithm? It's a whole topic. First, it is necessary to find out what error the computer introduces. Then apply the appropriate systematic error correction method. If it was not possible to remove this error, it must be at least somehow estimated. Here is a standard example:

> 0.1*0.2
< 0.020000000000000004

It can be seen that the error is equal to 4e-19, i.e. 0.1*0.2=0.020000000000000000+-0.000000000000000004. Well, in short, it is clear that there is some kind of error.
Well, if you still need accuracy, then this is the number of decimal places before the first significant digit of the error. Or maybe not. There is no concept of accuracy as far as I know.

A
Andy_U, 2018-05-29
@Andy_U

Install the mpmath package, repeat your calculation with and without it (by specifying many, many characters) and compare the results. If the formulas are simple, it will be fast. And then, if there is a rake, look for specific reasons.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question