[Numpy-discussion] Re: indexing problem
Ryan Krauss
ryanlists at gmail.com
Mon Feb 13 09:54:02 CST 2006
This may only be a problem for ridiculously large numbers. I actually
meant to be dealing with these values:
In [75]: d
Out[75]:
array([ 246.74011003, 986.96044011, 2220.66099025, 3947.84176044,
6168.50275068, 8882.64396098, 12090.26539133, 15791.36704174,
19985.94891221, 24674.01100272])
In [76]: s=d[-1]*1.0j
In [77]: s
Out[77]: 24674.011002723393j
In [78]: type(s)
Out[78]: <type 'complex128scalar'>
In [79]: s**2
Out[79]: (-608806818.96251547+7.4554869875188623e-08j)
So perhaps the previous difference of 26 orders of magnitude really
did mean that the imaginary part was negligibly small, that just got
obscured by the fact that the real part was order 1e+135.
On 2/13/06, Ryan Krauss <ryanlists at gmail.com> wrote:
> I am having a problem with indexing an array and not getting the
> expected scalar behavior for complex128scalar:
>
> In [44]: c
> Out[44]:
> array([ 3.31781200e+06, 2.20157529e+13, 1.46088259e+20,
> 9.69386754e+26, 6.43248601e+33, 4.26835585e+40,
> 2.83232045e+47, 1.87942136e+54, 1.24711335e+61,
> 8.27537526e+67])
>
> In [45]: s=c[-1]*1.0j
>
> In [46]: type(s)
> Out[46]: <type 'complex128scalar'>
>
> In [47]: s**2
> Out[47]: (-6.848183561893313e+135+8.3863291020365108e+119j)
>
> In [48]: s=8.27537526e+67*1.0j
>
> In [49]: type(s)
> Out[49]: <type 'complex'>
>
> In [50]: s**2
> Out[50]: (-6.8481835693820068e+135+0j)
>
> Why does result 47 have a non-zero imaginary part?
>
> Ryan
>
More information about the Numpy-discussion
mailing list