Re: inert wrapping function
- To: mathgroup at smc.vnet.net
- Subject: [mg5628] Re: [mg5592] inert wrapping function
- From: daiyanh at mindspring.com
- Date: Wed, 1 Jan 1997 21:04:56 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Hello,
This fa[] looks like a good ole functional in the functional analysis.
Went thru the examples, and me too experienced infinite recursions in
your defs. Looks like fa[] gets eval'ed everytime it's encountered as
the given pattern. That pattern is in the def itself. "Hold"'ing prevents
this. I found some workaround as follows:
fa[arg_Plus]:=fa/@arg;
fa[arg_Times]:=fa/@arg;
fa[fa[arg_]]:=fa[arg];
With the init
fa[a]=a;fa[b]=b;fa[c]=c;
I get
fa[a fa[A] + b fa[B] + c fa[C] ] ==>> a fa[A] + b fa[B] + c fa[C]
and
fa[a fa[A] + b fa[
fa[ a fa[A] + b fa[B] + c fa[C] ]
]] ==>> a fa[A] + b (a fa[A] + b fa[B] + c fa[C])
One last def is needed for the last example:
fa[Power[x_,y_]]:=fa[x]^y;
And an additional init:
fa[d]=d;fa[e]=e;fa[f]=f;fa[g]=g;fa[h]=h;fa[i]=i;fa[j]=j;fa[k]=k;fa[l]=l;
Then I get the answer to your example (allow me to cut out the whole
middle stuff):
$?#%&@* =
a fa[fA] b fa[fB]
{4.38333 Second, --------------------- + --------------------- +
a + b + c + d + e + f a + b + c + d + e + f
d fa[fD] e fa[fE] f fa[fF]
--------------------- + --------------------- + --------------------- +
a + b + c + d + e + f a + b + c + d + e + f a + b + c + d + e + f
g fa[fG] h fa[fH]
(c (--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
i fa[fI] k fa[fK]
--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
l fa[fL]
--------------------- +
g + h + i + j + k + l
g fa[fG] h fa[fH]
(j (--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
i fa[fI] k fa[fK]
--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
l fa[fL]
--------------------- +
g + h + i + j + k + l
g fa[fG] h fa[fH]
(j (--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
i fa[fI] k fa[fK]
--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
l fa[fL]
--------------------- +
g + h + i + j + k + l
g fa[fG] h fa[fH]
(j (--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
i fa[fI] j fa[fJ]
--------------------- + --------------------- +
g + h + i + j + k + l g + h + i + j + k + l
k fa[fK] l fa[fL]
--------------------- + ---------------------)) /
g + h + i + j + k + l g + h + i + j + k + l
(g + h + i + j + k + l))) / (g + h + i + j + k + l))) /
(g + h + i + j + k + l))) / (a + b + c + d + e + f)}
?
Note that _fa head collecting didn't work. The above representation
happens to be more compact than the fully collected one. Also pls
don't pay any att'n to the timing: my Mac is slow.
In the end, I believe that the explicit def's are needed for dealing
with the coefficients. If they are numbers, then one statement def
fa[arg_]:=arg /; NumberQ[arg]
will do.
Daitaro Hagihara