Re: finite-differencing and machine errors







On Fri, 26 May 2006, Toby Kelsey wrote:
On a digital computer you are already committed to representation error for the
inputs f(x).

Assuming |x| >> |h| and f(x+h) and f(x-h) are similar in magnitude,
then the subtraction
f(x+h) - f(x-h)
will not lose any more precision.

If the representation error of 1/(2h) is e, then the error of
(f(x+h)-f(x-h))/(2h) is approximately (delta_f)*e
while the error of
f(x+h)/(2h) - f(x-h)/(2h)
is larger because although the error 'e' tends the same way for both terms (and
thus tends to cancel), you lose extra precision because you are differencing
two similar larger numbers (assuming |1/(2h)| > 1).

Thanks for your comments.
My question was motivated by the desire to improve my routines for the
solution of some differential equations by FD methods. Taking, as an
example, the following ODE:

F(x, u, du/dx, d2u/dx2) = 0

we normally replace the derivatives by FD quotients, which yields
a nonlinear algebraic system, which in turn can be solved by the Newton
method. This generally requires the computation of the quotients such as

[u(x+h) - u(x-h)]/(2*h) for first derivatives, and similar for
second derivatives,

as well as the coefficients standing in these quotients at the discrete
solutions, i.e.

1/(2*h) and -1/(2*h) etc.

The coefficients are needed for calculating the Jacobian matrix of the AE
set.

From your messages I understand that the quotients are best calculated
directly as written above. However, the coefficients are still needed.
I cannot imagine how to derive the Jacobian matrix without
computing them. Hence, I thought that I might possibly re-use the
coefficients for computing the quotients, but following your advice
I see this is not the best idea. Am I correct, or there are better
ways to proceed? I stress that the above is a simple example. In practice
I work with time-dependent convection-reaction-diffusion PDEs, so that
there are even fewer possibilities for any scaling of the Jacobian matrix
that might reduce machine errors (please don't point me to upwind
differencing, it is another story; I am asking about MACHINE ERRORS).

L.B.

*-------------------------------------------------------------------*
| Dr. Leslaw Bieniasz, |
| Institute of Physical Chemistry of the Polish Academy of Sciences,|
| Department of Electrochemical Oxidation of Gaseous Fuels, |
| ul. Zagrody 13, 30-318 Cracow, Poland. |
| tel./fax: +48 (12) 266-03-41 |
| E-mail: nbbienia@xxxxxxxxxxxxx |
*-------------------------------------------------------------------*
| Interested in Computational Electrochemistry? |
| Visit my web site: http://www.cyf-kr.edu.pl/~nbbienia |
*-------------------------------------------------------------------*
.



Relevant Pages

  • Re: finite-differencing and machine errors
    ... This generally requires the computation of the quotients such as ... The coefficients are needed for calculating the Jacobian matrix of the AE ... _define_ the function values which should be computed and here the numerical errors ...
    (sci.math.num-analysis)
  • Re: interpolation accuracy, oversampling and fractional interpolation
    ... interpolation between entries of that table. ... in a practical system with fixed precision ... there is a number of phases beyond which the coefficients won't change ... hypothetical impulse response) that will look more like a windowed sinc ...
    (comp.dsp)
  • Re: computing rational values of cos(x)
    ... so if the coefficients are rational, ... though operations are being carried out with integer precision. ... filters with very low stop-band attenuation, the quantization severely ...
    (sci.math)
  • Re: Fixed Point IIR implementation
    ... precision) and *highly* unrecommended for fixed-point (saturation ... > are the boundaries of the sserie... ... > Point format for my coefficients.. ...
    (comp.dsp)
  • Re: Are there multiple roots?
    ... via the Winding Number theorem and simply Cauchy integrals? ... double precision a winding number for an appropriately chosen ... at most 20 roots. ... coefficients can't be accurately represented in the precision ...
    (sci.math.num-analysis)