In what order should I perform the four rules of operation to generate calculation errors/propagate

Asked 5 months ago, Updated 5 months ago, 13 views

The problem we have now is an operation that consists only of addition, multiplication, and division.

double c,m,d1,d2;
/* value each*/

That's the formula.Throw this expression to Maxima

double x=(c*m+0.5*(d1+1.0/d2)/(c+1.0);

will be transformed into .Organizing the expressions


appears in

If you type it as it is, you won't get the formula wrong
Considering the calculation error, if the formula is modified,

Is the error due to division and multiplication large?
Is the error due to addition and subtraction large?

I felt it was necessary to think
Which operator is less likely to cause calculation errors?

Additional information

The book "Common sense of numerical calculation" lists examples of how errors can be avoided by expression deformation, but does not specifically describe how the deformation of the expression leads to reduction of errors (especially for division multiplication).
Instead of expecting a more detailed explanation of multiple-length operations and addition algorithms,
This question asks how it would be desirable to modify it if it could be mitigated by formula transformation.

c++ algorithm

2022-09-30 11:06

7 Answers

I think it's good to study terms related to calculation errors such as rounding error, missing digits, and missing information in your own way.

"As for the book, I think the calculation error was detailed in ""common sense of numerical calculation"" by Masao Iri and others."

Also, in the web documentation, the here page is relatively well organized

2022-09-30 11:06

In terms of calculation errors, the four operations are not very relevant (although multiplication and division certainly have a greater impact).
It depends on how many digits the error can be allowed.

Eventually, using the double type will result in errors.
double value=0.1;
Even does not have strictly 0.1 (because it cannot be expressed in binary).

I think it's common to change the scale depending on how many digits you want to guarantee and calculate using an integer type.

For example, if you want to guarantee up to four decimal places,
0.1 is treated as 1000, dividing 10000 into the final operation results, and then substituting the double type for the first time.

Does the Maxima big float take into account this area?

2022-09-30 11:06

For your reference, here is the next page on computational calculations.

If the formula is programmed as it is, the computer's real-number valid number is infinite, it should produce the correct result, but it is actually finite, so there is an error occurs.This is called a round error.
The problem of floating-point rounding error appears in many places, but the accuracy is especially reduced when subtracting a similar number (or subtracting a number whose absolute value is close and whose sign is opposite).

In the financial sector, even a small calculation error can be a big problem, so many things have been devised.

2022-09-30 11:06

Error but digit loss will only result in addition and subtraction.
It is only when the absolute value of a±b is many digits closer to zero than the absolute value of a and b.
So, for example, if c,m,d1,d2 above are all positive, none of the three above will result in digits.

2022-09-30 11:06

For this expression only,
c is supposed to be divided by c+1 and when calculating this c+1 you must align the digits, that is, the floating-point exponents, and the valid digits are lost.
The farther away c is from 1, the less significant the effective digits are.
It's not a good expression for computing on a computer.If you have another solution, why don't you try it?

2022-09-30 11:06

If you don't need a strict warranty, you can change the formula

  • Adding and subtracting large differences in scale
  • Divide Close Values
  • double four operations

Consider reducing the number of .

2022-09-30 11:06

Understanding How Deforming an Expression Can Reduce Errors

Which operator is less likely to cause calculation errors?

The formula transformation used in "common sense of numerical calculation" is done by intentionally transforming a variable called error compensation (compensating errors) to appear more than once.

Therefore, it is more difficult to make errors in more conditions than in less conditions.

Finally, if you choose one of the examples, c appears twice and d2 appears three times.


Is the error due to division and multiplication large?
Is the error due to addition and subtraction large?

I can't tell which one is larger, but you can usually estimate the relative error in division and multiplication by adding up the absolute error in addition and subtraction.

2022-09-30 11:06

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.