Exponentiation

• Question

• There is a little ambiguity on the proper way to write the exponents in a function
So, I will make a little quiz

I want to compute this:

sin(3pi/4)   =    -0.70710678118654746

```        Dim Teta As Double = 3 * Math.PI / 4
Dim n As Double = 4
Dim X As Double

X = Math.Cos(Teta) ^ (2 / n) ' Returns: NaN

X = (Math.Cos(Teta) ^ 2) ^ (1 / n) ' Returns: 0.840896415253715

X = -0.70710678118654746 ^ (2 / n) ' Returns: -0.840896415253715
```

Thursday, May 9, 2013 1:41 PM

All replies

• The final result should not be a negative number under any circumstance.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Thursday, May 9, 2013 1:58 PM
• I would say the second statement

`X = (Math.Cos(Teta) ^ 2) ^ (1 / n) ' Returns: 0.840896415253715`

most closely follows the expression in your question.  However, I would argue that all three give the wrong answer.  Surely the correct answer is +/- 0.840896415253715

Thursday, May 9, 2013 2:04 PM
• I'd say none. The formula has sin() the code has cos().

Regards David R
---------------------------------------------------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
Every program eventually becomes rococo, and then rubble. - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

Thursday, May 9, 2013 2:09 PM
• ```Public Class Form1

Dim Teta As Double = 3 * Math.PI / 4
Dim n As Double = 4
Dim X As Double

X = Math.Sin(Teta) ^ (2 / n) ' Returns: NaN

Label1.Text = X.ToString

X = (Math.Sin(Teta) ^ 2) ^ (1 / n) ' Returns: 0.840896415253715

Label2.Text = X.ToString

X = -0.70710678118654746 ^ (2 / n) ' Returns: -0.840896415253715

Label3.Text = X.ToString

Label4.Text = Math.Sin(3 * Math.PI / 4).ToString

End Sub

End Class```

You've taught me everything I know but not everything you know.

Thursday, May 9, 2013 2:41 PM
• @ Blackwood

if you are right, it means that

SQRT( 0.840896415253715 )^4  =    sin(3pi/4)  = -0.70710678118654746

Which is false ...  SQRT( 0.840896415253715)^4 will obviously return a positive number

----------------------------------

@ nobody

This is fondamentalement false

X = -0.70710678118654746 ^ (2 / n)

What in fact this is computing is

X = - (  0.70710678118654746 ^ (2 / n))

------------------------------------

The right answer is NaN since it is the complex number ( 0.840896415253715 i )

that is the solution (Proof from reverse

SQRT ( 0.840896415253715 i )^4 =  -0.70710678118654746

------------------------------------

NB: since Blackwood is wrong, this implementation is also wrong

dim AA =  sin(3pi/4)^2

SO, be very careful in the mathematical logic when you are dealing with exponent not integer.

The rule of thumb, ... write the equation on a paper, make any possible simplification of the exponent and then write the equation in VB.

In my quiz, by making the simplification we would have see that

2/n = 2/4 =0.5

and the square root of a negative is a complex number

Thursday, May 9, 2013 2:58 PM
• So which is right? :)

Regards David R
---------------------------------------------------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
Every program eventually becomes rococo, and then rubble. - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

Thursday, May 9, 2013 3:07 PM
• I'd say none. The formula has sin() the code has cos().

Ya, I  f__k up, but the logic stay there
Thursday, May 9, 2013 3:10 PM
• @ Blackwood

if you are right, it means that

SQRT( 0.840896415253715 )^4  =    sin(3pi/4)  = -0.70710678118654746

Which is false ...  SQRT( 0.840896415253715)^4 will obviously return a positive number

I don't think you followed your expression there.  But in any case, the square root (or fourth root) of any positive number can be positive or negative. So 16 ^ (1/2) is +/- 4 and 16 ^ (1/4) is +/- 2. (-2 * -2 * -2 * -2 = 16).
Thursday, May 9, 2013 3:11 PM
• Ya, but -2^4 and 2^4 return a positive number in any case

so  n^4 cannot be equals to -0.70710678118654746
Thursday, May 9, 2013 3:15 PM
• Ya, but -2^4 and 2^4 return a positive number in any case

So, I was right!   =8^D    But, not totally correct.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Thursday, May 9, 2013 3:21 PM
• ```Public Class Form1

Dim Teta As Double = 3 * Math.PI / 4
Dim n As Double = 4
Dim X As Double

X = Math.Sin(Teta) ^ (2 / n) ' Returns: NaN

Label1.Text = X.ToString

X = (Math.Sin(Teta) ^ 2) ^ (1 / n) ' Returns: 0.840896415253715

Label2.Text = X.ToString

X = -0.70710678118654746 ^ (2 / n) ' Returns: -0.840896415253715

Label3.Text = X.ToString

Label4.Text = Math.Sin(3 * Math.PI / 4).ToString

End Sub

End Class```

You've taught me everything I know but not everything you know.

My code is with  Cos, not Sin

I just made a mistake while writing the equation in Word

Thursday, May 9, 2013 3:22 PM
• Ya, but -2^4 and 2^4 return a positive number in any case

Exactly. Your expression says to do three things in the following order.

1. Calculate sin(3 * pi / 4). The result is negative.
2. Calculate the square. The result is positive.
3. Calculate the fourth root. There are two answers, one positive one negative.

I think you are saying that we can simplify by combining steps 2 and 3 with a single step to take the square root.  I argue that, since that results in a different answer (nan), it can't be a valid simplification of the process.

Thursday, May 9, 2013 3:26 PM
• So which is right? :)

Regards David R
---------------------------------------------------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
Every program eventually becomes rococo, and then rubble. - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

The first is right, ... Double.NaN suggest that the answer is a complex number

Thursday, May 9, 2013 3:32 PM
• Ya, but -2^4 and 2^4 return a positive number in any case

Exactly. Your expression says to do three things in the following order.

1. Calculate sin(3 * pi / 4). The result is negative.
2. Calculate the square. The result is positive.
3. Calculate the fourth root. There are two answers, one positive one negative.

I think you are saying that we can simplify by combining steps 2 and 3 with a single step to take the square root.  I argue that, since that results in a different answer (nan), it can't be a valid simplification of the process.

X^(4/2) have 2 rooths, one negative and one positive BUT there are no real number N such that N^4 = -1 ... or negative anything ...

The solution have to be a complex number

I got this from Wikipedia for you

http://en.wikipedia.org/wiki/Exponent

Thursday, May 9, 2013 3:58 PM
• Hi Crazypennie,

If you follow BODMAS or BEDMAS rules.

( 3* Pi ) / 4 = 2.3561944901923449288469825374596

Sin ( 2.3561944901923449288469825374596 degrees ) = 0.041111761828599317357934264608497

--------------------------------------------------------

( 0.041111761828599317357934264608497 ) ^ 2 = 0.0016901769606514758865419186066252

The 4th root of 0.0016901769606514758865419186066252

= 0.20276035566303220843720301037987

But as a minus times a minus is a plus we also have an answer =

-0.20276035566303220843720301037987

'

The above results are from Windows Calculator. :-D

Please also remember that VB.Net works in RADIANS so if you want degrees

then multiply any INVERSE ( Sin, Cos, Tan ) result by ( 180 / Pi ).

If you want to convert degrees to radians then divide the angle by ( 180 / Pi ) =

57.295779513082320876798154814105

before you use:

• Math.Sin
• Math.Cos
• Math.Tan

Regards,

Thursday, May 9, 2013 4:14 PM
• X^(4/2) have 2 rooths, one negative and one positive BUT there are no real number N such that N^4 = -1 ... or negative anything ...

The solution have to be a complex number

I agree that no real number can give you a negative number when raised to the fourth power, but that is not what is happening in your expression.  The number we are taking the fourth root of is (sin(3 * pi / 4))^2 which is (-0.70710678118654746)^2 which is approximately 0.28 (a positive number).
Thursday, May 9, 2013 4:20 PM
• Hi again Crazypennie,

If you are using Cos then

( 3* Pi ) / 4 = 2.3561944901923449288469825374596

Cos( 2.3561944901923449288469825374596 ) = 0.99915455413031497832540334286332

_________________________________________________________________________

0.99915455413031497832540334286332 ^ 2 = 0.99830982303934852411345808139337

4th root of ( 0.99830982303934852411345808139337 ) =

0.99957718768002852933405559112419

or

-0.99957718768002852933405559112419

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 4:34 PM
• OK, more detail

IF

((-25)^2)^(1/4) = + or - 5

Exponent identity 1)

if X^m = Y     then    Y^(1/m)= X  (ie if x^2 = Y  == > sqrt( Y) = X

Exponent identity 2)

(X^n)^m = (X ^m)^n

--------------------

so

(5^4)^1/2 =  +or- minus 25 [ This is your argument 2 roots, on pos and one neg ]

but

(5 ^ 1/2) ^ 4 = 25 (Not -25)

so, according the the exponent identity, the negative root has to be rejected from the possible solution (since it dont satisfy the second identity)

and the positive root dont satisfy the first identity, ( 25 <> -25) so it has to be rejected also

Therefore neither 5 or -5 is a solution of the equation.

the solution that satisfy the equation is the complex number 5i

(5i^1/2)^4 = -25

(5i^4)^1/2 = -25

which satisfy both identities

-------------------------------------------------------

This is the all point of this, 5 or -5 can appears to be right -- and can be returned by a function,

But they are mathematically incorrect solutions

Thursday, May 9, 2013 4:45 PM
• Ya, but -2^4 and 2^4 return a positive number in any case

Exactly. Your expression says to do three things in the following order.

1. Calculate sin(3 * pi / 4). The result is negative.
2. Calculate the square. The result is positive.
3. Calculate the fourth root. There are two answers, one positive one negative.

I think you are saying that we can simplify by combining steps 2 and 3 with a single step to take the square root.  I argue that, since that results in a different answer (nan), it can't be a valid simplification of the process.

Hi Blackwood,

The Sin of ( 3 * Pi / 4 ) is not negative.

Sin ( 2.3561944901923449288469825374596 degrees ) = 0.041111761828599317357934264608497

_______________________________________________

Sin ( 2.3561944901923449288469825374596 radians ) =

0.70710678118654752440084436210485

_______________________________________________

The Cosine of the same number in Radians is negative.

However the same number does not equate to the same angle in degrees.

We need to convert the angle to Radians first for VB.Net functions:

• Math.Sin
• Math.Cos
• Math.Tan

The Cos( 2.3561944901923449288469825374596 radians ) =

-0.70710678118654752440084436210485

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 4:51 PM

• This is the all point of this, 5 or -5 can appears to be right -- and can be returned by a function,

But they are mathematically incorrect solutions

Hi again Crazypennie,

If it helps any you can use Complex Numbers with FrameWork 4.0

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 5:01 PM
• Hi again Crazypennie,

3 * Pi / 4 = 2.3561944901923449288469825374596

Math.Cos( 0.041123351671205660911810379166151 ) 'as in VB.Net

= 0.99915455413031497832540334286332

Then

0.99915455413031497832540334286332 ^ 2 =

0.99830982303934852411345808139337

4th root =

0.99957718768002852933405559112419

or

-0.99957718768002852933405559112419

Which is the same result I had earlier when working in degrees.  :-)

Regards,

Thursday, May 9, 2013 5:04 PM
• Hi Crazypennie

The whole story is that mathematical expressions give different results depending in which priority the operations are performed. This is why the three coded expressions give different results.

According to the priority conventions used by mathematicians the second code give the correct result of the given mathematical expression (assumed cos).

The critical point here is that performing the square then the fourth root is different than evaluating the square fourth rooted (2/n); this is mainly because the result will require absolute value.

It may be like (not exact, but just to simplify the idea): -3^2; do we mean (-3)^2 or -(3^2), the first gives 9 while the other gives -9. Now any other operation performed on 9 gives different result if performed on -9, such as square root which gives complex number when applied to -9 but a real number if applied to 9.

Hope this helps.

• Edited by Thursday, May 9, 2013 5:13 PM
• Proposed as answer by Thursday, May 9, 2013 5:18 PM
Thursday, May 9, 2013 5:07 PM
• The original expression calls for the expression to be squared, which always results in a positive number.  Hence, the final result (the fourth root) cannot be negative, nor should it be undefined.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Thursday, May 9, 2013 5:20 PM
• Hi ALL,

I get the same answer whether I work in degrees or radians.

0.99957718768002852933405559112419

or

-0.99957718768002852933405559112419

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 5:21 PM
• Hi

I would actually say the correct answer to the problem is all three lines of code. Whenever one takes a root of a number, he gets as many results as the order of the root. For example, the fourth root of 16 is (are):

1. 2

2. -2

3. 2i

4. -2i

Everyone probably agrees that 2 and -2 to the fourth power equals 16. However, i^4 = 1. So when you raise 2i to the fourth power you get: 2^4 * i^4 = 16 * 1 = 16. Also with -2i: -2^4 * i^4 = 16 * 1 = 16

So when you take the fourth root of cos(3*pi/4)^2, you get four results: 0.84..., -0.84..., 0.84i, -0.84i. Hope that's clear.

• Edited by Thursday, May 9, 2013 5:43 PM
Thursday, May 9, 2013 5:35 PM
• The original expression calls for the expression to be squared, which always results in a positive number.  Hence, the final result (the fourth root) cannot be negative, nor should it be undefined.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Hi Rudedog2,

So

-2 * -2 * -2 * -2 = 16 = 2 * 2 * 2 * 2

So of course the 4th root can be negative.

The number itself is written 4 times implying the 4th root.

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 5:43 PM
• Hi Crazypennie

The whole story is that mathematical expressions give different results depending in which priority the operations are performed. This is why the three coded expressions give different results.

According to the priority conventions used by mathematicians the second code give the correct result of the given mathematical expression (assumed cos).

The critical point here is that performing the square then the fourth root is different than evaluating the square fourth rooted (2/n); this is mainly because the result will require absolute value.

It may be like (not exact, but just to simplify the idea): -3^2; do we mean (-3)^2 or -(3^2), the first gives 9 while the other gives -9. Now any other operation performed on 9 gives different result if performed on -9, such as square root which gives complex number when applied to -9 but a real number if applied to 9.

Hope this helps.

1)  do you agree that if    2^4  =16  then  the 4th root of 16 is 2

so  that   X^n = Y    then   Y^(1/n) = X

This is always true

---------------------------------

2) do you agree that  (2^3)^4 = (2^4)^3

so that (X^n)^m  =  (X^m)^n

this is always true

----------------------------------

so if it was correct to say:

(-25)^2)^1/4) = + or - 5

then

we agree that ( ( -5 ) ^ 4)^ 1/2 = + or - 25

but ( ( -5) ^ 1/2)^4 <> -25 and since  (X^n)^m  =  (X^m)^n is always true,

it means that -5 is not a solution of the equation. It is mathematically illogical.

{ I am not arguing that  ( ( -5 ) ^ 4)^ 1/2 =  - 25 is not right, but it is a solution for  something else, not a solution for that equation :  -5 is not a solution for this equation. It is not because this expression gives -25 that -5 is a solution.

saying that it is, is saying that  (X^n)^m  =  (X^m)^n is not true. And if it is not true, someone has to redo the rules of the math}

and now about the solution 5 ... well

( ( 5 ) ^ 4)^ 1/2  <> -25

( (5) ^ 1/2)^4  <> -25

then 5 is not a solution neither

The only value that work is the complex number 5i

-----------------------------

So, if you are not careful when using non integer exponent, you may end up with some wrong value

Thursday, May 9, 2013 5:51 PM
• Hi,

( ( -5 ) ^ 4)^ 1/2 = +25

= ( ( +5 ) ^ 4)^ 1/2

You can only get +25 from both calculations

as a negative number will become positive if you raise it to an even power.

However after following what you have typed above leads me to think it is one of the reasons that COMPLEX NUMBERS were invented and to help mathematicians solve even more complex formulae.

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 6:08 PM
• Here's another take: mathematically,

((-5)^ 4)^1/2 = (-5)^2 = 25
((-5)^ 1/2)^4 = (-5)^2 = 25

What's mathematically incoherent about that? In the case you use we have (X^m)^n versus (X^n)^m where m = 2n, so both reduce to X^2 and that has a clear answer. And is mathematically correct. So I conclude there is a flaw in the argument - I suspect due to the fact that e.g. X^1/2 does not have a unique solution.

When translated into operations on a machine, the order of operations can be important and that can be hidden by symbol shuffling.

Regards David R
---------------------------------------------------------------
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
Every program eventually becomes rococo, and then rubble. - Alan Perlis
The only valid measurement of code quality: WTFs/minute.

Thursday, May 9, 2013 6:21 PM
• Hi,

( ( -5 ) ^ 4)^ 1/2 = +25

= ( ( +5 ) ^ 4)^ 1/2

You can only get +25 from both calculations

as a negative number will become positive if you raise it to an even power.

However after following what you have typed above leads to think it is one of the

reasons that COMPLEX NUMBERS were invented.

Yes ..

And this is the reason I bring this quiz ... we see this error all the time ..

It is not obvious, An I have a hard time at explaining it.

Thursday, May 9, 2013 6:25 PM
•

but ( ( -5) ^ 1/2)^4 <> -25 and since  (X^n)^m  =  (X^m)^n is always true,

Crazypenny, I'd argue that ( ( -5) ^ 1/2)^4 does equal -25. If one works it out, this is what they get

(-5) ^ 1/2 = ±(i * 5 ^ 1/2) [since the square root of any number gives two results]. Then if you raise that to the fourth power you get: ±(i * 5^1/2)^4 which is the same thing as  = ±(i * 5^1/2) * ±(i * 5^1/2) * ±(i * 5^1/2) * ±(i * 5^1/2) which can equal (based on how you use the signs) i * i * 5 * i * -i * 5 and i * i = -1 so  i * i * 5 * i * -i * 5 = -1 * 5 * -(-1) * 5 = -25!

Hope that's clear

Thursday, May 9, 2013 6:26 PM
• Hi ALL,

The reason complex numbers were invented, as far as I know, was to deal with formulas where we might see something like

Sqrt( -25 )

See:>

http://en.wikipedia.org/wiki/Imaginary_number

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Thursday, May 9, 2013 6:41 PM

• 2) do you agree that  (2^3)^4 = (2^4)^3

so that (X^n)^m  =  (X^m)^n

this is always true

No, this is not always true: [(-3)^2]^(1/2) <> [(-3)^(1/2)]^2.

The left side is 3, but the right side is -3.

This is the reason of the confusion mentioned in the original post.

Beside this, BY DEFINITION, x^(1/2) is positive although you can find negative y so that y^2=x.

• Edited by Thursday, May 9, 2013 7:41 PM
Thursday, May 9, 2013 7:21 PM
• Doesn't your problem boil down to the following?

﻿

Whether x is negative or not, it is squared first which results in a positive number and then the 4th root is taken.  So it would seem that the second line of code is correct.

What am I missing?

Thursday, May 9, 2013 7:45 PM
• It's stuff like this that leads to the prediction of stuff like anti-matter, negative frequency energy, and french fries.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Thursday, May 9, 2013 7:47 PM
• I think people are a little confused about the signs in calculations with powers and roots. For one thing:

may not end up with a positive number in the radical. If x = 2i, then x^2 would equal -4. Basically, whatever the degree of the root, that's how many results there will be (a basic rule of math). So the fourth roots of 16 are 2, -2, 2i, -2i; the square roots of 4 are 2 and -2. A way to think of roots is "What number times itself n times equals X". For example, with the square root of 4, what number times itself 2 times gives 4? The answers are 2 and -2. The same thing applies with ((Cos(3*pi/4)^2)^1/4. This boils down to (0.5)^1/4. This basically asks "What number times itself 4 times equals 0.5?" The answers are 0.84, -0.84, 0.84i, and -0.84i. So my answer to the original code snippet above would be that all the code lines return correct values.

Thursday, May 9, 2013 8:00 PM
• Here the all thing, ( I typed it clean for understanding )

Nothing gives -25

Thursday, May 9, 2013 8:02 PM
• Here the all thing, ( I typed it clean for understanding )

Nothing gives -25

Hi crazypennie again,

There is something wrong here: sqrt(-1) = i (only i and not -i). It has very good reasons to be defined mathematically like this although (-i)^2 = -1. From conventional math perspective:

sqrt(-1) = - i is wrong. Are we going to invent our own math!!

Thursday, May 9, 2013 8:10 PM
• Doesn't your problem boil down to the following?

﻿

Whether x is negative or not, it is squared first which results in a positive number and then the 4th root is taken.  So it would seem that the second line of code is correct.

What am I missing?

It really depends your field of interest.  The  square root of 25 can be +5 or -5.  Some fields of science routinely ignore the negative result, as either meaningless or redundant.

The value +2 can be raised to the fourth power, which results in the  value +16.  Likewise, the value -2 can be raised to the fourth power, which also results in the value +16.  In other words, the fourth root of 16 can be either +2 or -2.

But, the math completely changes when you start looking for the fourth root of -16.  That value results in the complex value 2i, or in my field 2j.

Mark the best replies as answers. "Fooling computers since 1971."

http://thesharpercoder.com/

Thursday, May 9, 2013 8:12 PM
• Crazypennie, I think you're dropping your signs too early. The square root of -5 can equal + OR -(i * 5^1/2). So you can have these two combinations (I'm have x = 5^1/2): i * x, and i * -x. These boil down to i * x and i * -x. Then when you raise the square root of -5 to the fourth power, you are doing: -5^1/2 * -5^1/2 * -5^1/2 * -5^1/2. -5^1/2 can equal i * x OR i * -x. So you can have:

i * x * i * x * i * x * i * -x. This is equal to: (i^4) * -(x^4). i^4 equals 1, so this works out to be:

1 * -(5^1/2)^4 = 1 * -25, which equals -25. (You can also put the minus sign in front of the i, since -i * x and i * -x are equal.)

• Edited by Thursday, May 9, 2013 8:18 PM
Thursday, May 9, 2013 8:15 PM
• By convention what you say is true, (Wanted to avoid another + or - argument)

that dont change that there are the same 2 solutions

1)  iX  from  (+ i) * (+X)

2) -iX from  (+i) * (- X)

and both lead to positive 25

Thursday, May 9, 2013 8:20 PM
• I tried maple and Microsoft Math, and both give the second answer:

Microsoft Math:

Maple:

Note that both Microsoft Math and Maple can handle complex numbers, and can give the complex answers if exists, yet this is not the case in our quiz (I really liked this quiz) :)
• Edited by Thursday, May 9, 2013 8:38 PM
Thursday, May 9, 2013 8:20 PM
• the square root of -5 can equal -iX OR iX, we agree on that. So if you raise the square root of -5 to the fourth power, since -5^1/2 can equal -iX OR iX and raising a number to the fourth is that number times itself 4 times, you have (iX OR -iX) * (iX OR -iX) * (iX OR -iX) * (iX OR -iX), which can result in iX * -iX * iX * iX OR -iX * -iX * iX * iX....so both 25 and -25 result.

• Edited by Thursday, May 9, 2013 8:31 PM
Thursday, May 9, 2013 8:26 PM
• I tried maple and Microsoft Math, and both give the second answer:

( ( -5) ^ 1/2)^4     <>     -25.

so if those answers you are showing are right, then

saying the

if  X^2 = Y      then    sqrt(Y) = X   is false  ( and it is not the case )

-------------------------------------------

" the definition of    b ^ (m/n)    when b is negative and n is even must use the imaginary unit i, "

from

http://en.wikipedia.org/wiki/Exponent

(Rational Exponents section)

,

Thursday, May 9, 2013 8:35 PM
• I tried maple and Microsoft Math, and both give the second answer:

( ( -5) ^ 1/2)^4     <>     -25.

so if those answers you are showing are right, then

saying the

if  X^2 = Y      then    sqrt(Y) = X   is false  ( and it is not the case )

-------------------------------------------

" the definition of    b ^ (m/n)    when b is negative and n is even must use the imaginary unit i, "

from

http://en.wikipedia.org/wiki/Exponent

(Rational Exponents section)

,

First, You can check yourself the results of Maple and Microsoft math.

Second, what you say about b ^ (m/n) is true; the wrong point is that (b^m)^(1/n) does not always equal b ^ (m/n). For example if b = -3, m = 2, and n = 2 the first gives 3 but the second gives -3.

Thursday, May 9, 2013 8:44 PM
• Second, what you say about b ^ (m/n) is true; the wrong point is that (b^m)^(1/n) does not always equal b ^ (m/n). For example if b = -3, m = 2, and n = 2 the first gives 3 but the second gives -3.

Got no problem whit what you are saying here "(b^m)^(1/n) does not always equal b ^ (m/n)". It is true

I think that this is where the all question is:

Is

equal to (25^2)^1/4

or is it equal to 25^(2/4)

Friday, May 10, 2013 9:41 AM
• Is

equal to (25^2)^1/4

or is it equal to 25^(2/4)

Hmm, here is where priority of operations plays an essential role: By convention, when we have the Radical operation, then everything below it should be calculated first and then we do the radical. The mentioned expression equals to [(-25)^2]^(1/4) which equals 5. I am aware that (-25)^(2/4) gives complex result, but it could NOT be represent as:

because this expression means (by convention) that the square should be calculated first, and then the fourth root is applied to the result of the square.

Well, it seems that the whole story is what we mean by some expression... like the old problem of 3+4*5; do we mean (3+4)*5 or 3+(4*5)? Mathematicians chose to be the latter.. Oh. I don't know why the font becomes smaller in these two line... :)

• Edited by Friday, May 10, 2013 10:10 AM
Friday, May 10, 2013 10:04 AM
• I sent an email to someone that will give us the right way to do it with explanation of why

Friday, May 10, 2013 10:51 AM

• I think that this is where the all question is:

Is

equal to (25^2)^1/4

or is it equal to 25^(2/4)

Hi Crazypennie,

I would always go with (25 ^ 2 ) ^ (1/4)

BEDMAS : Brackets, Exponentiation, Divide, Multiply, Add, Subtract

BODMAS : Brackets, power Of, Divide, Multiply, Add, Subtract

Always resolve the Brackets or parentheses first.

:-D

If you like, look at like this:>>

( ( 25 ) ^ 2 ) ^ ( 1/4 )

In other words, back to your 1st question.

This one is correct when (3*Pi/4) is expressed in RADIANS for the Cosine function.

`X = (Math.Cos(Teta) ^ 2) ^ (1 / n) ' Returns: 0.840896415253715`

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

• Edited by Friday, May 10, 2013 12:34 PM
• Proposed as answer by Friday, May 10, 2013 8:35 PM
Friday, May 10, 2013 12:13 PM

• Well, it seems that the whole story is what we mean by some expression...

like the old problem of 3+4*5; do we mean (3+4)*5 or 3+(4*5)?

Mathematicians chose to be the latter.. Oh. I don't know why the font becomes smaller in these two line... :)

Hi ALL,

This was the reason why BEDMAS a.k.a. BODMAS for operator precedence was created as mathematicians decided there can only be one answer for a simple sum like:

3 + 4 X 5 = 23

or similar such as

2 + 2 X 2  = 6

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Friday, May 10, 2013 12:19 PM

• Well, it seems that the whole story is what we mean by some expression...

like the old problem of 3+4*5; do we mean (3+4)*5 or 3+(4*5)?

Mathematicians chose to be the latter.. Oh. I don't know why the font becomes smaller in these two line... :)

Hi ALL,

This was the reason why BEDMAS a.k.a. BODMAS for operator precedence was created as mathematicians decided there can only be one answer for a simple sum like:

3 + 4 X 5 = 23

or similar such as

2 + 2 X 2  = 6

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

BEDMAS seems to be pretty nice, it makes it easy to memorize the order that should be followed when doing operations.

But I still don't know why the font becomes smaller in the last two lines ;)

• Edited by Friday, May 10, 2013 8:38 PM
Friday, May 10, 2013 8:33 PM

• BEDMAS seems to be pretty nice, it makes it easy to memorize the order that should be followed when doing operations.

But I still don't know why the font becomes smaller in the last two lines ;)

Hi BGQQ,

Blame the ghost of a deceased mathematician haunting the forums

or the ghost of a deceased software developer also haunting the forums.

I won't mention any names of anyone famous or otherwise as I'm only joking.  LOL!!

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Saturday, May 11, 2013 2:49 AM
• Hi John,

There is something missed by BEDMAS, what if the operators are the same.

For example: A = 2^2^(1/2)

Does it mean A = [2^2]^(1/2) = 2

or A = 2^[2^(1/2)] = ﻿﻿2.6651441426902 ?

Saturday, May 11, 2013 1:48 PM
• Hi John,

There is something missed by BEDMAS, what if the operators are the same.

For example: A = 2^2^(1/2)

Does it mean A = [2^2]^(1/2) = 2

or A = 2^[2^(1/2)] = ﻿﻿2.6651441426902 ?

Hi BGQQ,

It means:

A = 2^2^(1/2) = 2

Even if you do ( 2 ^  (1/2) ) ^ 2 = 2

You always evaluate the contents inside of the innermost Brackets first.

( 2 + 2 ) X 2 = 8

Whether you write:

2 + 2 X 2 = 6

or

2 + ( 2 X 2 ) = 6

you can see the importance of Brackets and operator precedence.  :-)

IMPORTANT NOTE: Windows Calculator uses

BEDMAS : Brackets, Exponentiation, Divide, Multiply, Add, Subtract

BODMAS : Brackets, power Of, Divide, Multiply, Add, Subtract

in Scientific Mode.

If you use STANDARD MODE it evaluates left to right so 2 + 2 X 2 = 8 in STANDARD MODE.

It is important to know the difference.

:-D

Consider:

( 2 + ( (5 X 8) / 10 ) ) = 6

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Sunday, May 12, 2013 1:52 AM
• Hi BGQQ,

It means:

A = 2^2^(1/2) = 2

Even if you do ( 2 ^  (1/2) ) ^ 2 = 2

You always evaluate the contents inside of the innermost Brackets first.

( 2 + 2 ) X 2 = 8

Whether you write:

2 + 2 X 2 = 6

or

2 + ( 2 X 2 ) = 6

you can see the importance of Brackets and operator precedence.  :-)

IMPORTANT NOTE: Windows Calculator uses

BEDMAS : Brackets, Exponentiation, Divide, Multiply, Add, Subtract

BODMAS : Brackets, power Of, Divide, Multiply, Add, Subtract

in Scientific Mode.

If you use STANDARD MODE it evaluates left to right so 2 + 2 X 2 = 8 in STANDARD MODE.

It is important to know the difference.

:-D

Consider:

( 2 + ( (5 X 8) / 10 ) ) = 6

Regards,

What if there is no brackets?

Example: 2^2^3

Is it 4^3 = 64?

Or 2^8 = 256?

The calculator returns 64, Microsoft Visual Basic returns also 64, Microsoft Math returns 256, Maple does accept it without parenthesis, and Mathematica returns 256. These very helpful softwares seem to have no standard about such situation!

• Edited by Sunday, May 12, 2013 10:21 AM
Sunday, May 12, 2013 8:25 AM

• What if there is no brackets?

Example: 2^2^3

Is it 4^3 = 64?

Or 2^8 = 256?

The calculator returns 64, Microsoft Visual Basic returns also 64, Microsoft Math returns 256, Maple does accept it without parenthesis, and Mathematica returns 256. These very helpful softwares seem to have no standard about such situation!

Hi again BGQQ,

Raising something to the 3rd power you would write it down 3 times.

I understand why Microsoft Math and Mathematica would evaluate

the above to 256 as it looks like it is doing 2 ^ ( 2 ^ 3 ) as 2 ^ 8 = 256

However ( 2 ^ 2 ) ^ 3 = 4 ^ 3 = 64 as it is evaluated left to right.

<edit>

However if you could write 2 ^ 2 ^ 3 in scientific notation would you have to work out the 2 ^ 3 part first or the topmost power when you look at it like this?

I would feel inclined to agree with Mathematica as the 1st number 2 at the base is raised to the power of ( 2 ^ 3 ).

>>

</edit>

Microsoft Windows Calculator in Scientific Mode in Windows Vista shows the answer of 64.

I feel inclined to report what you have just mentioned to Microsoft and Wolfram.

I do not have Microsoft Math, Maple or Mathematica myself.

Regards,

Click this link to see the NEW way of how to insert a picture into a forum post.

Installing VB6 on Windows 7

App Hub for Windows Phone & XBOX 360 developers.

Sunday, May 12, 2013 12:05 PM
• Wolfram and my Casio calculator return 256 which means that they interpret it as

2^(2^3)

(the calculators display showed this clearly)

So the answer to the question, "What if there aren't brackets?", is CHAOS!  But wait, there are brackets, so all is well.

edit: John - the question is what you are raising to the power of 3.

http://www.wolframalpha.com/input/?i=2^2^3

"Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein

• Edited by Sunday, May 12, 2013 1:32 PM
Sunday, May 12, 2013 12:13 PM

• edit: John - the question is what you are raising to the power of 3.

Hi dbasnett,

I see what you are saying and in my edit above I've written

I would feel inclined to agree with Mathematica as the 1st number 2 at the base is raised to the power of ( 2 ^ 3 ) when you look at it like this:>>

.

To BGQQ,

With VB.Net did you use Math.Pow or the ^

?

Regards,

Sunday, May 12, 2013 12:52 PM

• To BGQQ,

With VB.Net did you use Math.Pow or the ^

?

Dim D as Double = 2 ^ 2 ^ 3 ' Yields 64

Math.Pow can not evaluate such expression unless you decide which ^ is to be performed first.

Sunday, May 12, 2013 5:22 PM

• To BGQQ,

With VB.Net did you use Math.Pow or the ^

?

Dim D as Double = 2 ^ 2 ^ 3 ' Yields 64

Math.Pow can not evaluate such expression unless you decide which ^ is to be performed first.

Exactly.  Do you mean (2^2)^3 or 2^(2^3).  If you wrote it by hand and used stacked exponents then the anser is the latter.

"Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." JohnWein

Sunday, May 12, 2013 7:21 PM