exp

How can I use "e" (Euler's number) and power operation in python 2.7

How can I use "e" (Euler's number) and power operation? Question: How can I write 1-e^(-value1^2/2*value2^2) in Python? I don’t know how to use power operator and e. Asked By: Thanos Smar || Source Answers: Power is ** and e^ is math.exp: x.append(1 – math.exp(-0.5 * (value1*value2)**2)) Answered By: Daniel Python’s power operator is ** …

Total answers: 7

Deal with overflow in exp using numpy

Deal with overflow in exp using numpy Question: Using numpy, I have this definition of a function: def powellBadlyScaled(X): f1 = 10**4 * X[0] * X[1] – 1 f2 = numpy.exp(-numpy.float(X[0])) + numpy.exp(-numpy.float(X[1])) – 1.0001 return f1 + f2 This function is evaluated a huge number of times on an optimization routine. It often raises …

Total answers: 6