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
0
votes
0 answers

JSHint Exponentiation operator (**) warning?

Problem : in VSCode editor I got this warning message that's JSHint dropped Expected an identifier and instead saw '*'. (E030) for syntaxes like : const precise = (n, d = 2) => int(n * 10 ** d) / 10 ** d; in my code I have write syntaxes used…
Tamsamani
  • 76
  • 1
  • 8
0
votes
0 answers

GNATprove : "overflow check might fail" in exponentiation function

I can't solve this problem with SPARK 2018, I think I need some invariant to solve the problem of overflow, but I have already tried everything and can not find it. If someone could shed some light on my problem. I'll try Exponentiation by simple…
Michael Bueno
  • 33
  • 1
  • 1
  • 5
0
votes
2 answers

GCD Exponentiation

I have been trying to determine a shorter method for calculating gcd((a^n + b^n), abs(a-b)). I noticed that, if I were to calculate (using the above formula) say a = 100 and b = 4, starting from 1 and ending at n (a loop), at a certain point, the…
0
votes
1 answer

square always exponentiation method

besides the square-and-multiply method, there is this method square-and-multiply-always, and i am trying to implement it in python. My problem is that during searching i found a pseudocode for it, here and i implemented it in python but it does not…
kampias
  • 459
  • 1
  • 10
  • 21
0
votes
1 answer

ASCII number for exponent -2 and -3

I am trying to find an ascii formation to have a unit in a graph in exponent -2 and -3. For example mm^(-2). I found the relevant ascii formation for exponent 2 and 3 but i cannot find how to include the - sympol in the exponent. Do you have any…
stavcher
  • 9
  • 1
  • 5
0
votes
2 answers

How does the function powRec(x,n-1) performs an exponentiation?

class PowerRec { static double powRec(double x, int power) { if (power == 1){ return x; } return x * powRec(x, power - 1); } public static void main(String args[]) { double x = 2; …
sctts-lol
  • 557
  • 5
  • 9
0
votes
2 answers

Last number of exponentiation

I have a little problem. The task was to accept input for variable d - which means number of tests, and output variables a and b. Every test is for another pair of a's and b's. The result of this code should be the last number of ab…
K.Milde
  • 3
  • 2
0
votes
1 answer

10e5 == 10^5 is not true in MATLAB, why?

If you type in 10e5 == 10^5 ans = logical 0 so 10e5 does NOT mean 10 to the power of 5 but it means 10 to the power of 6. 10e5 == 10^6 ans = logical 1 What does 10e5 mean then? Is it somewhere in the documentation?…
0
votes
2 answers

Overflow in SML: Exponentiation procedure

I'm trying to write a simple procedure that calculates x to the power of 17 in the language Standard ML. I'm supposed to do it with a "helping procedure": fun help (y:int) = y * y * y * y; fun power17 (x:int) = help (help (help (help (x) ) ) ) *…
Mimi
  • 29
  • 2
0
votes
1 answer

R: Exponent returning infinity

I need to remove logarithms of my data and thus am taking e to the power of the values which are logarithmed. My issue is that when I have e to the power of more than 709 R returns the value of infinity. How can I surpass this? e^710 [1] Inf…
John_Doe
  • 95
  • 1
  • 11
0
votes
2 answers

Iterate bits from left to right for any number

I am trying to implement Modular Exponentiation (square and multiply left to right) algorithm in c. In order to iterate the bits from left to right, I can use masking which is explained in this link In this example mask used is 0x80 which can work…
TechJ
  • 512
  • 2
  • 5
  • 16
0
votes
1 answer

Evaluating arithmetic expression with exponentiation from string

I need to evaluate arithmetic expression with exponentiation from string, for example: string expression = "4*5+2^3" ^ symbol could be change to any other symbol or string, but it have to be written in same way as + - * operations because numbers…
Dork
  • 1,816
  • 9
  • 29
  • 57
0
votes
1 answer

negative exponent in modular exponentiation for RSA

I am trying to write an RSA code in python3.6 for educational purposes. The key generation and message encryption work fine, but I have a problem with decryption. As I understand the decryption algorithm is M = Cd mod n, where M is the message, C is…
0
votes
1 answer

Raising a complex number (__CLPK_complex) to an exponent in the Accelerate Framework

I am doing some matrix operations in Swift and I am using the Accelerate framework to do so. I need to be able to find matrix powers efficiently. To do that I diagonalise a matrix by finding its eigenvalues and eigenvectors (using the dgeev_…
0
votes
1 answer

How can I get an algorithm to do a exponentiation of a float exponent?

I'm developing a small application in Deluge (zoho.com). There isn't a "^" operator or a "pow" function to do exponentiation. Getting worst, I'm supposed to do exponentiations also with float exponents, instead just integer exponents. I've found a…
Alex
  • 3,325
  • 11
  • 52
  • 80