1

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?
peoro
  • 127
  • I suspect there is some usage for this kind of function in engineering or physics. There is a similarity with the "symlog scale" in matplotlib: a logarithmic scale with both positive and negative values. – Jean-Claude Arbaut May 24 '19 at 10:43
  • 1
    One way to see that $x^y$ has problems with negative values of $x$ is to recall that the square of a real number cannot be negative. Hence we can get problems if $y$ is fractional. For example, if $x=-1$ and $y=1/2$, you have $(-1)^{1/2}$. By definition, this would mean a number that squares to $-1$, but there is no real number with this property and we will have to exit the realm of real numbers to give this meaning (we need to start going to complex numbers). Same problem occurs with any other negative value of $x$. – Minus One-Twelfth May 24 '19 at 11:00
  • Anyway, I'm not sure what application you have in mind, but if you take $y$ to be an odd positive integer, you can use $x^y$ even if $x$ is negative (and the sign of $x$ will be preserved). For example $x^5$ or $x^{11}$. – Minus One-Twelfth May 24 '19 at 11:07
  • @MinusOne-Twelfth The question is not about the usual $x^y$ with $x<0$. If you define $f(x,y)=sgn(x)|x|^y$, then this $f$ has no problem with negative $x$, and it could have been a reasonable definition of $x^y$ in the first place. It was not defined this way as we all know, but maybe there is nevertheless a name for this $f$. – Jean-Claude Arbaut May 24 '19 at 11:07
  • The question 1. is referring to "$x^y$" and refers to its "weird behavior" for negative $x$, so I assumed 1. refers to the usual $x^y$. – Minus One-Twelfth May 24 '19 at 11:09

2 Answers2

2

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.

badjohn
  • 8,204
0

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).

Wuestenfux
  • 20,964