MathGroup Archive 1991

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Inner Bug ?

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: Re: Inner Bug ?
  • From: John Pfeifer <pfeifer at alw.nih.gov>
  • Date: Wed, 6 Mar 91 15:12:33 EST

<Pekka Janhunen writes:>
>The expression
>
>     Inner[f,{x,y,z},{1,2,3},List]/.f->List	(1)
>
>evaluates to {{x, 1}, {y, 2}, {z, 3}} as expected.
>But the seemingly equivalent expression
>
>	Inner[List,{x,y,z},{1,2,3},List]	(2)
>
>evaluates to {{x, y, z}, {1, 2, 3}}

First off, they are not equivalent expressions:

In[1]:= FullForm[Literal[Inner[List,{x,y,z},{1,2,3},List]]]

Out[1]//FullForm= Literal[Inner[List, List[x, y, z], List[1, 2, 3], List]]

In[2]:= FullForm[Literal[Inner[f,{x,y,z},{1,2,3},List] /. f->List]]

Out[2]//FullForm=

	Literal[ReplaceAll[Inner[f, List[x, y, z], List[1, 2, 3], List],

	Rule[f, List]]]

and so, in the second, the replace doesn't occur until _after_ the inner
product is computed. 

An expression equivalent to (1) is:
	Release[Hold[Inner[List,{x,y,z},{1,2,3},List]] /. f->List]

Upon further exploration it seems part of the difficulty is with your two
original lists having the head List and the first List:
	In[3]:=  Inner[List, Multipy[x, y, z], Multiply[1, 2, 3],List]

	Out[3]= {{x, 1}, {y, 2}, {z, 3}}

	In[4]:=  Inner[List, List[x, y, z], List[1, 2, 3],g]

	Out[4]= {g[x, y, z], g[1, 2, 3]}

Why?  I don't know.

#include <stdsig.h>

        John Pfeifer                    internet: pfeifer at alw.nih.gov

	"The most creaative and holy of men are always quite mad.
	 It is simply a social thing as to wether one is sane or
	 _insane_."				-The Madonna Vampira


  • Prev by Date: RE: Hypercard?
  • Next by Date: Re: Will these integrals work?
  • Previous by thread: Inner bug ?
  • Next by thread: Perplexing Puny Plot Print Problem.