updating oE power


<built-in> function power(object base, object exponent) 

raises a base value to some power.

  1. base : an object, the value or values to raise to some power.
  2. exponent : an object, the exponent or exponents to apply to base.

An object, the shape of which depends on base's and exponent's. For two atoms, this will be base raised to the power exponent.


If some atom in base is negative and is raised to a non integer exponent, an error will occur, as the result is undefined.

If 0 is raised to any negative power, this is the same as a zero divide and causes an error.

power(0,0) is illegal, because there is not an unique value that can be assigned to that quantity.


The arguments to this function may be atoms or sequences. The rules for operations on sequences apply.

Powers of 2 are calculated very efficiently.

Other languages have a ** or ^ operator to perform the same action. But they do not have sequences.

Example 1:
? power(5, 2) 
-- 25 is printed 
Example 2:
? power({5, 4, 3.5}, {2, 1, -0.5}) 
-- {25, 4, 0.534522} is printed 
Example 3:
? power(2, {1, 2, 3, 4}) 
-- {2, 4, 8, 16} 
Example 4:
? power({1, 2, 3, 4}, 2) 
-- {1, 4, 9, 16} 
See Also:

log, Operations on sequences

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu