# [SciPy-user] segfault in scipy.optimize.leastsq

Nils Wagner nwagner at iam.uni-stuttgart.de
Thu Aug 3 08:34:42 CDT 2006

```Jelle Feringa / EZCT Architecture & Design Research wrote:
> Any chance you have an older AMD processor perhaps not supporting SSE(3?)?
>
>
In case of a segfault I suggest to use gdb to track down the problem.

Nils

>
> -----Original Message-----
> From: scipy-user-bounces at scipy.org [mailto:scipy-user-bounces at scipy.org] On
> Behalf Of basvandijk at home.nl
> Sent: Thursday, August 03, 2006 3:12 PM
> To: scipy-user at scipy.org
> Subject: [SciPy-user] segfault in scipy.optimize.leastsq
>
> Hello,
>
> When running the following example from
> http://www.tau.ac.il/~kineret/amit/scipy_tutorial I get an segmentationfault
> in leastsq:
>
> --------------------------
> from scipy import *
> from numpy import *
>
> x = arange(0,6e-2,6e-2/30)
> A,k,theta = 10, 1.0/3e-2, pi/6s
> y_true = A*sin(2*pi*k*x+theta)
> y_meas = y_true + 2*randn(len(x))
>
> def residuals(p, y, x):
>     A,k,theta = p
>     err = y-A*sin(2*pi*k*x+theta)
>     return err
>
> def peval(x, p):
>     return p[0]*sin(2*pi*p[1]*x+p[2])
>
> p0 = [8, 1/2.3e-2, pi/3]
> print array(p0)
>
> from scipy.optimize import leastsq
> plsq = leastsq(residuals, p0, args=(y_meas, x))
> print plsq[0]
>
> print array([A, k, theta])
> --------------------------
>
> Note that
> C:\Python24\Lib\site-packages\scipy\optimize\tests\test_optimize.py also
> gives an error.
>
> I'm running Python 2.4.3, Scipy 0.5.0 and numpy 1.0b1.
>
> What can be the problem?
>
> Greetings,
>
> Bas van Dijk
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>

```