## pygsl-discuss

 [pygsl-discuss] Ufuncs problem From: - 2008-10-24 13:31:38 ``` ----- Messaggio inoltrato da mariagabriella.tana@... ----- Data: Fri, 24 Oct 2008 15:14:14 +0200 Da: mariagabriella.tana@... Rispondi-A:mariagabriella.tana@... Oggetto: Ufuncs problem A: pygsl-discuss@... Dear Pygsl users and developers, I'm a new user of pygsl and I'm a beginner in Python programming. I'm interested in the use of "root finding" algorithms to solve equations containing "special functions" (sf.so) such as "digamma" and "trigamma" functions. Because of the equivalent of "gsl_sf_psi_int" is "psi(...)", in pygsl.testing._ufuncs, I have written the following script like the python equivalent of the C example found in the GSL Reference document: ############################################################################# from pygsl.testing import _ufuncs from pygsl import roots, errno import pygsl._numobj as numx def digamma(x,costante): c=costante tmp =_ufuncs.sf_psi(x)-c return tmp c=3 ##def run_fsolver(val): mysys = roots.gsl_function(digamma, (c)) solver = roots.brent(mysys) #solver = roots.bisection(mysys) #solver = roots.falsepos(mysys) solver.set(0.0, 5.0) iter = 0 ## r_expected = numx.sqrt(5.0) print "# Using solver ", solver.name() print "# %5s [%9s %9s] %9s %10s %9s" % ("iter", "upper", "lower", "root", "err", "err(est)") for iter in range(100): status = solver.iterate() x_lo = solver.x_lower() x_up = solver.x_upper() status = roots.test_interval(x_lo, x_up, 0, 0.001) r = solver.root() if status == errno.GSL_SUCCESS: print "# Convereged :" print " %5d [%.7f %.7f] %.7f % .6f % .6f" %(iter, x_lo, x_up, r, x_up - x_lo) if status == errno.GSL_SUCCESS: break else: raise ValueError, "Exeeded maximum number of iterations!" ############################################################################# When the script is executed, a "Segmentation Fault" error occurs. I would ask you if you help me to understand the problem. Thnks in advance for your time and help. Best wishes. Gabriella ----- Fine del messaggio inoltrato ----- ```
 [pygsl-discuss] Ufuncs problem From: - 2008-10-24 15:45:06 ```Dear Pygsl users and developers, I'm a new user of pygsl and I'm a beginner in Python programming. I'm interested in the use of "root finding" algorithms to solve equations containing "special functions" (sf.so) such as "digamma" and "trigamma" functions. Because of the equivalent of "gsl_sf_psi_int" is "psi(...)", in pygsl.testing._ufuncs, I have written the following script like the python equivalent of the C example found in the GSL Reference document: ############################################################################# from pygsl.testing import _ufuncs from pygsl import roots, errno import pygsl._numobj as numx def digamma(x,costante): c=costante tmp =_ufuncs.sf_psi(x)-c return tmp c=3 ##def run_fsolver(val): mysys = roots.gsl_function(digamma, (c)) solver = roots.brent(mysys) #solver = roots.bisection(mysys) #solver = roots.falsepos(mysys) solver.set(0.0, 5.0) iter = 0 ## r_expected = numx.sqrt(5.0) print "# Using solver ", solver.name() print "# %5s [%9s %9s] %9s %10s %9s" % ("iter", "upper", "lower", "root", "err", "err(est)") for iter in range(100): status = solver.iterate() x_lo = solver.x_lower() x_up = solver.x_upper() status = roots.test_interval(x_lo, x_up, 0, 0.001) r = solver.root() if status == errno.GSL_SUCCESS: print "# Convereged :" print " %5d [%.7f %.7f] %.7f % .6f % .6f" %(iter, x_lo, x_up, r, x_up - x_lo) if status == errno.GSL_SUCCESS: break else: raise ValueError, "Exeeded maximum number of iterations!" ############################################################################# When the script is executed, a "Segmentation Fault" error occurs. I would ask you if you help me to understand the problem. Thnks in advance for your time and help. Best wishes. Gabriella ```
 Re: [pygsl-discuss] Ufuncs problem From: Pierre SCHNIZER - 2008-10-24 16:31:50 ```mariagabriella.tana@... wrote: > I downloaded the last version of pygsl, 0.9.3. > Thank you for your reply. > It's a bug in pygsl. But its triggered by a domain error in the function gsl_sf_psi. Then the standard translation from gsl to python errors fails. I will look to that during the week end. Pierre -- +---------------------------------------------------------------------+ Pierre Schnizer Telephon : +49 6159 71 1557 Fax : +49 6159 71 2043 GSI Helmholtzzentrum für Schwerionenforschung GmbH Planckstraße 1 D-64291 Darmstadt http://www.gsi.de Gesellschaft mit beschränkter Haftung Sitz der Gesellschaft: Darmstadt Handelsregister: Amtsgericht Darmstadt, HRB 1528 Geschäftsführer: Professor Dr. Horst Stöcker Vorsitzende des Aufsichtsrates: Dr. Beatrix Vierkorn-Rudolph Stellvertreter: Ministerialdirigent Dr. Rolf Bernhardt +---------------------------------------------------------------------+ ```