Jump to content

[SOLVED] Fractional Indices and Negative Numbers


GingerRobot

Recommended Posts

Unfortunately i dont think its quite that simple.

 

For example, you should get answers with the following inputs of:

 

(-1)^1/2 = i

(-1)^1/3 = -1

(-1)^1/4 = 0.70711+0.7011i - the numerical values are actually sin(45 degrees) if you're interested

 

At present, your code returns i for all of these inputs.

 

I might take a look later and see if i can come up with a solution. I dont think it's going to be easy though.

Link to comment
Share on other sites

as far as i know, the order of operations dictates that the numerator of a rational exponent is evaluated first (assuming one re-writes the expression as a power beneath a root sign).  by that logic, the only case where a^(m/n) will produce a complex number is when a < 0, m is odd, n is even.

 

regardless, whether a root is complex or not is rather a matter of definitions and semantics in the case of rational exponents, not actual programming.  might as well save yourself a headache and take the absolute value of 'a'.  as you yourself pointed out, one could simply multiply any given rational expression by 2/2 and obtain an identical exponent (based on group theory) which won't jar your script.  you could always add an 'i' to the final output if you want to, but it would be a largely arguable point.

Link to comment
Share on other sites

However, im fairly sure there is nothing to say that you have to use the fractional power inside the bracket. As far as i know (x^(1/b))^a is identical to (x^b)^(1/a).

 

Definitely one for my maths teacher i think.

 

At your service :)

 

Take the rule here:

 

(x^m)^n = x^(mn)

 

From this it follows that

 

(x^(1/b))^a

= x^(a/b)

 

(x^a)^(1/b)

= x^(a/b)

 

I assume that's what you meant, not (x^b)^(1/a)

 

These rules certainly don't work for b=0, and I would have doubts once things start getting negative..

Link to comment
Share on other sites

Sorry, yes you're right. I put the fraction with the wrong letter. However, you agreeing that

 

(x^(1/b))^a is the same as (x^a)^(a/b) ?

 

In which case, i think im back where i started.

 

Also, whilst you say the rules don't hold for b=0, that is simply due to the fact that x/0 is undefined - however you manipulate the expression, at some point you must divide by b, making the calculation impossible.

Link to comment
Share on other sites

(x^(1/b))^a is the same as (x^a)^(a/b)

 

(x^(1/b))^a is the same as (x^a)^(1/b), rather :P

 

Also, whilst you say the rules don't hold for b=0, that is simply due to the fact that x/0 is undefined - however you manipulate the expression, at some point you must divide by b, making the calculation impossible.

 

That's what I meant, sorry for not being clearer.

 

Anyway, what is your current goal, when you say you are back where you started?  Are you still thinking about the apparent paradox in your earlier post?  I think the solution there is that you simply can't take the 3 and 6 inside, because that rule doesn't apply for x < 0.  So you have to use other methods to solve, and those other methods will give you a correct result.

Link to comment
Share on other sites

(x^(1/b))^a is the same as (x^a)^(1/b), rather :P

 

Whoops. Though it was 7 in the morning -thats my excuse anyway :P

 

As for current goal, i think i've satisfied my original motivation for posting, which was that i'd noticed that php couldn't deal with negative bases and fractional powers.

 

I've largely just been trying to understand, from a mathematical point of view, how/why it works/doesn't work. I think ill mark this as solved now, although im sure im going to continue my searches on the internet.

 

And thanks everyone, for all your help.

Link to comment
Share on other sites

I think Barand is talking about this:

 

4(x-2)^2

= 4(x-2)(x-2)

= 4(x^2 - 2x -2x + 4)

= 4(x^2 - 4x + 4)

= 4x^2 - 16x + 16

 

No complex numbers involved there..

 

The lesson is, don't do maths in your head and drive!  The same rule applies when not driving.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.