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

Displaying "stacked" and added exponents in Java

So I have been asked to create a program that can evaluate and print the value of... 0.1 + (0.1)^2 + (0.1)^3 . . . + (0.1)^n using a while loop. So far I have import java.util.Scanner; class Power { public static void main(String[] args) { …
Andrew M
  • 93
  • 8
0
votes
2 answers

Modular Exponentiation Issue in Java

import java.util.Scanner; class codeabbey145 { public static void main(String[] Args) { Scanner input = new Scanner(System.in); double A = 0; double B = 0; double M = 0; System.out.println("\n\nHow…
JDI
  • 19
  • 4
0
votes
0 answers

Sparse matrix exponentiation in RcppArmadillo

I'm trying to replicate the following R function in C++ using Rcpp and RcppArmadillo: function (M, t) { I = diag(nrow(M)) return(I %*% expm(t*M)) } where M is a Sparse squared Matrix of class "dgCMatrix" in the Matrix package and t is just a…
iq447
  • 11
  • 4
0
votes
1 answer

Prolog getting inifinite loop when asking for another solution

I am using SWI Prolog, the following code is used in my homework(the code is not the homework but needed to write the methods the course requires): nat(0). nat(s(X)) :- nat(X). plus(0,N,N) :- nat(N). plus(s(M),N,s(Z)) :- …
0
votes
2 answers

Why does **0.5 appear to be more efficient than sqrt()

I have tried measuring the speed of these two ways for taking square root: > system.time(expr = replicate(10000, 1:10000 ** (1/2))) ## user system elapsed ## 0.027 0.001 0.028 > system.time(expr = replicate(10000, sqrt(1:10000))) ## user…
Lytze
  • 755
  • 6
  • 12
0
votes
1 answer

Tail recursive exponentiation in Prolog

I'm trying to write the code which get 3 arguments when X is the coefficient, Y is the exponent and R should return the answer. My code till now is - exp(X,0,R):- R is X*X. exp(X,Y,R):- Y1 is Y-1, exp(X,Y1,R). I know it doesn't work. But I can't…
divelner
  • 244
  • 1
  • 2
  • 10
0
votes
0 answers

Select Sql Query returns ceiling Exponential value for big integer

I do have one field in sql table which contains Big Integer typed records, Now in my c# script when I fire select query on this table, it returns Exponential value instead of numeric value in DataTable I converted it by double.parse(expVal) and…
Amit
  • 1,821
  • 1
  • 17
  • 30
0
votes
3 answers

Trouble with signs on zero-exponents equations

Python seems to have trouble returning the correct value for numbers to the power of zero. When I give it a literal equation, it works properly, but it always returns positive 1 for anything more complex than a raw number to the zeroeth. Here are…
Augusta
  • 7,171
  • 5
  • 24
  • 39
0
votes
1 answer

How to force 0^0 be 1 in Maxima?

It is suitable in many series and polynomials to treat 0^0 as 1. Unfortunately, Maxima think it is expt. How to force?
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
0
votes
2 answers

Rebuilt Fortran code is twice as slow after updating to Ubuntu 14.04

Our parallel Fortran program is running more than twice slower after updating the OS to Ubuntu 14.04 and rebuilding with Gfortran 4.8.2. To measure which parts of the code were slowed down is unfortunately not possible any more (not without…
nukimov
  • 216
  • 1
  • 7
0
votes
2 answers

Power function in prolog

Exactly what's the Prolog definition for power function. I wrote this code and it give some errors I wanna know exact code for the power function. pow(X,0,1). pow(X,Y,Z):-Y1=Y-1,pow(X,Y1,Z1),Z1=Z*X. Anything wrong with this code?
NHans
  • 63
  • 2
  • 6
0
votes
2 answers

x86 Assembly - finding powers using addition

The program will accept two numbers from the user and display the sum, product, and power (a^b) of those two numbers. Here is the catch, however... The program MUST: Use an AddNumbers function Use that AddNumbers function in a MultiplyNumbers…
Bubz21
  • 15
  • 1
  • 4
0
votes
1 answer

Modular Exponentiation over a Power of 2

So I've been doing some work recently with the modpow function. One of the forms I needed was Modular Exponentiation when the Modulus is a Power of 2. So I got the code up and running. Great, no problems. Then I read that one trick you can make…
0
votes
0 answers

python power operator strange behaviour

I am trying to implement multivariate gaussian pdf. I have a strange issue with the ** operator.The code is def multi_var(x,mu,cov): #Multivariate gaussian print (1/2*np.pi)**(len(x)/2) …
user3443615
  • 155
  • 1
  • 1
  • 9
0
votes
0 answers

How do I use transform and conquer to simplify this algorithm?

I am aware that there are three ways transform and conquer can be used to simplify a problem. I'm trying to simplify the code of this one to become more efficient. The thing is, it's already in log n runtime. I was wondering how I could possibly…