MathGroup Archive 2002

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

Search the Archive

Simple question on whether function is defined or not

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35093] Simple question on whether function is defined or not
  • From: "Geoff Tims" <Geoff at swt.edu>
  • Date: Tue, 25 Jun 2002 03:39:29 -0400 (EDT)
  • Organization: Southwest Texas State University
  • Sender: owner-wri-mathgroup at wolfram.com

I am trying to make a function in mathematica.  I have two questions on this
and an answer to either would be wonderful.  For me, this looks complicated,
but for you it probably does not.  However, even if it does, my question, I
believe, is still simple and I only give what I have to clarify if that is
needed.

What I have so far should define the function completely as far as I can
tell except for one small problem.


n := 15
BracketDefine[a_.*e[i_], b_.*e[j_]] :=
    Which[
      i + j > n, 0,
      i == j, 0,
      i == 1, a*b*e[j + 1],
      i == 2 && j == 3, -a*b*e[5],
      i == 3 && j == 4, 2*a*b*e[7]
      ];
Bracket[mul_, expr_Plus] := Map[Bracket[mul, #] &, expr];
Bracket[expr_Plus, mul_] := Map[Bracket[#, mul] &, expr];

Bracket[e[i_], e[j_]] :=
  Which[
    ValueQ[BracketDefine[e[i], e[j]]], BracketDefine[e[i], e[j]],
    j - i == 2, -Bracket[e[1], Bracket[e[i], e[i + 1]]],
    True, -Bracket[e[i + 1], e[j - 1]] +
      Bracket[e[1], Bracket[e[i], e[j - 1]]]
    ]



I have BracketDefine[] and then Bracket[] which, in theory, takes values
from BracketDefine.  Well, it does take values from BracketDefine[], but
BracketDefine only has certain values of the entire function Bracket[].
That's why in the first condition and statement of Which, I see if it's
already defined in BracketDefine, and if so, it takes on that value.  That's
my problem.  Mathematica, at least with ValueQ, believes that BracketDefine
is defined for all values of i and j.  However, it's only defined for a few
values.  BracketDefine[e[3],e[5]] for instance returns nothing.  This brings
us to my questions

Is there another test which would return false if the function returns
nothing for certain values, but true if it returns something for other
values?

Or, to avoid the problem altogether, is there a way to just define the
entire Bracket function all at once?  I tried defining Bracket the way
BracketDefine is defined and then again defining Bracket the way Bracket is
now defined, but it seemed to lose all knowledge of the first definition.

Thanks
Geoff Tims




  • Prev by Date: Re: FourierTransform problem
  • Next by Date: RE: Large-scale enumerations and memory problems
  • Previous by thread: Re; FourierTransform problem
  • Next by thread: RE: Simple question on whether function is defined or not