Next: , Previous: , Up: baselib math ops   [Index]


4.6.4.8 Exponentiation functions

Procedure: sqrt z

Return the principal square root of z. For rational z, the result has either positive real part, or zero real part and non–negative imaginary part. With \log defined as in baselib math semantics trascend, the value of (sqrt z) could be expressed as e^{(\log z)/2}.

The sqrt procedure may return an inexact result even when given an exact argument.

(sqrt -5)               ⇒ 0.0+2.23606797749979i
                        ; approximately
(sqrt +inf.0)           ⇒ +inf.0
(sqrt -inf.0)           ⇒ +inf.0i
Procedure: exact-integer-sqrt k

The exact-integer-sqrt procedure returns two non–negative exact integer objects s and r where k = s^2 + r and k < (s+1)^2.

(exact-integer-sqrt 4)  ⇒ 2 0 ; two return values
(exact-integer-sqrt 5)  ⇒ 2 1 ; two return values
Procedure: expt z1 z2

Return z1 raised to the power z2. For non–zero z1, this is e^{(z_2 \log z_1)}. 0.0^z is 1.0 if z = 0.0, and 0.0 if (real-part z) is positive. For other cases in which the first argument is zero, either an exception is raised with condition type &implementation-restriction, or an unspecified number object is returned.

For an exact real number object z1 and an exact integer object z2, (expt z1 z2) must return an exact result. For all other values of z1 and z2, (expt z1 z2) may return an inexact result, even when both z1 and z2 are exact.

(expt 5 3)                  ⇒ 125
(expt 5 -3)                 ⇒ 1/125
(expt 5 0)                  ⇒ 1
(expt 0 5)                  ⇒ 0
(expt 0 5+.0000312i)        ⇒ 0.0
(expt 0 -5)                 ⇒ unspecified
(expt 0 -5+.0000312i)       ⇒ unspecified
(expt 0 0)                  ⇒ 1
(expt 0.0 0.0)              ⇒ 1.0

Next: , Previous: , Up: baselib math ops   [Index]