[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] [bug #39713] roots/secant.c "derivative value is not finite" f
From: |
Max |
Subject: |
[Bug-gsl] [bug #39713] roots/secant.c "derivative value is not finite" for a good guess |
Date: |
Wed, 07 Aug 2013 03:52:27 +0000 |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:22.0) Gecko/20100101 Firefox/22.0 |
URL:
<http://savannah.gnu.org/bugs/?39713>
Summary: roots/secant.c "derivative value is not finite" for
a good guess
Project: GNU Scientific Library
Submitted by: nikulin
Submitted on: Срд 07 Авг 2013 03:52:26
Category: Runtime error
Severity: 3 - Normal
Operating System: Linux
Status: None
Assigned to: None
Open/Closed: Open
Release: bzr
Discussion Lock: Any
_______________________________________________________
Details:
Implementation of the secant method for root finding fails
for an (almost) linear function. If at a certain iteration
the root approximation is within DBL_EPSILON, then
the next iteration fails with "derivative value is not finite"
error. Actually it means that a good approximation has been found.
It may be tested with the following function
(full program source is attached as well)
double test_f (double x, void *params)
{
return -M_PI*x + M_E;
}
double test_df (double x, void *params)
{
return -M_PI;
}
# i x_i-r x_i - x_p status
0 0.000e+00 -2.347e-01 -2
gsl: secant.c:104: ERROR: derivative value is not finite
Default GSL error handler invoked.
I think that an addition test should be added and
derivative should be updated only if the step is
significantly greater then DBL_EPSILON. Otherwise
rounding error or even zero division may be the issue.
The proposed patch is attached. When it is applied
the programs works correctly.
# i x_i-r x_i - x_p status
0 0.000e+00 -2.347e-01 -2
1 0.000e+00 0.000e+00 0
# Converged
# f(x_i) = 2.9707e-17
It seems that all 82 tests supplied in roots directory
are passed correctly with this patch.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Срд 07 Авг 2013 03:52:26 Name: gsl-secant.c Size: 2kB By:
nikulin
A program to demonstrate the issue and the patch
<http://savannah.gnu.org/bugs/download.php?file_id=28779>
-------------------------------------------------------
Date: Срд 07 Авг 2013 03:52:26 Name: gsl-roots-secant.patch Size: 795B
By: nikulin
A program to demonstrate the issue and the patch
<http://savannah.gnu.org/bugs/download.php?file_id=28780>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?39713>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Bug-gsl] [bug #39713] roots/secant.c "derivative value is not finite" for a good guess,
Max <=