Questions tagged [exponentiation]

Anything related to the exponentiation operation, i.e. the process of computing the power of a number, and the corresponding syntax, semantics, constraints and implementation in programming languages.

Exponentiation is the process of raising a number to the nth power, (xn). Mathematically, it is denoted by superscripts, where the superscripted number is the exponent - xy.

However, since many text editors do not support superscripts, an alternative notation is used in code that uses exponentiation - typically a caret (x^y) or two asterisks (x**y). Other programming languages do not support symbolic operators for exponentiation, and rely on the pow function to calculate the exponent.

Please remember that the caret notation ^ may be used for bitwise XOR instead, and some languages does not support a built-in exponentiation operator.

See more

  • : a function that performs exponentiation. Namely, pow(a, b) calculates ab.
  • : do not assume that the ^ operator represents exponentiation. Many languages treat the ^ operator as bitwise-xor instead.
  • : The function ex, base-e exponentiation.
  • : Describes a type of curve produced by an exponent. Here, the the base is constant, and the variable is the exponent - and it grows extremely fast.
  • Wikipedia article for nore information about exponents and their identities.
368 questions
3
votes
1 answer

Hat ^ operator vs Math.Pow()

Having perused the MSDN documentation for both the ^ (hat) operator and the Math.Pow() function, I see no explicit difference. Is there one? There obviously is the difference that one is a function while the other is considered an operator, e.g.…
Toby
  • 9,696
  • 16
  • 68
  • 132
3
votes
1 answer

Power with successor arithmetic - how to prevent an infinite loop? [Prolog]

I have been thinking over this the whole day. I finally admit, I do not understand Prolog as good as I thought. At the start of the day, I had trouble implementing a successor arithmetic, which multiplies 2 s-Numbers, which structure is…
InDaPond
  • 574
  • 3
  • 6
  • 23
3
votes
1 answer

Difference between Python built-in pow and math pow for large integers

I find that for large integers, math.pow() does not successfully give its integer version. (I got a buggy Karatsuba multiplication when implemented with math.pow). For instance: >>> a_Size=32 >>> pow(10,a_size) *…
Rock
  • 177
  • 3
  • 11
3
votes
1 answer

What gives best precision, exponential of the difference or the quotient of the exponentials?

Given a typical programming language. I have two numbers floating point numbers a and b which are close to one another (i.e. their difference is much smaller, in absolute value, than their average). |a-b| << |a+b|/2 Mathematically, we have…
3
votes
3 answers

What math operation comes after exponentiation (^)?

Let's give expressions some names: x+3 = x+1+1+1 // lvl 1 x*3 = x+x+x // lvl 2 x^3 = x*x*x // lvl 3 What would be the mathematical term / real name / topic for lvls after 3? Like: x (lvl 4 operation) 3 = x^x^x x (lvl 5 operation) 3 = x(lvl 4…
3
votes
3 answers

Raise matrix to complex power

I'm implementing a library which makes use of the GSL for matrix operations. I am now at a point where I need to raise things to any power, including imaginary ones. I already have the code in place to handle negative powers of a matrix, but now I…
2mac
  • 1,609
  • 5
  • 20
  • 35
3
votes
5 answers

'Grokkable' algorithm to understand exponentiation where the exponent is floating point

To clarify first: 2^3 = 8. That's equivalent to 2*2*2. Easy. 2^4 = 16. That's equivalent to 2*2*2*2. Also easy. 2^3.5 = 11.313708... Er, that's not so easy to grok. Want I want is a simple algorithm which most clearly shows how 2^3.5 = 11.313708.…
Dan W
  • 3,520
  • 7
  • 42
  • 69
3
votes
1 answer

Python exponentiation order of operations and grouping

Simple question: Why does (7**3) ** 24 % 25 take almost no time to run, but 7 ** 3 ** 24 % 25 not terminate?
Elliot Gorokhovsky
  • 3,610
  • 2
  • 31
  • 56
3
votes
2 answers

Java: Dealing with Exponentiation

I have a problem with this program where I have to calculate the value of base^expo, and the base is a real number whereas the exponent is an integer. With (95.123)^12 I'm expecting 548815620517731830194541.899025343415715973535967221869852721, but…
user4395468
3
votes
4 answers

Why is the exponent operator not giving the expected result?

Here is the code #include int main() { int a; printf("%d\n",(3^6)); printf("%d",(a^a)); return 0; } I am getting the below output on executing the above code. 5 0 Shouldn't the output be 729? 3 to the power of 6 is 729. I could not…
3
votes
9 answers

How to cube a number

I just started using Python today for my class and one of my problems is cubing a number in Python. I know the way to do it is x^3, but that doesn't work in Python. I was just wondering how I would be able to do that. This is what I tried so far,…
user3795416
  • 65
  • 1
  • 1
  • 2
3
votes
1 answer

Iterative logarithmic exponentiation

I bombed an interview (phone screen with collabedit) recently. Here is the question: Write an interative O(lg n) algorithm for finding the power of x^y (x is a double, y>0 is an int). I first did the recursive divide and conquer one and tried to…
user87219
  • 181
  • 2
  • 10
3
votes
2 answers

Fast implementation binary exponentiation implementation in OpenCL

I've been trying to design a fast binary exponentiation implementation in OpenCL. My current implementation is very similar to the one in this book about pi. // Returns 16^n mod ak inline double expm (long n, double ak) { double r = 16.0; …
AnimatedRNG
  • 1,859
  • 3
  • 26
  • 39
3
votes
3 answers

Plotting functions at a specific y-interval

I need to plot a few exponential curves on the same plot - with the constraint that the plot ends at y=1. For reference, here is the code: from numpy import arange from matplotlib import pyplot as plt T = arange(60,89) curve1 = 2**(T - 74) curve2…
Tom Kealy
  • 2,537
  • 2
  • 27
  • 45
3
votes
2 answers

Why is this MongoDB ObjectID infinite in Google spreadsheet?

Type the MongoDB ObjectID 52489e882967060200000283 into a cell in a Google spreadsheet and it's clobbered by ∞. What gives?
hurrymaplelad
  • 26,645
  • 10
  • 56
  • 76