| |
 |
|
|
Science Forum Index » Math - Numerical Analysis Forum » numerical differentiation / choosing the step size
Page 1 of 1
|
| Author |
Message |
| Axel Vogt |
Posted: Sun Mar 11, 2007 4:02 pm |
|
|
|
Guest
|
I have a function with removable singularity (analytically, but that would
be quite laborious) in which I want to approximate the 1st derivative using
central differences.
How to find the step size for having a small approximation error? There is
a function 'fdiff' in the GSL library (their comments does not enlighten me),
but for my situation it does not give the 'best' step size (by powers of 10). |
|
|
| Back to top |
|
| Peter Spellucci |
Posted: Mon Mar 12, 2007 3:41 am |
|
|
|
Guest
|
In article <55j961F25edk9U1@mid.individual.net>,
Axel Vogt <&@axelvogt.de> writes:
Quote: I have a function with removable singularity (analytically, but that would
be quite laborious) in which I want to approximate the 1st derivative using
central differences.
How to find the step size for having a small approximation error? There is
a function 'fdiff' in the GSL library (their comments does not enlighten me),
but for my situation it does not give the 'best' step size (by powers of 10).
if you decide to use central differences (you mean second order symmetric
difference quotient) then the total error bound is
error in the function values/stepsize + stepsize^2 /6 * third derivative
of the function plus higher order terms,
hence the choice of the optimal stepsize depends on knowledge of the error
in the function evaluation plus an (maybe rough) estimate of the
third derivative. without this knowledge there is the rule of thumb
error in the function values ^ (1/3)
hth
peter |
|
|
| Back to top |
|
| Axel Vogt |
Posted: Mon Mar 12, 2007 2:48 pm |
|
|
|
Guest
|
Peter Spellucci wrote:
Quote: In article <55j961F25edk9U1@mid.individual.net>,
Axel Vogt <&@axelvogt.de> writes:
I have a function with removable singularity (analytically, but that would
be quite laborious) in which I want to approximate the 1st derivative using
central differences.
How to find the step size for having a small approximation error? There is
a function 'fdiff' in the GSL library (their comments does not enlighten me),
but for my situation it does not give the 'best' step size (by powers of 10).
if you decide to use central differences (you mean second order symmetric
difference quotient) then the total error bound is
error in the function values/stepsize + stepsize^2 /6 * third derivative
of the function plus higher order terms,
hence the choice of the optimal stepsize depends on knowledge of the error
in the function evaluation plus an (maybe rough) estimate of the
third derivative. without this knowledge there is the rule of thumb
error in the function values ^ (1/3)
hth
peter
Thank you, that helped to understand the stuff.
And I located my problem: if the steps size is too small, then the singularity
hits me on my nose, as close to it the function 'explodes'. |
|
|
| Back to top |
|
| Gert Van den Eynde |
Posted: Fri Mar 16, 2007 10:29 am |
|
|
|
Guest
|
Axel Vogt wrote:
Quote: Peter Spellucci wrote:
In article <55j961F25edk9U1@mid.individual.net>,
Axel Vogt <&@axelvogt.de> writes:
I have a function with removable singularity (analytically, but that
would
be quite laborious) in which I want to approximate the 1st
derivative using
central differences.
How to find the step size for having a small approximation error?
There is
a function 'fdiff' in the GSL library (their comments does not
enlighten me),
but for my situation it does not give the 'best' step size (by
powers of 10).
if you decide to use central differences (you mean second order
symmetric
difference quotient) then the total error bound is error in the
function values/stepsize + stepsize^2 /6 * third derivative
of the function plus higher order terms, hence the choice of the
optimal stepsize depends on knowledge of the error in the function
evaluation plus an (maybe rough) estimate of the third derivative.
without this knowledge there is the rule of thumb error in the
function values ^ (1/3) hth
peter
Thank you, that helped to understand the stuff.
And I located my problem: if the steps size is too small, then the
singularity
hits me on my nose, as close to it the function 'explodes'.
Axel,
You can improve your results by Richardson extrapolation (use the same
trick as Romberg quadrature). Start with a reasonable stepsize h, halve
it a couple of times and use all these results to build your
extrapolation table. Works quite well.
bye,
gert |
|
|
| Back to top |
|
| Axel Vogt |
Posted: Sat Mar 17, 2007 9:26 am |
|
|
|
Guest
|
Gert Van den Eynde wrote:
Quote: Axel Vogt wrote:
Peter Spellucci wrote:
In article <55j961F25edk9U1@mid.individual.net>,
Axel Vogt <&@axelvogt.de> writes:
I have a function with removable singularity (analytically, but that
would
be quite laborious) in which I want to approximate the 1st
derivative using
central differences.
How to find the step size for having a small approximation error?
There is
a function 'fdiff' in the GSL library (their comments does not
enlighten me),
but for my situation it does not give the 'best' step size (by
powers of 10).
if you decide to use central differences (you mean second order
symmetric
difference quotient) then the total error bound is error in the
function values/stepsize + stepsize^2 /6 * third derivative
of the function plus higher order terms, hence the choice of the
optimal stepsize depends on knowledge of the error in the function
evaluation plus an (maybe rough) estimate of the third derivative.
without this knowledge there is the rule of thumb error in the
function values ^ (1/3) hth
peter
Thank you, that helped to understand the stuff.
And I located my problem: if the steps size is too small, then the
singularity
hits me on my nose, as close to it the function 'explodes'.
Axel,
You can improve your results by Richardson extrapolation (use the same
trick as Romberg quadrature). Start with a reasonable stepsize h, halve
it a couple of times and use all these results to build your
extrapolation table. Works quite well.
bye,
gert
Gerd,
My problem is how to stop before the singularity kills reasonable
results, to be applied to something like 1/Gamma(x) + 1/Gamma(-x)
for x in IN and x < 12 (or so, but not in that precise form).
Currently I use a step size of 1/2^16 * sqrt(-1) and use 4 points
(which is a Richardson extrapolation I think), it works sufficiently
but I would like to have s.th. better.
Axel |
|
|
| Back to top |
|
| |
|
Page 1 of 1
All times are GMT - 5 Hours
The time now is Thu Jan 08, 2009 3:30 am
|
|