Unintuitive behavior of x^y for x<0

77 Views Asked by At

I take advantage of mathematics a lot while programming, but in spite of that I'm very mathematically ignorant. Sorry if I'm asking something stupid.

Often I need to exponentially amplify some values. I usually start using exponentiation ($x^y$), but this gives me obvious problems whenever $x<0$.

What I would need is something similar to $|x|^y sgn(x)$: a function that amplifies $x \in \mathbb R$ (while keeping its sign) by an exponent $y \in \mathbb R^+$. (Possibly $|x|^{e^y} sgn(x)$ with $x,y \in \mathbb R$ would be even better)
Such function has no discontinuities and I find it easy to use and reason about.

I've got the feeling that amplifying a value exponentially is a very common use case when designing functions, and usually I realize that $x^y$ doesn't cut it only by trial and error.


This makes me wonder:

  1. Why a function as common and standard as $x^y$ has such a weird behavior for $x<0$?

I understand that $(-x)^2=(-x) \cdot (-x) = x^2$, but this definition only applies to $y \in \mathbb N$ anyways. Its extension to $y \in \mathbb R$ (and thus to $x<0$ too) could have been different.

And then:

  1. Does the function I'm looking for have a name?
2

There are 2 best solutions below

0
On BEST ANSWER

That it is easy to write something does not necessarily mean that it is easy to give it a useful definition. It is easy to write $\frac{0}{0}$ but it is not easy to define in a useful way. A similar problem applies to $0^0$. For most $x$, $x^0 = 1$ so that is a tempting definition but also $0^x = 0$ for $x > 0$ so that is also a tempting definition. In some specific contexts, we might accept one of these definitions (or something else) but in general we just leave these expressions undefined.

$x^y$ is a particularly complicated case. It started with very simple cases: $x^2 = x \times x$, $x^3 = x \times x\times x$, etc. Then it was extended to zero, and negative exponents. Next to fractional positive exponents and some negative. Finally, it was extended to arbitrary positive exponents but that is about the end of the road without hitting problems and hence where we generally stop.

I can see that your proposed function may have some practical use but it is less likely to be very interesting to theoreticians and I don't know any name for it.

You could study complex numbers which may help tidy up the details but at the cost of some new complications. This might be interesting but probably not useful to your needs.

Finally, note that terms in mathematics do not have official fixed definitions. There is no governing body for mathematics. You could define $x^y$ to suit you provided that you warn your readers. Similarly, when reading the work of others, be aware that they may be using different definitions to those that you are used to.

2
On

Crazy things are going on here just as in a recent post:

$(-5)^{1/2} = \sqrt{-5} = i\sqrt 5$ (imaginary), but $(-5)^{2/4} = \sqrt[4]{(-5)^2} = \sqrt[4]{25}$ (real).