home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / modula2 / library / modula1 / complex.mod < prev    next >
Text File  |  1987-06-11  |  768b  |  29 lines

  1. (* Multiply the complex number z = 5/13 + 12/13i 50 times
  2.    with the complex number w = (0.6 + 0.8i).  Print intermediate
  3.    products and the square of their absolute value.
  4.    Note that |z| = |w| = 1. *)
  5.  
  6. MODULE complexmult;
  7. FROM RealInOut IMPORT WriteReal;
  8. FROM Terminal  IMPORT WriteLn;
  9.  
  10. CONST u = 0.6;
  11.       v = 0.8;
  12.  
  13. VAR i,j: CARDINAL;
  14.     x,x1,y: REAL;
  15.  
  16. BEGIN
  17.   x := 5.0/13.0; y := 12.0/13.0;
  18.   FOR i := 1 TO 50 DO
  19.     FOR j := 1 TO 10 DO
  20.       (* (x+iy) := (x+iy) * (u+iv) *)
  21.       x1 := x*u - y*v;
  22.       y := y*u + x*v;
  23.       x := x1
  24.     END;
  25.     WriteReal(x,6); WriteReal(y,6);
  26.     WriteReal(x*x + y*y,6); WriteLn
  27.   END
  28. END complexmult.
  29.