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
1 answer

Computing the powers of a polynomial f(x) modulo irreducible polynomial h(x) in MATLAB

Suppose I have a polynomial f(x)= a_0 + a_1*x + a_2*x^2 +...+ a_(n-1)*x^(n-1) with a_i elements of F_q, q prime. How do I compute the powers f(x)^0, f(x)^1, f(x)^2, ..., f(x)^k modulo another polynomial h(x) of degree n for any positive integer k…
0
votes
2 answers

C++ Division with modulo

I want to calculate result of this equation [(pow(4, p) - 1) / 3] % q I wrote a function pow that returns p-th power of 4 mod q, but I can't apply it here. How can I do it? p, q are integers and could be large - up to 1 000 000 000. Thanks in…
tomwesolowski
  • 956
  • 1
  • 11
  • 27
0
votes
1 answer

Unpacking Exponent factors table multiplied packed value back into original values

I have this poker card game where a possible 13 card ranks stored as [0 to 12]. Each hand which holds 5 cards which have 13 possible card ranks. The final value is a identifier which begins from the exponent 13⁵ (to power of 5). Which stores what…
SSpoke
  • 5,656
  • 10
  • 72
  • 124
0
votes
2 answers

Convert a math equation in string format to something workable in Python3

So I have a function that takes a math equation in string format, and a list of numbers. The purpose of the function is to apply that function to each number (an exponent function), and return the result. For example, I am trying to pass "x**4" to…
user1768884
  • 1,079
  • 1
  • 20
  • 34
0
votes
1 answer

modular exponentiation in vhdl

I need to implement a modular exponentiation in vhdl for a spartan 6, with google i found the following paper describing a fast implementation for an virtex 4 https://www.iacr.org/archive/ches2007/47270272/47270272.pdf I'm wondering if it could be…
0
votes
2 answers

Prolog Power Function

I am new to Prolog and while I can understand the code, I find it hard to create a program. I am trying to create a function that takes an integer and return 2^(integer) example pow(4) returns 16 (2^4). I also need it to be in a loop to keep taking…
user3241846
  • 643
  • 3
  • 9
  • 26
0
votes
1 answer

for Loop in Java - exponents

Basically, there is a group of 20 sheep. After the group has grown to a population of 80 sheep, the group does not need to be supervised anymore. The number of sheep, N, each year, t, is found with : N = 220/(1 + 10(0.83)^t) This program tries to…
Freedom
  • 347
  • 2
  • 7
  • 24
0
votes
3 answers

Time complexity of powering a number

Learning from MIT Opencourseware's algorithms course, a professor talks about powering a number and its time complexity. x^n simply is computed as x*x*x...... n times (imagine a simple for loop with a multiplication being performed inside it) He…
user720694
  • 2,035
  • 6
  • 35
  • 57
0
votes
1 answer

Eval() freeze for large exponents

I've been making a genetic program and I've come across a problem. It seems that it will try to calculate large exponents but freeze (which is understandable, because it is a large number) in the process. Is there any way to time the execution? This…
user2514631
  • 187
  • 1
  • 1
  • 6
0
votes
1 answer

Expression involving modular exponentiations in C++

I am wanting to evaluate the expression, (an + bn + cn) % 1000000003 , in C++. I a getting overflow errors when n is very large. Can someone help me with this ? More specifically a = q + 1, b = - 2 * q and c = q - 1. I have been following the…
0
votes
3 answers

Recursive Exponentiation Racket Programming

#lang eopl (define (expo base n ) (cond( (or (= base 1) (= n 0) ) 1) (else ( (* base (expo(base (- n 1))) ) ) ))) -> (enter! "expo.rkt") "expo.rkt"> (expo (2 1) ) ; application: not a procedure; ; expected a…
knowKnothing
  • 45
  • 2
  • 10
0
votes
2 answers

Exponentiation of real numbers

I've come across an interesting exercise and it says: Implement a function x^y using standard functions of Turbo Pascal For integer variables I can use for loop but I cannot understand how to work with real variables in this case. I've been thinking…
yulian
  • 1,601
  • 3
  • 21
  • 49
0
votes
1 answer

fmodl - Modulus in long double

#include #include using namespace std; unsigned long long modExp(unsigned long long b, unsigned long long e, unsigned long long m) { unsigned long long remainder; unsigned long long x = 1; while (e != 0) { …
0
votes
1 answer

Pow-like function for negative base case

std::pow is fine for most combinations of base and exponent values. However when the base is negative and fractional, std::pow keels over. In the example below NaN is returned (as per definition), when the expected value is roughly:…
Gerdiner
  • 1,435
  • 3
  • 15
  • 19
0
votes
1 answer

Doubles and Code Accuracy: What Is Wrong?

I'm having trouble with the accuracy of the exponentiation of doubles and their sums in the following code: public static void main(String[] args) { for(double A = 1; A <= 100; A++) { for(double B = 1; B <= 100; B++) { …
J0nathan
  • 1
  • 1