MathGroup Archive 2005

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

Search the Archive

Wick like theorem and "symbolic" compilation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61062] Wick like theorem and "symbolic" compilation
  • From: "Alexander" <beginning.physst at mail.ru>
  • Date: Sun, 9 Oct 2005 01:35:14 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear MathGroup!

I wrote simple programm to perform "Wick" expanding.
Here is the code:

(*St1 - basic function to extract couples of fields from a given list*)

st1[x_] := If[Length[
    x] === 2, Wick[Sequence @@ x], Plus @@
      ReplaceList[List @@ (x), {e___, a_, c___,
      b_, d___} -> Wick[a, b] e c d]];

(* Some transformation rules for this function *)

st1[x_Wick y_] := x st1[y];
st1[a_ + b_] := st1[a] + st1[b];

(* Formatting rules *)

\!\(\(Format[Wick[x_, y_]] := \(x\ y\)\&^;\)\)

(* Final function *)

WickTheorem[x_] := Expand[Plus @@ FixedPointList[st1, x]] //. a_ +
          b_Integer c_ -> a + c;

Simple example, showing how it works:

In[6]:= WickTheorem[a b c d]

Out[6]:= \!\(\*FormBox[
  RowBox[{\(a\ b\ c\ d\), "+",
    RowBox[{"c", " ",
      FormBox[\(\(a\ b\)\&^\),
        "TraditionalForm"], " ", "d"}], "+",
    RowBox[{"b", " ",
      FormBox[\(\(a\ c\)\&^\),
        "TraditionalForm"], " ", "d"}], "+",
    RowBox[{"a", " ",
      FormBox[\(\(b\ c\)\&^\),
        "TraditionalForm"], " ", "d"}], "+",
    RowBox[{"b", " ", "c", " ",
      FormBox[\(\(a\ d\)\&^\),
        "TraditionalForm"]}], "+",
    RowBox[{
      FormBox[\(\(a\ d\)\&^\),
        "TraditionalForm"], " ",
      FormBox[\(\(b\ c\)\&^\),
        "TraditionalForm"]}], "+",
    RowBox[{"a", " ", "c", " ",
      FormBox[\(\(b\ d\)\&^\),
        "TraditionalForm"]}], "+",
    RowBox[{
      FormBox[\(\(a\ c\)\&^\),
        "TraditionalForm"], " ",
      FormBox[\(\(b\ d\)\&^\),
        "TraditionalForm"]}], "+",
    RowBox[{"a", " ", "b", " ",
      FormBox[\(\(c\ d\)\&^\),
        "TraditionalForm"]}], "+",
    RowBox[{
      FormBox[\(\(a\ b\)\&^\),
        "TraditionalForm"], " ",
      FormBox[\(\(c\ d\)\&^\),
        "TraditionalForm"]}]}], TraditionalForm]\)

Maybe there is more simple and elegant realization of this theorem than
my code ???

Second question is about optimization.

In current realization, on my Cleleron 1700 (with 128Mb of ram) using
Mathematica 5.1 for Windows, I have following timings:

In[7]:= WickTheorem[a b c d e f w t] // Timing // Print["Time = ", #[[
    1]], ", Length = ", Length[#[[2]]]] &
Out[7]:= Time = 10.688 Second, Length = 764

So, in final expression there was 764 terms and it takes ~10 seconds to
evaluate them. Input expression contains only 8 fields, with 9 fields
computation takes a relatively long time,about 600 seconds.

Why so long?
And what are the ways to reduce this time ?

I have tried to use CompileEvaluate from Experimental package, but this
doesn't reduce evaluation time greatly.

Resuming, second question sounds like:
Should I rewrite the program in more elegant and efficient way to
reduce
evaluation time or there is "symbolic" compilation technique to do
that?

Thanks for your help!

Alexander.


  • Prev by Date: Re: Stylesheets don't work unless imported.
  • Next by Date: RE: a very simple graphics problem
  • Previous by thread: Re: Import Limitations
  • Next by thread: Re: Wick like theorem and "symbolic" compilation