Why is (-1)^1.2 not defined?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Why is (-1)^1.2 not defined?

Post by Bindie »

Hey, little math problem as mentioned.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Why is (-1)^1.2 not defined?

Post by s-ol »

Bindie wrote:Hey, little math problem as mentioned.
Because it is defined as the 6th root of -1, to the power of 5 (1.2 = 6/5). The root of negative numbers is not defined in general math.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: Why is (-1)^1.2 not defined?

Post by Bindie »

Of course. There is no root of (-1), complex numbers. I didn't see 1.2 as a rational number. :) Like a (a/b) number.
Muris
Party member
Posts: 131
Joined: Fri May 23, 2014 9:18 am

Re: Why is (-1)^1.2 not defined?

Post by Muris »

I would guess at least some math libraries would define it something as:
{ re = cos 1.2pi, im = sin 1.2pi }

and if not, you can probably define it yourself.
Bindie
Party member
Posts: 151
Joined: Fri Jan 23, 2015 1:29 pm

Re: Why is (-1)^1.2 not defined?

Post by Bindie »

It's not that important, ^2 was too high so I figured I'd use ^1.2, however it didn't work with negative numbers and now I know why. Of course 1.2 is a a/b kind of numeral, and as S0lll0s said, more or less a root of a number.
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Why is (-1)^1.2 not defined?

Post by Ranguna259 »

Actualy there are roots for negative numbers but the index has to be odd:
Even index:

Code: Select all

(-1)^(1/2) = 2root-1 = i (or error)
Same goes for 4root, 6root, 8root, (2*x)root where x is a natural number

Odd index:

Code: Select all

(-1)^(1/3) = 3root-1 = -1
Same goes for 1root, 5root, 7root, (3*x)root where x is a natural number or 1/3
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Why is (-1)^1.2 not defined?

Post by zorg »

Ranguna259 wrote:Actualy there are roots for negative numbers but the index has to be odd:
...

Code: Select all

(-1)^(1/3) = 3root-1 = -1
Except lua still won't calculate that with the default lib routines; it gives -nan in the online interpreter.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests