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
1
vote
2 answers

Exponentiation function Haskell

How to get the exponentiation function in church numerals using Haskell? I'm trying to apply the rule, which is λxy.yx but something doesn't work right. exponentiation :: (Num a) => Func a exponentiation x y = y x
thali
  • 13
  • 3
1
vote
1 answer

Exponentiation with fractional power in a prime finite field

I'm trying to do some exponentiation in the finite field modulo prime GF(8191) and I'm not sure why I don't get consistent results. I compare those formulas: with and which should return the same result (at least it does in ) The Sage code is…
Eric
  • 1,138
  • 11
  • 24
1
vote
1 answer

TypeError from attempted exponentiation

I am trying to graph as a function of r the probability for finding the electron in the ground state of the two dimensional and three-dimensional hydrogen atom. The code I have right now is: import math import matplotlib.pyplot as plt import numpy…
1
vote
1 answer

Python, exclusive exponentiation from a string input

While working within python 3, I have created a calculator that accepts string inputs such as "-28 + 4.0/3 * 5" and other similar mathematical equations. As an exercise I had wanted to support exponentiation through use of the '^' key such that…
1
vote
1 answer

Left to right binary modular exponentiation in Javacard

I am thinking to implement left to right binary modular exponentiation in Javacard. I know that there are libraries which can perform RSA encryption etc. but in my case I just need to perform the modular exponentiation. The only thing that I am…
TechJ
  • 512
  • 2
  • 5
  • 16
1
vote
1 answer

How to implement scalar raised to the power of a matrix in Eigen?

I have the following code in MATLAB that I wish to port to C++, ideally with the Eigen library: N(:,i)=2.^L(:,i)+1; Where L is a symmetric matrix (1,2;2,1), and diagonal elements are all one. In Eigen (unsupported) I note there is a function to…
Nick Wilton
  • 113
  • 6
1
vote
2 answers

Floating exponent exponentiation algorithm

I must to write a algorithm that exponentiates a base (integer or float) in a integer or float argument. I wrote this algorithm for Deluge (zoho.com), but it can only use integer exponents: float math.potencia(float base, int expoente) { …
Alex
  • 3,325
  • 11
  • 52
  • 80
1
vote
2 answers

Python exponentiation of two lists performance

Is there a way to compute the Cobb-Douglas utility function faster in Python. I run it millions of time, so a speed increase would help. The function raises elements of quantities_list to power of corresponding elements of exponents list, and then…
user58925
  • 1,537
  • 5
  • 19
  • 28
1
vote
1 answer

Python finite field matrix exponentiation

Is there a simple way to calculate (especially powers/exponetiation) with matrices whose elements are integers from finite field, or at least arbitrary integer precision matrices with support of % operator? For example let's say we have a matrix A…
user5125238
1
vote
4 answers

How to check if a^b is smaller than n

given 2 positive integers a and b (1 < a,b < 10000), I want to make sure a^b < 10000. the problem is I can't just solve a^b, given that 64^64 is long enough to break integer size. how can I have this answer fast? I thought about using…
user5162677
1
vote
2 answers

exponentiation in Data Structures and Algorithm Analysis in C

When addressed exponentiation in chapter 2, the author mentioned "The number of multiplications required is clearly at most 2 log n(the base is 2), because at most two multiplications (if n is odd) are required to halve the problem. Again,a…
Jedore
  • 333
  • 3
  • 13
1
vote
1 answer

How can I evaluate simple math expressions in es?

For reference, I'm using this version of the shell. I'm looking to evaluate a math expression containing exponents. How can I do so? expr isn't available in es-shell, and neither do the double parends work (as they do in other shells). The…
user5458362
1
vote
1 answer

Modular Exponentiation with big numbers

I'm Trying to implement modular exponentiation algorithm. I have some class: template< typename T> class SomeMathFun { ..... } and it has method: static T ModularExp(T base, T exp, T modulo) { T result(1); base %= modulo; while…
NonSense
  • 173
  • 1
  • 2
  • 13
1
vote
0 answers

Exponentiation of a floating number

I am trying to print the exact exponentiation of a floating number but i failed to print the digits of the exponentiation after 5 decimal digits. What should be done in order to get rest of the digits? Example: 1.0100 ^ 12 =…
BlackBeard
  • 31
  • 4
1
vote
1 answer

Modular exponentation in C

Help! I need to implement a C program (using only string, stdlib, and stdio libraries) which use modular exponentiation of really big numbers, some of them is 260 digits. I'm thinking of using a linked list but I cannot find a good reference on how…
Xael Yvette
  • 77
  • 1
  • 9