REDUCE2(15-SEP-72 (UM 1-JUNE-73)) ...
COMMENT SOME EXAMPLES OF THE F O R STATEMENT;
COMMENT SUMMING THE SQUARES OF THE EVEN POSITIVE INTEGERS THROUGH 50;
FOR I:=2 STEP 2 UNTIL 50 SUM I**2;
22100
COMMENT TO SET XXX TO THE FACTORIAL OF 10;
XXX:=FOR I:=1:10 PRODUCT I;
XXX:=3628800
COMMENT ALTERNATIVELY, WE COULD SET THE ELEMENTS A(I) OF THE ARRAY A TO THE FACTORIAL OF I BY THE STATEMENTS;
ARRAY A(10);
A(0):=1$
FOR I:=1:10 DO A(I):=I*A(I - 1);
COMMENT THE ABOVE VERSION OF THE F O R STATEMENT DOES NOT RETURN AN ALGEBRAIC VALUE, BUT WE CAN NOW USE THESE
ARRAY ELEMENTS AS FACTORIALS IN EXPRESSIONS, E. G.;
1 + A(5);
121
COMMENT WE COULD HAVE PRINTED THE VALUES OF EACH A(I) AS THEY WERE COMPUTED BY REPLACING THE F O R STATEMENT BY;
FOR I:=1:10 DO WRITE A(I):=I*A(I - 1);
A(1):=1
A(2):=2
A(3):=6
A(4):=24
A(5):=120
A(6):=720
A(7):=5040
A(8):=40320
A(9):=362880
A(10):=3628800
COMMENT ANOTHER WAY TO USE FACTORIALS WOULD BE TO INTRODUCE AN OPERATOR FAC BY AN INTEGER PROCEDURE AS FOLLOWS;
INTEGER PROCEDURE FAC(N);
BEGIN INTEGER M,N;
M:=1;
L1:IF N=0 THEN RETURN M;
M:=M*N;
N:=N - 1;
GO TO L1 END;
COMMENT WE CAN NOW USE FAC AS AN OPERATOR IN EXPRESSIONS, E. G. ;
Z**2 + FAC(4) - 2*FAC 2*Y;
2
- (4*Y - Z - 24)
COMMENT NOTE IN THE ABOVE EXAMPLE THAT THE PARENTHESES AROUND THE ARGUMENTS OF FAC MAY BE OMITTED SINCE FAC IS A
UNARY OPERATOR;
COMMENT THE FOLLOWING EXAMPLES ILLUSTRATE THE SOLUTION OF SOME COMPLETE PROBLEMS;
COMMENT THE F AND G SERIES (REF SCONZO, P., LESCHACK, A. R. AND TOBEY, R. G., ASTRONOMICAL JOURNAL, VOL 70 (MAY
1965);
SCALAR F1,F2,G1,G2;
DEPS:= - SIG*(MU + 2*EPS)$
DMU:= - 3*MU*SIG$
DSIG:=EPS - 2*SIG**2$
F1:=1$
G1:=0$
FOR I:=1:8 DO BEGIN F2:= - MU*G1 + DEPS*DF(F1,EPS) + DMU*DF(F1,MU) + DSIG*DF(F1,SIG)$
WRITE"F(",I,") := ",F2;
G2:=F1 + DEPS*DF(G1,EPS) + DMU*DF(G1,MU) + DSIG*DF(G1,SIG)$
WRITE"G(",I,") := ",G2;
F1:=F2$
G1:=G2 END;
F(1) := 0
G(1) := 1
F(2) := - MU
G(2) := 0
F(3) := 3*MU*SIG
G(3) := - MU
2
F(4) := MU*(MU - 15*SIG + 3*EPS)
G(4) := 6*MU*SIG
2
F(5) := - 15*MU*SIG*(MU - 7*SIG + 3*EPS)
2
G(5) := MU*(MU - 45*SIG + 9*EPS)
2 2 4 2 2
F(6) := - MU*(MU - 210*MU*SIG + 24*MU*EPS + 945*SIG - 630*SIG *EPS + 45*EPS )
2
G(6) := - 30*MU*SIG*(MU - 14*SIG + 6*EPS)
2 2 4 2 2
F(7) := 63*MU*SIG*(MU - 50*MU*SIG + 14*MU*EPS + 165*SIG - 150*SIG *EPS + 25*EPS )
2 2 4 2 2
G(7) := - MU*(MU - 630*MU*SIG + 54*MU*EPS + 4725*SIG - 3150*SIG *EPS + 225*EPS )
3 2 2 2 4 2 2 6
F(8) := MU*(MU - 2205*MU *SIG + 117*MU *EPS + 51975*MU*SIG - 24570*MU*SIG *EPS + 1107*MU*EPS - 135135*SIG +
4 2 2 3
155925*SIG *EPS - 42525*SIG *EPS + 1575*EPS )
2 2 4 2 2
G(8) := 126*MU*SIG*(MU - 100*MU*SIG + 24*MU*EPS + 495*SIG - 450*SIG *EPS + 75*EPS )
COMMENT A PROBLEM IN FOURIER ANALYSIS;
FOR ALL X,Y LET COS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ACILITY;
MATRIX XX,YY;
LET XX=MAT((A11,A12),(A21,A22)),YY=MAT((Y1),(Y2));
2*DET XX - 3*XXX;
2*(A22*A11 - A21*A12 - 5443200)
ZZ:=SOLVE(XX,YY);
ZZ(1,1)=(Y1*A22 - Y2*A12)/(A22*A11 - A21*A12)
ZZ(2,1)=( - (Y1*A21 - Y2*A11))/(A22*A11 - A21*A12)
1/XX**2;
2 2 2 2 2
MAT(1,1)=(A22 + A21*A12)/(A22 *A11 - 2*A22*A21*A12*A11 + A21 *A12 )
2 2 2 2
MAT(1,2)=( - A12*(A22 + A11))/(A22 *A11 - 2*A22*A21*A12*A11 + A21 *A12 )
2 2 2 2
MAT(2,1)=( - A21*(A22 + A11))/(A22 *A11 - 2*A22*A21*A12*A11 + A21 *A12 )
2 2 2 2 2
MAT(2,2)=(A21*A12 + A11 )/(A22 *A11 - 2*A22*A21*A12*A11 + A21 *A12 )
COMMENT END OF MATRIX EXAMPLES;
COMMENT THE FOLLOWING EXAMPLES WILL FAIL UNLESS THE FUNCTIONS NEEDED FOR PROBLEMS IN HIGH ENERGY PHYSICS HAVE
BEEN LOADED;
COMMENT A PHYSICS EXAMPLE;
ON DIV;
COMMENT THIS GIVES US OUTPUT IN SAME FORM AS BJORKEN AND DRELL;
MASS KI=0,KF=0,PI=M,PF=M;
VECTOR EI,EF;
MSHELL KI,KF,PI,PF;
LET PI.EI=0,PI.EF=0,PI.PF=M**2 + KI.KF,PI.KI=M*K,PI.KF=M*KP,PF.EI= - KF.EI,PF.EF=KI.EF,PF.KI=M*KP,PF.KF=M*K,KI.EI
=0,KI.KF=M*(K - KP),KF.EF=0,EI.EI= - 1,EF.EF= - 1;
FOR ALL P LET GP(P)=G(L,P) + M;
COMMENT THIS IS JUST TO SAVE US A LOT OF WRITING;
GP(PF)*(G(L,EF,EI,KI)/(2*KI.PI) + G(L,EI,EF,KF)/(2*KF.PI))*GP(PI)*(G(L,KI,EI,EF)/(2*KI.PI) + G(L,KF,EF,EI)/(2*KF.
PI))$
WRITE"THE COMPTON CROSS-SECTION IS ",*ANS;
(-1) (-1) 2 2 2
THE COMPTON CROSS-SECTION IS 1/2*K *KP *(K + 4*K*KP*EF.EI - 2*K*KP + KP )
COMMENT END OF FIRST PHYSICS EXAMPLE;
OFF DIV;
COMMENT ANOTHER PHYSICS EXAMPLE;
FACTOR MM,P1.P3;
INDEX X1,Y1,Z;
MASS P1=MM,P2=MM,P3=MM,P4=MM,K1=0;
MSHELL P1,P2,P3,P4,K1;
VECTOR Q1,Q2;
FOR ALL P LET GA(P)=G(LA,P) + MM,GB(P)=G(LB,P) + MM;
GA( - P2)*G(LA,X1)*GA( - P4)*G(LA,Y1)*(GB(P3)*G(LB,X1)*GB(Q1)*G(LB,Z)*GB(P1)*G(LB,Y1)*GB(Q2)*G(LB,Z) + GB(P3)*G(
LB,Z)*GB(Q2)*G(LB,X1)*GB(P1)*G(LB,Z)*GB(Q1)*G(LB,Y1))$
LET Q1=P1 - K1,Q2=P3 + K1;
COMMENT IT IS USUALLY FASTER TO MAKE SUCH SUBSTITUTIONS AFTER ALL TRACE ALGEBRA IS DONE;
WRITE"CXN = ",*ANS;
4 4 2 2 2 2
CXN = 32*MM *P3.P1 - 8*MM *(P3.K1 - P1.K1) - 16*MM *P3.P1 - 16*MM *P3.P1*(P4.P2 - P3.K1 + P1.K1) + 8*MM *(P4.P2*
P3.K1 - P4.P2*P1.K1 - 2*P4.K1*P2.K1) + 8*P3.P1*(2*P4.P3*P2.P1 - P4.P3*P2.K1 + 2*P4.P1*P2.P3 + P4.P1*P2.K1
- P4.K1*P2.P3 + P4.K1*P2.P1) + 8*(2*P4.P3*P2.P3*P1.K1 - P4.P3*P2.P1*P3.K1 + P4.P3*P2.P1*P1.K1 - P4.P1*P2.
P3*P3.K1 + P4.P1*P2.P3*P1.K1 - 2*P4.P1*P2.P1*P3.K1)
COMMENT END OF SECOND PHYSICS EXAMPLE;
COMMENT THE FOLLOWING RATHER LONG PROGRAM IS A COMPLETE ROUTINE FOR CALCULATING THE RICCI SCALAR. IT WAS
DEVELOPED IN COLLABORATION WITH DAVID BARTON AND JOHN FITCH;
COMMENT FIRST WE INHIBIT DIAGNOSTIC MESSAGE PRINTING AND THE PRINTING OF ZERO ELEMENTS OF ARRAYS;
OFF MSG$
ON NERO$
COMMENT HERE WE INTRODUCE THE COVARIANT AND CONTRAVARIANT METRICS;
ARRAY GG(3,3),H(3,3),X(3)$
FOR I:=0:3 DO FOR J:=0:3 DO GG(I,J):=H(I,J):=0$
GG(0,0):=E**(Q1(X(1)))$
GG(1,1):= - E**(P1(X(1)))$
GG(2,2):= - X(1)**2$
GG(3,3):= - X(1)**2*SIN(X(2))**2$
FOR I:=0:3 DO H(I,I):=1/GG(I,I)$
IF I~=J LET DF(P1(X(I)),X(J))=0,DF(Q1(X(I)),X(J))=0;
COMMENT GENERATE CHRISTOFFEL SYMBOLS AND STORE IN ARRAYS CS1 AND CS2;
ARRAY CS1(3,3,3)$
FOR I:=0:3 DO FOR J:=I:3 DO FOR K:=0:3 DO CS1(J,I,K):=CS1(I,J,K):=(DF(GG(I,K),X(J)) + DF(GG(J,K),X(I)) - DF(GG(I,
J),X(K)))/2$
ARRAY CS2(3,3,3)$
FOR I:=0:3 DO FOR J:=I:3 DO FOR K:=0:3 DO CS2(J,I,K):=CS2(I,J,K):=FOR P:=0:3 SUM H(K,P)*CS1(I,J,P)$
COMMENT NOW CALCULATE THE DERIVATIVES OF THE CHRISTOFFEL SYMBOLS AND STORE IN DC2(I,J,K,L);
ARRAY DC2(3,3,3,3)$
FOR I:=0:3 DO FOR J:=I:3 DO FOR K:=0:3 DO FOR L:=0:3 DO DC2(J,I,K,L):=DC2(I,J,K,L):=DF(CS2(I,J,K),X(L))$
COMMENT NOW STORE THE SUMS OF PRODUCTS OF THE CS2 IN SPCS2;
ARRAY SPCS2(3,3,3,3)$
FOR I:=0:3 DO FOR J:=I:3 DO FOR K:=0:3 DO FOR L:=0:3 DO SPCS2(J,I,K,L):=SPCS2(I,J,K,L):=FOR P:=0:3 SUM CS2(P,L,K)
*CS2(I,J,P)$
COMMENT NOW COMPUTE THE RIEMANN TENSOR AND STORE IN R(I,J,K,L);
ARRAY R(3,3,3,3)$
FOR I:=0:3 DO FOR J:=I + 1:3 DO FOR K:=I:3 DO FOR L:=K + 1:IF K=I THEN J ELSE 3 DO BEGIN R(J,I,L,K):=R(I,J,K,L):=
FOR Q:=0:3 SUM GG(I,Q)*(DC2(K,J,Q,L) - DC2(J,L,Q,K) + SPCS2(K,J,Q,L) - SPCS2(L,J,Q,K))$
R(I,J,L,K):=R(J,I,K,L):= - R(I,J,K,L)$
IF I=K&J=L THEN GO TO A$
R(K,L,I,J):=R(L,K,J,I):=R(I,J,K,L)$
R(L,K,I,J):=R(K,L,J,I):= - R(I,J,K,L)$
A:END$
COMMENT NOW COMPUTE AND PRINT THE RICCI TENSOR;
ARRAY RICCI(3,3)$
FOR I:=0:3 DO FOR J:=0:3 DO WRITE RICCI(J,I):=RICCI(I,J):=FOR P:=0:3 SUM FOR Q:=0:3 SUM H(P,Q)*R(Q,I,P,J);
( - Q1(X(1))) ( - (P1(X(1)) - Q1(X(1))))
RICCI(0,0):=RICCI(0,0):=(4*R(0,0,0,0)*X(1)*E + X(1)*E *DF(P1(X(1)),X(1))*DF
( - (P1(X(1)) - Q1(X(1)))) 2 ( - (P1(X(1)) - Q1(X(1))))
(Q1(X(1)),X(1)) - X(1)*E *DF(Q1(X(1)),X(1)) - 2*X(1)*E *DF(Q1(
( - (P1(X(1)) - Q1(X(1))))
X(1)),X(1),X(1)) - 4*E *DF(Q1(X(1)),X(1)))/(4*X(1))
( - P1(X(1))) ( - Q1(X(1)))
RICCI(1,0):=RICCI(0,1):= - (R(1,0,1,1)*E - R(0,0,0,1)*E )
2 ( - Q1(X(1))) 2
RICCI(2,0):=RICCI(0,2):=( - (R(2,0,2,2) - R(0,0,0,2)*X(1) *E ))/X(1)
2 2 ( - Q1(X(1))) 2 2
RICCI(3,0):=RICCI(0,3):=(SIN(X(2)) *R(0,0,0,3)*X(1) *E - R(3,0,3,3))/(SIN(X(2)) *X(1) )
( - P1(X(1))) ( - Q1(X(1)))
RICCI(0,1):=RICCI(1,0):= - (R(1,1,1,0)*E - R(0,1,0,0)*E )
( - P1(X(1)))
RICCI(1,1):=RICCI(1,1):=( - (4*R(1,1,1,1)*X(1)*E + X(1)*DF(P1(X(1)),X(1))*DF(Q1(X(1)),X(1)) - X(1)*
2
DF(Q1(X(1)),X(1)) - 2*X(1)*DF(Q1(X(1)),X(1),X(1)) + 4*DF(P1(X(1)),X(1))))/(4*X(1))
2 ( - P1(X(1))) 2
RICCI(2,1):=RICCI(1,2):=( - (R(2,1,2,2) + R(1,1,1,2)*X(1) *E ))/X(1)
2 2 ( - P1(X(1))) 2 2
RICCI(3,1):=RICCI(1,3):=( - SIN(X(2)) *R(1,1,1,3)*X(1) *E - R(3,1,3,3))/(SIN(X(2)) *X(1) )
2 ( - Q1(X(1))) 2
RICCI(0,2):=RICCI(2,0):=( - (R(2,2,2,0) - R(0,2,0,0)*X(1) *E ))/X(1)
2 ( - P1(X(1))) 2
RICCI(1,2):=RICCI(2,1):=( - (R(2,2,2,1) + R(1,2,1,1)*X(1) *E ))/X(1)
3 ( - P1(X(1))) 3 ( - P1(X(1)))
RICCI(2,2):=RICCI(2,2):=( - (2*R(2,2,2,2) + X(1) *E *DF(P1(X(1)),X(1)) - X(1) *E *DF(Q1(X
2 ( - P1(X(1))) 2 2
(1)),X(1)) - 2*X(1) *E + 2*X(1) ))/(2*X(1) )
2 2 2
RICCI(3,2):=RICCI(2,3):=( - SIN(X(2)) *R(2,2,2,3) - R(3,2,3,3))/(SIN(X(2)) *X(1) )
2 2 ( - Q1(X(1))) 2 2
RICCI(0,3):=RICCI(3,0):=(SIN(X(2)) *R(0,3,0,0)*X(1) *E - R(3,3,3,0))/(SIN(X(2)) *X(1) )
2 2 ( - P1(X(1))) 2 2
RICCI(1,3):=RICCI(3,1):=( - SIN(X(2)) *R(1,3,1,1)*X(1) *E - R(3,3,3,1))/(SIN(X(2)) *X(1) )
2 2 2
RICCI(2,3):=RICCI(3,2):=( - SIN(X(2)) *R(2,3,2,2) - R(3,3,3,2))/(SIN(X(2)) *X(1) )
4 2 ( - P1(X(1))) ( - P1(X(1)))
RICCI(3,3):=RICCI(3,3):=( - SIN(X(2)) *X(1) *(X(1)*E *DF(P1(X(1)),X(1)) - X(1)*E *DF(Q1(X
( - P1(X(1))) 2 2
(1)),X(1)) - 2*E + 2) - 2*R(3,3,3,3))/(2*SIN(X(2)) *X(1) )
COMMENT FINALLY COMPUTE AND PRINT THE RICCI SCALAR;
R:=FOR I:=0:3 SUM FOR J:=0:3 SUM H(I,J)*RICCI(I,J);
4 4 ( - 2*P1(X(1))) 4 ( - 2*Q1(X(1))) 4
R:=(SIN(X(2)) *(2*R(2,2,2,2) + 2*R(1,1,1,1)*X(1) *E + 2*R(0,0,0,0)*X(1) *E + X(1) *
( - P1(X(1))) 4 ( - P1(X(1))) 2 4 ( -
E *DF(P1(X(1)),X(1))*DF(Q1(X(1)),X(1)) - X(1) *E *DF(Q1(X(1)),X(1)) - 2*X(1) *E
P1(X(1))) 3 ( - P1(X(1))) 3 ( - P1(X(1)))
*DF(Q1(X(1)),X(1),X(1)) + 4*X(1) *E *DF(P1(X(1)),X(1)) - 4*X(1) *E *DF(Q1(X(
2 ( - P1(X(1))) 2 4 4
1)),X(1)) - 4*X(1) *E + 4*X(1) ) + 2*R(3,3,3,3))/(2*SIN(X(2)) *X(1) )
END OF RICCI TENSOR AND SCALAR CALCULATION;
LEAVING REDUCE ...
***