RE: latest on Mathematica 4 bug
- To: mathgroup at smc.vnet.net
- Subject: [mg19072] RE: latest on Mathematica 4 bug
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Thu, 5 Aug 1999 01:34:57 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Below I provide another example where the version 4.0 bug
noted by (slinger at signal.dera.gov.uk) causes problems.
In[1]:=
a1=Range[-2.5, -1.5, 1];
a2=Sqrt[a1]
Out[2]=
{0.+1.58114 I, 0.+1.22474 I}
In[3]:=
Part[a2,1]= 3.2+9.8*I;
a2
Out[4]=
{3.2+3.2 I, 0.+1.22474 I}
Notice the result above is wrong. As indicated earlier this seems to crop
up when you use Part and Set to change an element of a complex packed array.
There are many functions that can return a complex packed array, so beware.
Instead I would use ReplacePart as below.
In[5]:=
a2=Sqrt[a1];
ReplacePart[a2, 3.2+9.8*I, 1]
Out[6]=
{3.2+9.8 I, 0.+1.22474 I}
---------------------
Regards,
Ted Ersek