[SciPy-user] Using scipy specfunc in integration

Anne Archibald peridot.faceted@gmail....
Fri Jun 13 18:36:08 CDT 2008


2008/6/13 Robert Kern <robert.kern@gmail.com>:
> On Fri, Jun 13, 2008 at 09:21, Neal Becker <ndbecker2@gmail.com> wrote:
>> Any ideas on this?
>> from scipy.special import erf
>> from math import exp, tan
>> def cot(x):
>>    return 1/tan(x)
>>
>> N = 8
>> esnodB = 10
>> Rd = 10**(.1 * esnodB)
>>
>> def F (y):
>>    return exp (-(y**2)) * erf (y * cot (pi/N))
>>
>>
>> Pe = float(N-1)/float(N) - 0.5 * erf (sqrt (Rd * sin (pi/N))) - 1/(sqrt(pi))
>> * quadrature(F, 0, sqrt(Rd) * sin (pi/N))[0]
>> TypeError: only length-1 arrays can be converted to Python scalars
>>
>> It seems to be complaining about erf.
>> erf
>> Out[33]: <ufunc 'erf'>
>
> I think it's complaining about exp(), actually. quadrature() is going
> to pass arrays to F(), not scalars.

Specifically, math.exp and math.tan do not accept vector arguments;
don't use them. Use numpy.exp and numpy.tan instead.

Anne


More information about the SciPy-user mailing list