Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem: Approximate complex values in Mathematica 8.0.1

10 views
Skip to first unread message

dr DanW

unread,
Apr 2, 2011, 3:52:38 AM4/2/11
to
As noted in this discussion:
https://groups.google.com/d/topic/comp.soft-sys.math.mathematica/K06SxXE72gM/discussion

The way Mathematica 8.0.1 handles approximate complex values has changed. In the related discussion, the change only seemed to effect the way approximate complex values were displayed

In[28]:=N[8*I]

Out[28]= 0. + 8. I

This is different from prior behavior, where the answer was 8. I

Now I have found a situation where it causes a package I wrote to fail. The simplest embodiment of the problem I can find is:

In[29]:= fnc = Interpolation[{{0, 0}, {2, 2}}, InterpolationOrder -> 1];

In[30]:= fnc[1. I/I]

Out[30]= InterpolatingFunction[][1. + 0. I]

The function does not evaluate because it is expecting a real input. I can't confirm that this is new to 8.0.1 (no old installations of Mathematica around), but I have never encountered this problem with my package before.

Remember, I have reduced the problem to triviality for this posting. In the actual application, the situation is much more complex and deeply buried, so even the obvious simple workarounds are not available to me without lots of work.

Daniel

dr DanW

unread,
Apr 2, 2011, 6:04:25 PM4/2/11
to
On a second try, the 1. I/I example worked. However, fnc[N[I]/I] does not. I did find a fix for my immediate problem, but my point is that the behavior of Mathematica has changed, and it is more insidious than the way approximate values are displayed.

Daniel

Bob Hanlon

unread,
Apr 2, 2011, 6:04:36 PM4/2/11
to

Your example works on my Mac's version 8.0.1

{$Version, $ReleaseNumber}

{"8.0 for Mac OS X x86 (64-bit) (February 23, 2011)", 1}

fnc = Interpolation[{{0, 0}, {2, 2}}, InterpolationOrder -> 1];

fnc[1. I/I]

1.


Bob Hanlon

---- dr DanW <dmaxw...@gmail.com> wrote:

=============

David Bailey

unread,
Apr 4, 2011, 6:32:13 AM4/4/11
to
Yet with 8.0.1, I find:

In[621]:= 1.*I/I //Head

Out[621]= Real

In[622]:= 1.+I/I //Head

Out[622]= Real

David Bailey
http://www.dbaileyconsultancy.co.uk

DrMajorBob

unread,
Apr 5, 2011, 6:42:23 AM4/5/11
to
Or, as a workaround, Wolfram could fix their code and send out a patch.

Bobby

On Mon, 04 Apr 2011 05:29:05 -0500, Bob Hanlon <han...@cox.net> wrote:

> As a workaround you could either Chop the input or output


>
> fnc = Interpolation[{{0, 0}, {2, 2}}, InterpolationOrder -> 1];
>

> fnc[Chop[N[I]/I]]
>
> 1.
>
> Chop[fnc[N[I]/I]]
>
> 1.
>
> or redefine the function definition to include Chop
>
> fnc = Interpolation[{{0, 0}, {2, 2}}, InterpolationOrder -> 1][Chop[#]]
> &;
>
> fnc[N[I]/I]
>
> 1.
>
> fnc = Chop[Interpolation[{{0, 0}, {2, 2}}, InterpolationOrder -> 1][#]]
> &;
>
> fnc[N[I]/I]


>
> 1.
>
>
> Bob Hanlon
>
> ---- dr DanW <dmaxw...@gmail.com> wrote:
>
> =============


--
DrMaj...@yahoo.com

0 new messages