2
$\begingroup$

I am doing a calculation where I try to simplify a very complicated complex function. I did this step by step and I checked that the numerical values that the function gets for certain values of the variables that it depends on are equal at each step. After some significant simplification, I wanted to check that the initial and final results give the same answers. The function is purely imaginary, so I did not expect any real part.
The initial numerical evaluation of the function for a set of particular value for its variables returned $1.02798*10^{-11} + 187628i$. The same set values for the variables returned the following for the final form of the function: $4.76837*10^{-7} + 187628i$.

As you can see, they agree on the imaginary part and both give approximately zero for the real part, although their real parts differ by four orders of magnitude. So, finally, I want to ask how much is the acceptable error that we can expect when doing a numerical evaluation and how much is the acceptable error that we should (at most) get when simplifying a function?

Of course, I am aware that this is pretty general and that the error depends on the simplifications done and how complicated an expression is, but I wanted to know whether or not there are some rules of thumb for these things.

$\endgroup$

closed as too broad by Daniel Lichtblau, Mariusz Iwaniuk, Henrik Schumacher, Michael E2, AccidentalFourierTransform Aug 19 '18 at 15:55

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ How much does the real part change when the function is evaluated with higher precision numbers? It may just be that some of the intermediate steps drop precision more quickly with machine-precision numbers than they did in the original expression. As I understand, the precision calculations used with machine-precision arithmetic are somewhat looser than with arbitrary-precision arithmetic. $\endgroup$ – eyorble Aug 19 '18 at 0:03
  • 5
    $\begingroup$ I think this is effectively impossible to answer. There is no specific example to examine, and no clear way to know what changes in form occurred that might amplify the error. About all I can suggest is that reverse engineering the change in form might give some way to compute a condition number for the transformation, which in turn can be used to estimate error amplification. Possibly redoing it with bignums, using significance arithmetic, might automate this or at least suggest the conditioning by indicating how many correct digits were lost. $\endgroup$ – Daniel Lichtblau Aug 19 '18 at 1:40
  • 1
    $\begingroup$ You probably want to use as a measure of error $|z_1-z_2|/|z_1|$, if the two numbers are close to each other, unless both approximate zero. In the given example, that gives you more than 11 digits of agreement. Whether that is good enough for an application depends on the application. Physicists usually require more than engineers. In function approximation, one seeks to understand the relationship between efficiency and accuracy. $\endgroup$ – Michael E2 Aug 19 '18 at 1:41
  • 1
    $\begingroup$ It is necessary to control the computational process using $MaxPrecision, $MinPrecision, rather than relying on automatic options. $\endgroup$ – Alex Trounev Aug 19 '18 at 3:46