make-rectangular, make-polar - construct complex numbers


(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme r5rs))              ;R7RS
(import (scheme complex))           ;R7RS


(make-rectangular x y)
(make-polar m a)


The make-rectangular procedure returns the complex number with real part x and imaginary part y.

The make-polar procedure returns the complex number with approximate magnitude m and approximate angle a.


GNU Guile 3.0
Guile does not have a way to represent exact complex numbers with non-zero imaginary parts. This means that 1+2i is automatically turned into 1.0+2.0i. This is a deviation from R6RS but is allowed by R7RS.
Loko Scheme
Loko Scheme can internally represent complex numbers in polar notation, keeping the polar notation when convenient. This is mostly done as a joke and isn't something normally found in Scheme. Most implementations convert the polar notation to an inexact rectangular representation.

The real numbers, the rational numbers and the integers are a subset of the complex numbers. Many implementations will simplify the return type when one of y, m, and a is exact zero.


Both procedures return a single value; a complex number. If either argument is inexact then the returned number is inexact. The make-polar procedure may return inexact results even when the arguments are exact.


(make-rectangular 1 2)
          => 1+2i

(make-rectangular 1.1 2.2)
          => 1.1+2.2i ; approximately

(make-polar 1.1 2.2)
          => 1.1@2.2 ; approximately


These procedures, where they are implemented, are intended to achieve the same result: return the mathematically correct result to the extent allowed by the implementation. Some variations between implementations are noted above.

Support for these procedures is required by R6RS. There are however still variations in which types of numbers that can be represented. Some of the possible variations are: IEEE 754 floats are not required, -0.0 does not need to be distinct, the precision of inexact numbers can vary, numbers in polar notation can be turned into inexact numbers in rectangular notation.

Support for complex numbers is not guaranteed at all in R7RS.

An R7RS implementation's support can be tested with cond-expand(7scm):

Exact complex numbers are provided. (Note that this refers to the rectangular representation only).
Inexact numbers are IEEE 754 binary floating point values.


This procedure can raise exceptions with the following condition types:
&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain. In particular, all arguments must be real numbers.
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
R7RS and unsupported numbers
If an implementation encounters an exact numerical constant that it cannot represent as an exact number, then it may either report a violation of an implementation restriction or it may silently represent the constant by an inexact number.


exp(3scm), sin(3scm)


R4RS, IEEE Scheme, R5RS, R6RS, R7RS


These procedures first appeared in R2RS, which got them from Common Lisp.


This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at

Markup created by unroff 1.0sc,    March 04, 2023.