david135 / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

error in expt corner case #176

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. evaluate (expt +inf.0+2.0i 2)

What is the expected output? What do you see instead?
It should be: +inf.0++nan.0i. It is: +inf.0++inf.0i.

What version of the product are you using? On what operating system?
Mosh R6RS scheme interpreter, version 0.2.6 (revision master 2010/10/20 
21:28:25 mosh-0.2.5-191-g0df954a).  i686-pc-linux-gnu.

Please provide any additional information below.
The following discussion is from an email exchange with Kent Dybvig (I asked 
him permission to publish it):

  ;;It does seem like:
  ;;
  ;;   (expt +inf.0+2.i 2)
  ;;
  ;;would be equivalent to:
  ;;
  ;;   (* +inf.0+2.i +inf.0+2.i)
  ;;
  ;;which evaluates  to +inf.0+inf.0i.   Nevertheless, I'm not  sure the
  ;;R6RS supports this interpretation.   According to the description of
  ;;expt, when z1 is not zero,
  ;;
  ;;   (expt z1 z2) => e^{z2 log z1}
  ;;
  ;;so,
  ;;
  ;;   (expt +inf.0+2.i 2) => (exp (* 2 (log +inf.0+2.i)))
  ;;
  ;;Meanwhile, the Section 11.7.3 subsection on transcendental functions
  ;;defines log as follows:
  ;;
  ;;   (log z) => log |z| + (angle z)i
  ;;
  ;;so,
  ;;
  ;;   (log +inf.0+2.i) =>
  ;;     (make-rectangular
  ;;       (log (magnitude +inf.0+2.0i))
  ;;       (angle +inf.0+2.0i))
  ;;
  ;;Since:
  ;;
  ;;   (magnitude +inf.0+2.i) => +inf.0,
  ;;   (log +inf.0) => +inf.0, and
  ;;   (angle +inf.0+2.i) => 0.0,
  ;;
  ;;we have:
  ;;
  ;;   (log +inf.0+2.i) => +inf.0+0.0i
  ;;
  ;;and finally:
  ;;
  ;;   (expt +inf.0+2.i 2) => (exp (* 2 +inf.0+0.0i))
  ;;                       => (exp +inf.0+0.0i)
  ;;                       => (* (exp +inf.0) (exp 0.0i))
  ;;                       => (* +inf.0 1.0+0.0i)
  ;;                       => +inf.0+nan.0i
  ;;
  ;;because:
  ;;
  ;;   (* +inf.0 0.0i) => +nan.0
  ;;

P.S. The double plus in +inf.0++inf.0i is ugly.

Original issue reported on code.google.com by mrc....@gmail.com on 20 Oct 2010 at 7:13

GoogleCodeExporter commented 9 years ago

Original comment by hige...@gmail.com on 24 Oct 2010 at 12:35

GoogleCodeExporter commented 9 years ago

Original comment by hige...@gmail.com on 24 Oct 2010 at 12:36

GoogleCodeExporter commented 9 years ago

Original comment by hige...@gmail.com on 31 Jan 2011 at 3:42