ISO M2 COMPLEX-number constructor test 
Author Message
 ISO M2 COMPLEX-number constructor test

 MODULE C_Ackermann;
 (* Recursive ISO Modula-2 COMPLEX number constructor example & test program
    by G~unter Dotzel/ModulaWare GmbH, 22-Mar-1992

    To check the results: f(CMPLX(3.,j)) = 2^(j+3) -3
    Try to compute f(CMPLX(4.,1.)) on a real fast machine! ;-)
 FROM STextIO IMPORT WriteString, WriteLn;

   IF RE(c)=0.0 THEN RETURN IM(c)+1.0;
   ELSIF IM(c)=0.0 THEN RETURN f(CMPLX(RE(c)-1.0, 1.0));
   ELSE RETURN f(CMPLX(RE(c)-1.0, f(CMPLX(RE(c),IM(c)-1.0))))
 END f;

 CONST max=11.0; VAR j: REAL;
 BEGIN j:=0.0;
   WHILE j<=max DO
     WriteString('f (CMPLX(3.,');WriteReal(j, 0); WriteString('))=');
     WriteReal(f(CMPLX(3.0,j)), 0); WriteLn;
 END C_Ackermann.
 (* the program produces the following output
    (On my outdated microVAXII, the computation takes *several* minutes!) :
    f (CMPLX(3.,0.))=5.
    f (CMPLX(3.,1.))=13.00
    f (CMPLX(3.,2.))=29.00
    f (CMPLX(3.,3.))=61.00
    f (CMPLX(3.,4.))=125.0
    f (CMPLX(3.,5.))=253.0
    f (CMPLX(3.,6.))=509.0
    f (CMPLX(3.,7.))=1021.
    f (CMPLX(3.,8.))=2045.
    f (CMPLX(3.,9.))=4093.
    f (CMPLX(3.,10.00))=8189.
    f (CMPLX(3.,11.00))=16381


Sun, 11 Sep 1994 15:00:02 GMT  
 [ 1 post ] 

 Relevant Pages 

1. ISO M2 I/O-Lib test file: TestPos.MOD

2. ISO M2 I/O-Lib test file: TestExam.MOD

3. A logicial to Pass complex number to real number

4. IOTRANSFER: why was it modified in ISO M2?

5. ISO M2 Std Lib Defs .ARC

6. Status of M2 ISO Standard

7. ISO M2 Std Lib Defs .ARC

8. Oberon-2 random file access w ISO M2 Std

9. ISO M2 Library for Oberon-2

10. Did you receive the ISO M2 Standard IO a

11. M2-ISO/DIN/MIG WG-meeting 22.Feb/Essen(F

12. M2 complex math-lib wanted


Powered by phpBB® Forum Software