infusion / Complex.js

Complex.js is a com numbers library written in JavaScript
https://raw.org/article/complex-numbers-in-javascript/
MIT License
232 stars 33 forks source link

Behaviour of z^Infinity and Infinity^z #24

Open harrysarson opened 6 years ago

harrysarson commented 6 years ago

What does the Riemann mapping say when it comes to the complex exponential?

@derknorton @balagge

derknorton commented 6 years ago

My understanding is that all mathematical operations that work in the complex plane work the same way on the Riemann sphere. So the results of complex exponential operations that land in the complex plane get mapped to the appropriate place on the Riemann sphere. This includes zero and all four infinities (which map to the poles).

On Mar 9, 2018, at 5:36 AM, Harry Sarson notifications@github.com wrote:

What does the Riemann mapping say when it comes to the complex exponential?

@derknorton https://github.com/derknorton @balagge https://github.com/balagge — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1eYg5265IBEFelQUwroPF1Ie1_shAks5tcndUgaJpZM4SkNEU.

harrysarson commented 6 years ago

What does that make Complex(Infinity).exp() equal to?

derknorton commented 6 years ago

Since z^n is the same as z z ... z and Infinity Infinity => Infinity I would say the answer should be Infinity.

On Mar 9, 2018, at 8:46 AM, Harry Sarson notifications@github.com wrote:

What does that make Complex(Infinity).exp() equal to?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-371850345, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1eWHCXBVLQqHp6JEpvCkubJCgNAeGks5tcqPggaJpZM4SkNEU.

balagge commented 6 years ago

indeterminate. (no value, NaN, whatever. same as 0 / 0)

balagge commented 6 years ago

wolfram: kepernyokep 2018-03-09 17 26 18

balagge commented 6 years ago

This is because kepernyokep 2018-03-09 17 32 33 which means that if z = x + iy and z goes to infinity, then we cannot determine the limit of exp(z). For example, take the following z values: 0, i, 2i, 3i, .... Then the limit exp(0), exp(i), exp(2i), ... will be meaningless, as exp(n i) = cos n + i sin n, which is essentially a "random" point on the unit circle, clearly does not converge (neither to infinity, nor to any given complex number)

balagge commented 6 years ago

or, if you take the z values: 0, i*pi, 2 i*pi, 3 i*pi, etc. (clearly z goes to infinity) then the exp(z) values will be +1, -1, +1, ... as exp(n i pi) is -1 if n is odd and + 1 if n is even. complex exponentiation is always tricky.

balagge commented 6 years ago

truly confusing, I never liked this part of complex theory. https://en.wikipedia.org/wiki/Exponential_function#Complex_plane

balagge commented 6 years ago

this is how wikipedia pictures the complex exp function. pretty cool. Brightness means the absolute value, color means the direction.

Now if you approach infinity "to the right", then you will have a sequence that also goes to infinity. However, if you approach it "to the top" (as in the example I wrote above), then you will be going around the unit circle. Same with the bottom direction.

If you go left (to the same complex infinity) than the exponentiation will go to zero...

https://upload.wikimedia.org/wikipedia/commons/a/a7/Complex_exp.jpg

derknorton commented 6 years ago

I think Harry was asking about Infinity^z rather than z^Infinity. The first should be Infinity. I think you are correct that the second should be indeterminate (NaN).

On Mar 9, 2018, at 9:27 AM, Paál Balázs notifications@github.com wrote:

wolfram: https://user-images.githubusercontent.com/13258533/37217878-1069145a-23bf-11e8-92be-e8594f029ba3.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-371862972, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1ec-FmRT0CCgVU8626ah22wFIN2FZks5tcq1ygaJpZM4SkNEU.

harrysarson commented 6 years ago

@derknorton Both cases are relivant but to clarify:

Complex(Infinity).exp() calculates e^Infinity so I was talking about the second case.

derknorton commented 6 years ago

Sorry, my mistake...

On Mar 9, 2018, at 11:29 AM, Harry Sarson notifications@github.com wrote:

@derknorton https://github.com/derknorton Both cases are relivant but to clarify:

Complex(Infinity).exp() calculates e^Infinity so I was talking about the second case.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-371904065, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1eZLnTvBQSoALVpXUiMjs0enyuLT7ks5tcsoQgaJpZM4SkNEU.

harrysarson commented 6 years ago

To summarise for complex z : 1) 0 ^ Infinity === 0 2) 1 ^ Infinity === 1 2) z ^ Infinity === |z| < 1 ? 0 : NaN 3) Infinity ^ Infinity === NaN 4) Infinity ^ 0 === NaN 5) Infinity ^ 1 === Infinity 6) Infinity ^ z === Infinity

maybe?

derknorton commented 6 years ago

I think #3 should result in Infinity for |z| > 1

On Mar 9, 2018, at 11:36 AM, Harry Sarson notifications@github.com wrote:

To summarise for complex z :

0 ^ Infinity === 0 1 ^ Infinity === 1 z ^ Infinity === |z| < 1 ? 0 : NaN Infinity ^ Infinity === NaN Infinity ^ 0 === NaN Infinity ^ 1 === Infinity Infinity ^ z === Infinity — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-371906406, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1eVGBKrsd7RXaE1CKXj1aXgiOwA_Cks5tcsusgaJpZM4SkNEU.

harrysarson commented 6 years ago

https://github.com/infusion/Complex.js/issues/24#issuecomment-371865945 says it should not

derknorton commented 6 years ago

That's fine, but we should clarify (especially in the code) that for real z the third one approaches Infinity for |z| > 1 ;-)

On Mar 9, 2018, at 12:01 PM, Harry Sarson notifications@github.com wrote:

24 (comment) https://github.com/infusion/Complex.js/issues/24#issuecomment-371865945 says it should not

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-371913349, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1eeBq_k-nR2CzcsMxIO17QWtuU7l-ks5tctGGgaJpZM4SkNEU.

balagge commented 6 years ago

Wait. There are quite a few problems with exponentiation in the general cases. As a start, check out https://en.wikipedia.org/wiki/Exponentiation#Complex_exponents_with_positive_real_bases and https://en.wikipedia.org/wiki/Exponentiation#Powers_of_complex_numbers just to see the complexity of the issue. It is not necessary to understand everything (or anything), but it is quite clear that exponentiation has a lot of pitfalls on the complex plane and cannot be easily handled.

Whenever an exponentiation involves Infinity (which, on the Riemann sphere means a single complex infinity), the only way to define the meaning is by using limits, so e.g. a ^ Infinity is the limit of a ^ z where z -> Infinity. However, determining such limits is not always intuitive, and, for some of the cases, even the simple exponentiation z ^ w (neither being Infinity) is hard.

I thought the question was about e ^ Infinity, because that is usually understood by the function exp(), and I think the Complex library has the same meaning.

balagge commented 6 years ago

So I checked all of the other examples first on Wolfram Cloud, and actually most of them are indeterminate. I am still working on understanding each case, but there are serious challenges here, although I have a degree in math :)

Ok, so:

  1. 0 ^ Infinity is indeterminate. This one is not so difficult to see, because choosing a sequence z_n = 1, 2, ..., you get 0 ^ (z_n) = 0,0,0,..., however another sequence w_n = -1, -2, -3, ... yields 0 ^ (w_n) = Infinity, Infinity, Infinity, ..... Therefore, the expression 0 ^ z has no definite limit if z -> Infinity.
balagge commented 6 years ago
  1. 1 ^ Infinity is indeterminate. This I do not understand as of yet. Still working on it.
balagge commented 6 years ago
  1. z ^ Infinity is indeterminate, even if |z| < 1. This would require determining a definite limit for z ^ w (where w -> Infinity). However, unless z is a positive real number, such powers are difficult to calculate and some (most) do not even have a single well-defined value, but many different (sometimes infinitely many different) possible results. As I have said before, exponentiation on the complex plane is hard and counter-intuitive.

Quote from wikipedia:

"Trying to extend these functions to the general case of noninteger powers of complex numbers that are not positive reals leads to difficulties. Either we define discontinuous functions or multivalued functions. Neither of these options is entirely satisfactory."

In other words, z ^ w is better left undefined, unless z is a positive real.

This means that the infinite case, z ^ Infinity should, in my opinion, be indeterminate for the general case (z is not a positive real).

However, for the positive real case: this is also indeterminate, unless z = 1, which is the case above, and I am not sure about it. This case is basically very similar to e ^ Infinity, because a power a ^ w can be solved by writing a ^ w = e ^ (ln(a) w ). Then decompose w = x + i y, you get e ^ (ln(a) * (x + i y)), which is e ^ (ln(a) x + i ln(a) y) = a ^ x * (cos (ln(a) y) + i sin (ln(a) y). This is a bit of a mess at first sight, but it is essentially the same as the natural base case mentioned earlier, unless a = 1. For a <> 1, you can always choose some silly w's, so that e.g. the real part of w (which is x) is fixed, and then you get "random" numbers on the circle with radius a^x, clearly divergent.

balagge commented 6 years ago
  1. Infinity ^ Infinity === NaN that is correct.
  2. Infinity ^ 0 === NaN
  3. Infinity ^ 1 === Infinity that is correct by definition.
  4. Infinity ^ z is, unfortunately, again indeterminate, unless z is a non-zero real number. However, for reals, this may have a value: Infinity ^ x is Infinity, if x is positive, 0 if x is negative. I am a bit tired to be 100% sure, but this is what Wolfram gives as a result and it seems ok.
balagge commented 6 years ago

Summary:

Any exponentiation involving Infinity (either as base or exponent) is indeterminate, except:

(6) Infinity ^ 1 === Infinity, (7a) Infinity ^ z === Infinity, if z is a positive real number (Im(z) === 0, Re(z) >0) (7b) Infinity ^ z === 0, if z is a negative real number (Im(z) === 0, Re(z) < 0)

And, the only question is the result of 1 ^ Infinity, but I need some more time on that one. (but wolfram gives indeterminate for that as well)

harrysarson commented 6 years ago

For (7b) could we qnot have Infinity ^ z === 0 if the real part of z is negative. Wolfram agrees: image.

I can buy that (1), (3) and (4) should all be NaN.

As for 1 ^ Infinity, could this not be 1? The best argument that I can think of against this is that it is z ^ Infinity is NaN for all z !== 1 so it might as well be NaN for 1 aswell.

harrysarson commented 6 years ago

To summarise for any complex z:

1) z ^ Infinity === NaN 2) Infinity ^ z === Infinity if Im(z) === 0 and Re(z) > 0 3) Infinity ^ z === 0 if Re(z) < 0 4) Infinity ^ 0 === 1 5) Infinity ^ z === NaN otherwise

Question: should Infinity ^ 0 === 1 which would fit with behavour for Numbers in js?

derknorton commented 6 years ago

On Mar 14, 2018, at 5:46 PM, Harry Sarson notifications@github.com wrote:

To summarise for any complex z:

z ^ Infinity === NaN Infinity ^ z === Infinity if Im(z) === 0 and Re(z) > 0 Infinity ^ z === 0 if Re(z) < 0 Infinity ^ z === NaN otherwise Question: should Infinity ^ 0 === 1 which would fit with behavour for Numbers in js?

I would think so, since I thought mathematicians had defined anything to the zeroth power as 1, but we should ask the real mathematician ;-) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/infusion/Complex.js/issues/24#issuecomment-373212248, or mute the thread https://github.com/notifications/unsubscribe-auth/AFk1ec03ZkMb-ucHs4svV_Mmbjl_M_Ocks5teavwgaJpZM4SkNEU.

harrysarson commented 6 years ago

image

balagge commented 6 years ago

@harrysarson

For (7b) could we qnot have Infinity ^ z === 0 if the real part of z is negative.

you are right, provided that exponentiation is otherwise defined with a fixed branch cut of the log() function.

Wikipedia has a good explanation on how to compute a complex power:

https://en.wikipedia.org/wiki/Exponentiation#Computing_complex_powers

So if we want to compute w^z, we must choose a branch cut of log(), normally (-pi, pi]

Then w must be written in polar decomposition w = r e^(i theta) (choosing theta so that pi < theta <= pi, the principal branch cut), and z in Cartesian decomposition z = c + d i). The following formula gives the result:

w^z = r^c e^(-d theta) (cos(d log(r) + c theta) + i sin (d log(r) + c theta))

This indeed converges if Re(z) = c < 0 (w -> Infinity) , because the r^c part will converge to 0, the e^(-d theta) part is within a fixed range (here we use heavily that theta is in a fixed finite interval), and the rest is just a point on the unit circle, again bounded.

Generally, with multi-valued powers, this does not work, because theta can have any value and might "work against" the r^c part, hence no convergence.

Bottom line: if Complex.js defines z^w using this approach of a fixed branch cut, then Infinity^z = 0 if Re(z) < 0. You are right, I was wrong. :)

balagge commented 6 years ago

For Infinity ^ 0 all material that I can find says it is indeterminate (even with real infinity)

https://en.wikipedia.org/wiki/Indeterminate_form

Infinity ^ 0 cannot be computed with lim z^0 (z -> Infinity). (That approach would yield Infinity * 0 = 0 as well, clearly wrong, az Infinity * 0 is also indeterminate)

The right way is with lim z^w (z -> Infinity, w -> 0). And that does not converge generally.

balagge commented 6 years ago

Funny that javascript has Math.pow(Infinity,0) === 1. Yeah, that is a problem. But javascript also has Math.pow(-2, Infinity) === Infinity, which is even more silly. I do not know where they got that idea ...