2 COMMENT FIRST EXAMPLE PROGRAM FROM BALGOL MANUAL, MARCH 1963.
2
2 J.G. HERRIOT, OF STANFORD UNIVERSITY, HAS WRITTEN THE FOLLOWING
2 PROGRAM TO DETERMINE AN APROXIMATION OF HARMONIC-BOUNDARY VALUES,
2 USING ORTHONORMAL FUNCTIONS;
2
2 COMMENT THIS PROGRAM FIRST CONSTRUCTS A SET OF ORTHONORMAL FUNCTIONS
2 AND THEN USES THEM TO FIND AN APPROXIMATION TO THE SOLUTION OF A
2 HARMONIC BOUNDARY-VALUE PROBLEM;
2
2 COMMENT WE FIRST CONSTRUCT THE ORTHONORMAL FUNCTIONS;
2
2 INTEGER I, J, K, L, M, N, NU, TH;
2 ARRAY R(29), HFN(29), DSUM(24), HFCN(5), HFCEN(6),
2       FA(25,25), A(25,25), B(25,25), HA(47), HAA(24);
2 INPUT DATA (FOR I=(1,1,29); R(I)), DIMEN(N);
2 OUTPUT FRESULTS (FOR I=(1,1,N); FOR J=(1,1,N); FA(I,J)),
2        ARESULTS (FOR I=(1,1,N); FOR J=(1,1,N); A(I,J)),
2        BRESULTS (FOR I=(1,1,N); FOR J=(1,1,N); B(I,J)),
2        COEFFS (FOR NU=(4,4,N-1); HA(2NU-1)),
2        HFNRES (FOR K=(1,1,29); HFN(K)),
2        CRES(CONST), HFCNRES (TH, FOR K=(115); HFNC(K)),                       <<TYPOS
2        HFCENRES(TH, FOR K=(1,1,6); HFCEN(K));
2 FORMAT VECTOR (B8,6F16.8,W0),
2        FTITLE (B48,*FRESULTS,FA(I,J)*,W3,W2),
2        ATITLE (B48,*ARESULTS,A(I,J)*,W3,W2),
2        COEFTITLE (B30,*HA(8NU-1)*,W2),
2        BDYVALUES (B42,*PRELIMINARY BOUNDARY VALUES*,W3,W2),
2        CBDYVALUES (B43,*CORRECTED BOUNDARY VALUES*,W2),
2        CONTITLE (B50,*CONSTANT*,W2),
2        TABLE (B8,I2,B6,6F16.8,W0),
2        TABLEHEAD (B40, *THE VALUES OF H(RHO,TH) IN B*, W3,W2),
2        TABLELINE (B13,*RHO*,B6,*0.5*,B13,*1.0*,B13,*1.5*,B13,
2                   *2.0*,B13,*2.5*,B13,*3.0*,W0),
2        TABLETH (B8,*TH*,W0);
2 START..
2   READ (;; DATA);
2 RDIM..
2   READ (;; DIMEN);
2   FOR I = (1,1,N);
2     FOR J = (I,4,N);
2       BEGIN
2       L = I-J; K = I+J;
2       SUM = R(1)*K + 1.5R(18)*K.COS(0.59341195.L)
2            + 0.5.R(29)*K.COS(0.78539816.L);
2       FOR M = (2,1,17);
2         SUM = SUM + 2.0.R(M)*K.COS((M-1).0.034906585.L);
2       FOR M = (19,1,28);
2         SUM = SUM + R(M)*K.COS((0.59341195 + (M-18).0.017453293).L);
2       FA(I,J) = (8.0/K).0.017453293.SUM
2       END;
2   WRITE (;; FTITLE);
2   WRITE (;; FRESULTS, VECTOR);
2   FOR J - (1,1,N);                                                            <<TYPO
2     B(1,J) = FA(1,J);
2   FOR I = (2,1,N);
2     BEGIN
2     FOR J = (1,1,I-1);
2       B(I,J = -B(J,I)/B(J,J);                                                 <<TYPO
2     FOR J = (I,1,N);
2       BEGIN
2       B(I,J) = FA(I,J);
2       FOR K = (1,1,I-1);
2         B(I,J) = B(I,J) + B(I,K).B(K,J)
2       END;
2     FOR J = (1,1,I-1);
2       B(I,J) = B(I,J).SQRT(B(J,J)/B(I,I))
2     END;
2   FOR I = (1,1,N);
2     B(I,I) = 1.0/(SQRT(B(I,I)).I);
2   WRITE (;; BTITLE);                                                          <<UNDEC
2   WRITE (;; BRESULTS, VECTOR);
2   FOR I = (1,1,N);
2     FOR J = (1,1,N);
2       A(I,J) = 0;
2   A(1,1) = B(1,1);
2   FOR I = (2,1,N);
2     BEGIN
2     FOR J= (1,1,I-1);
2       BEGIN
2       A(I,J) = 0;
2       FOR K = (J,1,I-1);
2         A(I,J) = A(I,J) + B(I,K).A(K,J)
2       END;
2       A(I,I) = B(I,I)
2     END;
2   WRITE (;; ATITLE);
2   WRITE (;; ARESULT, VECTOR);                                                 <<TYPO
2
2   COMMENT NOW CONSTRUCT THE APROXIMATION TO THE SOLUTION;
2
2   FOR J = (4,4,N-1);
2     BEGIN
2     DSUM(J) = 0;
2     FOR M = (1,1,17);
2       DSUM(J) = DSUM(J) + (R(M)*2 + R(M+1)*2).
2                           (R(M+1)*J.SIN(M.0.034906585.J)
2                           - R(M)*J.SIN((M-1).0.034906585.J));
2     FOR M = (18,1,28);
2       DSUM(J) = DSUM(J) + (R(M)*2 + R(M+1)*2.(R(M+1)*J.
2                           SIN((0.59341195 + (M-17).0.017453293).J)
2                           - R(M)*J.SIN((0.59341195
2                                         + (M-18).0.017453293).J)))
2     END;
2   FOR NU = (4,4,N-1);
2     BEGIN
2     HA(2NU-1) = 0;
2     FOR J = (4,4,NU);
2       HA(2NU-1) = HA(2NU-1) + A(NU,J).DSUM(J);
2       HA(2NU-1) = 4.0.HA(2NU-1)
2     END;
2   WRITE (;; COEFTITLE);
2   WRITE (;; COEFFS, VECTOR);
2   FOR J = (4,4,N-1);
2     BEGIN
2     HAA(J) = 0;
2     FOR NU = (J,4,N-1);
2       HAA(J) = HAA(J) + HA(2NU-1).A(NU,J)
2     END                                                                       <<SEMI
2   FOR M = (1,1,18);
2     BEGIN
2     HFN(M) = 0;
2     FOR J = (4,4,N-1);
2       HFN(M) = HFN(M) + HAA(J).R(M)*J.COS((M-1).0.034906585.J)
2     END;
2   FOR M = (19,1,29);
2     BEGIN
2     HFN(M) = 0;
2     FOR J = (4,4,N-1);
2       HFN(M) = HFN(M) + HAA(J).R(M)*J.
2                         COS((0.59341195 + (M-18).0.017453293).J)
2     END;
2   WRITE (;; BDYVALUES);
2   WRITE (;; HFNRES, VECTOR);
2   AVT = 0;
2   FOR M = (1,1,29);
2     AVT = AVT + R(M)*2 - HFN(M);
2   CONST = AVT/29.0;
2   WRITE (;; CONTITLE);
2   WRITE (;; CRES, VECTOR);
2   FOR M = (1,1,29);
2     HFN(M) = CONST + HFN(M);
2   WRITE (;; CBDYVALUES);
2   WRITE (;; HFNRES, VECTOR);
2   FOR I = (1,1,5);
2     BEGIN
2     TH = 5.(I-1);
2     FOR J = (1,1,5);
2       BEGIN
2       HFCN(J) = CONST;
2       FOR M = (4,4,N-1);
2         HFCN(J) = HFCN(J) + HAA(M).(0.5.J)*M.COS((I-1).0.087266463.M)
2       END;
2     WRITE (;; TABLEHEAD);
2     WRITE (;; TABLELINE);
2     WRITE (;; TABLETH);
2     WRITE (;; HFCNRES, TABLE)
2     END;
2   FOR I = (6,1,10);
2     BEGIN
2     TH = 5.(I-1);
2     FOR J = (1,1,6);
2       BEGIN
2       HFCEN(J) = CONST;
2       FOR M = (4,4,N-1);
2         HFCEN(J) = FHCEN(J) + HAA(M).(0.5.J)*M.                               <<TYPO
2                               COS((I-1).0.087266463.M)
2       END;
2     WRITE (;; HFCNRES, TABLE)
2     END;
2   STOP 1234;
2   GO TO RDIM;
2 FINISH;
