MathGroup Archive 2002

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

Search the Archive

= versus := and trying to speed up calculations

  • To: mathgroup at
  • Subject: [mg35410] = versus := and trying to speed up calculations
  • From: "Geoff Tims" <Geoff at>
  • Date: Thu, 11 Jul 2002 05:24:19 -0400 (EDT)
  • Organization: Southwest Texas State University
  • Sender: owner-wri-mathgroup at

I have the following function and it is called many many times in a program
I have written.  This is a bracket operator for a certain type of Lie
Algebra I am looking at and it must be called over and over to test whether
or not the Jacobi is actually 0 as it should be.  With very low numbers for
n, my program runs in a second or less.  If n is around 20+ or if the
coefficients are large, the program takes nearer a minute or two.  That's
not a long time, but I have a feeling that it's having to calculate the same
Bracket many times in the program and I'm hoping to get rid of that somehow.
However, I don't understand the differences between := and = enough.  I've
read the help files, but I don't understand the subtle differences such as I
can call

Bracket[stuff, something]:= somethingelse

more than once, but it doesn't seem as if I can use = more than once.

Bracket[a_.*e[i_], b_.*e[j_]] :=
      i + j > n, 0,
      i == j, 0,
      i == 1, a*b*e[j + 1],
      i == 2 && j == 3, 14a*b*e[7],
      i == 3 && j == 4, 0,
      i < j, -a*b*Bracket[e[i + 1], e[j - 1]] +
        Bracket[e[1], Bracket[e[i], e[j - 1]]],
      i > j, -a*b*Bracket[e[j], e[i]]
(* bilinear function *)
Bracket[mul_, expr_Plus] := Map[Bracket[mul, #] &, expr];
Bracket[expr_Plus, mul_] := Map[Bracket[#, mul] &, expr];
Bracket[0, x_] := 0
Bracket[x_, 0] := 0

Any help would be much appreciated.
Geoff Tims

  • Prev by Date: Re: ColorFunction TriangularSurfacePlot
  • Next by Date: Memory conserving Input of big Ascii tables ?
  • Previous by thread: Re: Math1mono problem in Latex
  • Next by thread: RE: = versus := and trying to speed up calculations