# FORM

Here are some tips for the algebraic manipulation program of Jos Vermaseren.

Version 2 is well documented in the book:

``Symbolic manipulation with FORM''
J.A.M. Vermaseren
CAN, Computer Algebra Nederland 1991

Version 3 exists as a beta version and has many extremely desirable features.
Don't drool on your fine Persion carpets.....

Visit Jos' homepage for more details.

My claim is that ANY purely algebraic problem in theoretical physics can be
solved using this package (at the cost of some hair-loss). In particular, the type
thinking required is usually very similar to that needed to solve the problem by
hand but the size of tasks completeable in real time is immensely enhanced.

# Tips and Pits

Matching Squares, The Sorted Repeat

Here's a selection of my favourite hints... Many of these are directly due to Jos!

## 1. Matching Squares

Watch out for this simple feature:

FORM version 3.-1(Apr  2 1999). Run at: Mon May 10 13:46:38 1999
symbol a,b;

L test = a^4;

Id a?*b?=1;

print +s;

.end

Time =       0.00 sec    Generated terms =          1
test        Terms in output =          1
Bytes used      =         18

test =
+ a^4
;

Which isn't exactly what we want. Workaround solution:

FORM version 3.-1(Apr  2 1999). Run at: Mon May 10 16:42:00 1999
symbol a,b;
cfunction f;

L test = a^4;

Id a?=f(a);

Id f(a?)*f(b?)=1;

print +s;

.end

Time =       0.00 sec    Generated terms =          1
test        Terms in output =          1
Bytes used      =         10

test =
+ 1
;

This may seem all pretty trivial, but now imagine you want to implement

Id U?.W*V?.W=W.W;

which won't see U.W^2. The statement

Id U=f(?);

will then save the day since it replaces the vector U(mu) by the function f(mu)
introducing dummy indices where necessary.

## 2. The Sorted Repeat

The ``sorted repeat''. The main idea of sorting is to do it whenever you think
your expression is going to collapse. However, imagine you are running a repeat
loop and you think the thing should simplify somewhere in there. Then you
can try the following:

FORM version 3.-1(Apr  2 1999). Run at: Tue May 11 22:37:14 1999
S x;

#define max"160"

L test=x^`max';

#do i=1,1

Id x^2=x+1;

If (count(x,1)>1) redefine i"0";

.sort

Time =       0.02 sec    Generated terms =         81
test        Terms in output =         81
Bytes used      =       1902

#enddo

Time =       0.19 sec    Generated terms =       1681
test        Terms in output =         41
Bytes used      =       1218

Time =       0.21 sec    Generated terms =        441
test        Terms in output =         21
Bytes used      =        650

Time =       0.22 sec    Generated terms =        121
test        Terms in output =         11
Bytes used      =        354

Time =       0.22 sec    Generated terms =         36
test        Terms in output =          6
Bytes used      =        202

Time =       0.22 sec    Generated terms =         12
test        Terms in output =          4
Bytes used      =        134

Time =       0.22 sec    Generated terms =          6
test        Terms in output =          3
Bytes used      =         98

Time =       0.22 sec    Generated terms =          4
test        Terms in output =          2
Bytes used      =         74

print;

.sort

Time =       0.22 sec    Generated terms =          2
test        Terms in output =          2
Bytes used      =         74

test =
757791618667731139247631372100066 + 1226132595394188293000174702095995*x
;

drop test;

L test1=x^`max';

repeat Id x^2=x+1;

print;

.end

Time =       0.70 sec    Generated terms =      20000
test1      1 Terms left      =          2
Bytes used      =         54

Time =       1.19 sec    Generated terms =      38784
test1      1 Terms left      =          4
Bytes used      =        112

Time =       1.66 sec    Generated terms =      55708
test1      1 Terms left      =          6
Bytes used      =        178

Time =       2.10 sec    Generated terms =      71278
test1      1 Terms left      =          8
Bytes used      =        244

Time =       2.52 sec    Generated terms =      85718
test1      1 Terms left      =         10
Bytes used      =        318

Time =       2.93 sec    Generated terms =      99501
test1      1 Terms left      =         12
Bytes used      =        392

Time =       3.34 sec    Generated terms =     112958
test1      1 Terms left      =         14
Bytes used      =        466

Time =       3.44 sec    Generated terms =     115779
test1      1 Terms left      =         16
Bytes used      =        540

Time =       3.44 sec    Generated terms =     115779
test1        Terms in output =          2
Bytes used      =         74

test1 =
757791618667731139247631372100066 + 1226132595394188293000174702095995*x
;

Apologies for all the statistics, but I guess they were the main point. Note that (re)define can be used to (re)set preprocessor variables.