[Nickle] Nickle bug: hangs computing exponent

Bart Massey bart at cs.pdx.edu
Sun Sep 14 01:17:28 PDT 2003

I suspect this may not actually be a bug, but just a bad
algorithm leading to a too-long computation.  At any rate:

  > q=1e-4
  > pow(1-q,10000)

hangs.  Coercing the base to real (using imprecise()) makes
it complete quickly with a good answer.  In fact, as one
scales the exponent, the time steadily increases.

Suggestion: does it make sense to compute the exponent of
the numerator and denominator separately, and then do a big
division and single GCD at the end?  Let's try:

  > qn = numerator(1-q)
  > qd = denominator(1-q)
  > qx = qn**10000;
  > qy = qd**10000;
  > qx / qy

hangs.  Ahh, but

  > qz = qx / qy;

returns instantly, so the problem is in output somewhere.
I note that 

  printf("%.17f\n", qz);

hangs, and tracing down it looks like the problem is likely
to be somewhere in RationalDecimalPrint () in rational.c.

Out of time to investigate tonight.  Keithp?


P.S.  During the investigation, another bug :-). The
prettyprinter should qualify names with namespace names
when the namespace is out of scope.

  > printf
  void func(string format, args ...)
      vprintf (format, args);
  > vprintf
  ->     vprintf;
  <stdin>:5: No visible symbol "vprintf" in scope
  > import File;
  > vprintf
  void func(string format, poly[*] args)
      vfprintf (stdout, format, args);

More information about the Nickle mailing list