Exponentiation of negative numbers

Revision as of 22:27, 15 October 2008 by Lchrisman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The operator x^y raises x to the yth power.

This page discusses how Analytica treats exponentiation in the case where x is negative and y is non-integer. It also describes some of the mathematical theory behind this case.

Mathematical Theory

When x is negative and y is not an integer, the mathematical situation is somewhat ambiguous. With infinite numeric precision, the correct result of x^y is mathematically well-defined without ambiguity. Certain values of y yield an imaginary number as a result, while other values of y result in a real-valued result. Specifically, when x<0, the result of x^y is real-valued exactly when y can be written as a fraction, m/n, where m is an integer and n is an odd integer. Furthermore, the result is positive when m is even and negative when m is odd. When y cannot be written as such, the result would be an imaginary number.

From this theory, it follows that values of y that result in real-valued results are dense in the real-number line. In other words, for any value of y, there is a value arbitrarily close to y that results in a real-valued solution. However, it also follows that these solutions are non-continuous. For any value of y that results in a real-valued result, there is another value arbitrary close that results in a real-valued result with the opposite sign. Consider the following example (the theoretical result is shown):

(-27)^(1/3) → -3
(-27)^(10000000000000/30000000000001) → +3

This lack of continuity presents a practical problem for computer models that want to raise negative numbers to fractional powers. Because computers store fractional numbers using finite-precision representations, the value stored in memory should always be considered a close approximation to the true value that is being represented. When you raise a negative number to a fractional power, there is no way to know whether that true value is even rational, and if it is, whether it would correspond to the positive or to the negative solution.

What does Analytica do?

Analytica 4.1 and earlier returns NaN in all cases in which x<0 and y is non-integer.

Analytica 4.2 and later will return real-valued results for certain fractional values of y when x<0. Loosely speaking, it returns a real-valued result only when the y value is very close to a simple fraction with an odd denominator. For example, real-valued results are obtained for the following cases:

x^(1/5)
x^(3/11)
x^(2/17)
x^(-11/9)

However, the following cases would not be treated as being "simple fractions", and would thus result in NaN:

x^(10/49)
x^(30/111)
x^(19/169)
x^(110/89)

Comparing these to the previous cases, you'll note that the fractions are very close numerically, yet would result in results with differing signs.

The rule used by Analytica to decide whether a fractional exponent is a "simple fraction" is somewhat difficult to characterize, but chosen because it can be computed quickly. A few generalities can be stated. If your exponent is very close to a fraction of the form 1/n where n is an odd-integer, it will generally be recognized. Additionally, it will generally be recognized as a valid fraction if it is very close to a rational number having an odd denominator of 21 or less.

Comments


You are not allowed to post comments.