This shows you the differences between two versions of the page.

cl:functions:exp [2019/06/15 02:00] |
cl:functions:exp [2019/06/18 10:00] (current) |
||
---|---|---|---|

Line 1: | Line 1: | ||

+ | ====== Function EXP, EXPT ====== | ||

+ | |||

+ | ====Syntax==== | ||

+ | * **exp** //number// → //result// | ||

+ | * **expt** //base-number power-number// → //result// | ||

+ | |||

+ | ====Arguments and Values==== | ||

+ | * //number// - a //[[CL:Glossary:number]]//. | ||

+ | * //base-number// - a //[[CL:Glossary:number]]//. | ||

+ | * //power-number// - a //[[CL:Glossary:number]]//. | ||

+ | * //result// - a //[[CL:Glossary:number]]//. | ||

+ | |||

+ | ====Description==== | ||

+ | **exp** and **expt** perform exponentiation. | ||

+ | |||

+ | **exp** returns ''e'' raised to the power //number//, where ''e'' is the base of the natural logarithms. | ||

+ | |||

+ | **exp** has no branch cut. | ||

+ | |||

+ | **expt** returns //base-number// raised to the power //power-number//. If the //base-number// is a //[[CL:Glossary:rational]]// and //power-number// is an //[[CL:Glossary:integer]]//, the calculation is exact and the result will be of type **[[CL:Types:rational]]**; otherwise a floating-point approximation might result. | ||

+ | |||

+ | For **expt** of a //[[CL:Glossary:complex rational]]// to an //[[CL:Glossary:integer]]// power, the calculation must be exact and the result is of type ''([[CL:Types:or]] [[CL:Types:rational]] ([[CL:Types:complex]] [[CL:Types:rational]]))''. | ||

+ | |||

+ | The result of **expt** can be a //[[CL:Glossary:complex]]//, even when neither argument is a //[[CL:Glossary:complex]]//, if //base-number// is negative and //power-number// is not an //[[CL:Glossary:integer]]//. The result is always the //[[CL:Glossary:principal]]// //[[CL:Glossary:complex]]// //[[CL:Glossary:value]]//. For example, ''(expt -8 1/3)'' is not permitted to return ''-2'', even though ''-2'' is one of the cube roots of ''-8''. The //[[CL:Glossary:principal]]// cube root is a //[[CL:Glossary:complex]]// approximately equal to ''#C(1.0 1.73205)'', not ''-2''. | ||

+ | |||

+ | **expt** is defined as ''b<sup>x</sup> = ''e<sup>x log b</sup>''. This defines the //[[CL:Glossary:principal]]// //[[CL:Glossary:values]]// precisely. The range of **expt** is the entire complex plane. Regarded as a function of //x//, with //b// fixed, there is no branch cut. Regarded as a function of //b//, with //x// fixed, there is in general a branch cut along the negative real axis, continuous with quadrant II. The domain excludes the origin. By definition, ''0<sup>0</sup> = 1''. If ''//b// = 0'' and the real part of //x// is strictly positive, then ''b<sup>x</sup> = 0''. For all other values of //x//, ''0<sup>x</sup>'' is an error. | ||

+ | |||

+ | When //power-number// is an //[[CL:Glossary:integer]]// ''0'', then the result is always the value one in the //[[CL:Glossary:type]]// of //base-number//, even if the //base-number// is zero (of any //[[CL:Glossary:type]]//). That is: | ||

+ | |||

+ | <blockquote> | ||

+ | (expt x 0) ≡ ([[CL:Functions:coerce]] 1 ([[CL:Functions:type-of]] x)) | ||

+ | </blockquote> | ||

+ | |||

+ | If //power-number// is a zero of any other //[[CL:Glossary:type]]//, then the result is also the value one, in the //[[CL:Glossary:type]]// of the arguments after the application of the contagion rules in \secref\NumericContagionRules, with one exception: the consequences are undefined if //base-number// is zero when //power-number// is zero and not of type **[[CL:Types:integer]]**. | ||

+ | |||

+ | ====Examples==== | ||

+ | |||

+ | <blockquote> | ||

+ | (exp 0) → 1.0 | ||

+ | (exp 1) → 2.718282 | ||

+ | (exp ([[CL:Functions:log]] 5)) → 5.0 | ||

+ | (expt 2 8) → 256 | ||

+ | (expt 4 .5) → 2.0 | ||

+ | (expt #c(0 1) 2) → -1 | ||

+ | (expt #c(2 2) 3) → #C(-16 16) | ||

+ | (expt #c(2 2) 4) → -64 | ||

+ | </blockquote> | ||

+ | |||

+ | ====Affected By==== | ||

+ | None. | ||

+ | |||

+ | ====Exceptional Situations==== | ||

+ | None. | ||

+ | |||

+ | ====See Also==== | ||

+ | * **[[CL:Functions:log|Function LOG]]** | ||

+ | * {\secref\FloatSubstitutability} | ||

+ | |||

+ | ====Notes==== | ||

+ | Implementations of **expt** are permitted to use different algorithms for the cases of a //power-number// of type **[[CL:Types:rational]]** and a //power-number// of type **[[CL:Types:float]]**. | ||

+ | |||

+ | Note that by the following logic, ''([[CL:Functions:sqrt]] (expt //x// 3))'' is not equivalent to ''(expt //x// 3/2)''. | ||

+ | |||

+ | <blockquote> | ||

+ | ([[CL:Macros:defparameter]] *x* (exp ([[CL:Functions:math-divide|/]] ([[CL:Functions:math-multiply|*]] 2 pi #c(0 1)) 3))) ; e<sup>2πi/3</sup> | ||

+ | (expt *x* 3) → 1 ; except for round-off error | ||

+ | ([[CL:Functions:sqrt]] (expt *x* 3)) → 1 ; except for round-off error | ||

+ | (expt *x* 3/2) → -1 ; except for round-off error </blockquote> | ||

+ | |||

+ | \issue{COMPLEX-RATIONAL-RESULT:EXTEND} \issue{COMPLEX-RATIONAL-RESULT:EXTEND} \issue{EXPT-RATIO:P.211} | ||