An efficient algorith to evaluate exp(A)

  • Context: Undergrad 
  • Thread starter Thread starter Karlisbad
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around finding efficient algorithms to evaluate the exponential function e^A, particularly for large values of A. Participants explore various methods, including approximations and computational techniques, without reaching a consensus on the best approach.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested, Mathematical reasoning

Main Points Raised

  • Some participants suggest using logarithmic approximations to estimate e^A, while others mention the potential for reducing multiplications using techniques similar to RSA fast exponentiation.
  • One participant notes that e^A has approximately A/3 digits, implying that the complexity of computation is O(A).
  • There is a discussion about the feasibility of calculating e^A using programming, with one participant sharing their experience of computing e^A for values up to a million in under a minute, emphasizing the importance of accuracy and the size of A.
  • Participants discuss the "square and multiply" method for exponentiation, explaining how it can optimize the computation by reducing the number of operations needed.
  • Another participant mentions precomputing values of e raised to powers of two to further enhance efficiency, suggesting that this method could apply to floating-point exponents as well.
  • There is a consideration of the numerical stability of different algorithms, particularly in relation to trigonometric functions, though no definitive conclusions are drawn.

Areas of Agreement / Disagreement

Participants express various viewpoints on the efficiency and methods for computing e^A, with no clear consensus on a single best approach. Disagreements exist regarding the applicability of certain techniques and the trade-offs involved in accuracy and computational time.

Contextual Notes

Participants highlight limitations related to accuracy and the size of A, as well as the dependence on computational methods and definitions of efficiency. The discussion does not resolve these issues.

Who May Find This Useful

This discussion may be of interest to those involved in computational mathematics, algorithm design, or programming, particularly in contexts where efficient evaluation of exponential functions is required.

Karlisbad
Messages
127
Reaction score
0
let be "A" a big number, my question is, is there an efficient algorith (with only a few steps) to evaluate e^{A} :confused:
 
Mathematics news on Phys.org
I'm certainly no expert on this, but you could get an order-of-magnitude approximation by taking the logarithm. Also, you could reduce the number of multiplications used in an exact answer to only log A by using the same technique used in RSA fast exponentiation.
 
e^A
has approximately
\frac{A}{3}
digits.

Hence, the best you can do is going to be O(A).
 
0rthodontist said:
I'm certainly no expert on this, but you could get an order-of-magnitude approximation by taking the logarithm. Also, you could reduce the number of multiplications used in an exact answer to only log A by using the same technique used in RSA fast exponentiation.

The RSA thing only works for modular arithmetic.
 
do you mean using a computer on a program, or using your head?

how big do you want A to be?

just for ref, i quickly wrote a c++ program that can get you values of e^A where A is in the order of a million in less than a min, although i cheated and gave it a starting value of e

but you need to know a few things first if you are writing a program for this

* e^x is an irrational number just like for example pie, so getting it exact is impossible,

* thus you need to limit yourself to some sort of accuracy

* what order of A do you want to calculate to

* if your accuracy is only to a few sig figures , perhaps upto 10sig fig, then you can write a computer program to give you e^x where x is any number, the program if written well will not take very long to run, probably in the order of a few min max

* the accuracy and value of a will be the main factors in the time to compute
 
NateTG said:
The RSA thing only works for modular arithmetic.
No, not that technique, the one that splits up the exponent. It would take me some time to remember it but the basic idea is that if you have an exponent like 2n, it computes x^n and then squares it.
 
0rthodontist said:
No, not that technique, the one that splits up the exponent. It would take me some time to remember it but the basic idea is that if you have an exponent like 2n, it computes x^n and then squares it.

I think you mean the repeated squaring idea for finding exponents? To find x^n you first find x^1, x^2, x^(2^2), x^(2^3), x^(2^m) where 2^(m+1)>n. this takes some log(n) squaring operations. Then write n in binary and multiply the appropriate numbers from your list to get x^n, another log(n) multiplications in the worst case. For example x^11=(x^1)*(x^2)*(x^(2^3)).

I don't think this has a standard name, and it's not an rsa specific thing of course.
 
Yes, that's it. It's called "square and multiply" exponentiation.
 
cells said:
* if your accuracy is only to a few sig figures , perhaps upto 10sig fig, then you can write a computer program to give you e^x where x is any number, the program if written well will not take very long to run, probably in the order of a few min max
The goal, of course, is to get that "few minutes" down to "few milliseconds". :smile:


0rthodontist said:
Yes, that's it. It's called "square and multiply" exponentiation.
If your exponent is a C integer, then there's a nice optimization you can do; you can simply precompute

e^1, e^2, e^4, e^8, ..., e^(2^31)

and then you don't have to bother with squaring. :smile:


I think a similar method is good for any floating point exponent. (Though you might want to choose a different class of precomputed values)



On a related note, the same sort of "shift-and-add" algorithm works for trig functions... in particular, sinh x and cosh x. (use the addition and double-angle identities) I wonder if that version is more numerically stable than repeatedly squaring & multiplying e? Probably not, but worth a look.
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
928
  • · Replies 41 ·
2
Replies
41
Views
7K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K