Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
any number raised to zero power should be positive one

Subject: any number raised to zero power should be positive one

From: Aaron Friedman

Date: 30 Mar, 2009 01:20:06

Message: 1 of 8

I am new to MatLab. I inputted a very basic equation:

(-1)^0 (I also tried (-1).^0 )

I got -1. That's an incorrect answer. Anything raised to zero power is 1 not -1.
I also tried -12^0 and got -1. Should be 1. 12 ^ 0 is 1 which is OK.

Anyone know what's happening?

Thanks

Subject: any number raised to zero power should be positive one

From: Chaos

Date: 30 Mar, 2009 01:40:04

Message: 2 of 8

"Aaron Friedman" <aaron-friedman@att.net> wrote in message <gqp6o6$3vv$1@fred.mathworks.com>...
> I am new to MatLab. I inputted a very basic equation:
>
> (-1)^0 (I also tried (-1).^0 )
>
> I got -1. That's an incorrect answer. Anything raised to zero power is 1 not -1.
> I also tried -12^0 and got -1. Should be 1. 12 ^ 0 is 1 which is OK.
>
> Anyone know what's happening?
>
> Thanks

this is not mathematica, maple or excel. you need to understand C programming
and complex math.

(sqrt(-1)*sqrt(-1))^0

ans = 1

Subject: any number raised to zero power should be positive one

From: Steven Lord

Date: 30 Mar, 2009 01:43:31

Message: 3 of 8


"Aaron Friedman" <aaron-friedman@att.net> wrote in message
news:gqp6o6$3vv$1@fred.mathworks.com...
>I am new to MatLab. I inputted a very basic equation:
>
> (-1)^0 (I also tried (-1).^0 )
>
> I got -1. That's an incorrect answer. Anything raised to zero power is 1
> not -1.

I'm betting that's not what you typed. I'm betting you typed:

-1^0 or -1.^0

The power operator has higher precedence than the unary minus operator (see
HELP PRECEDENCE) and so -1^0 is the same as -(1^0). Since 1^0 is 1, -(1^0)
is -1.

If you try these:

(-1)^0 or (-1).^0

then you should get 1 as you expect.

Note that what you wrote in your subject is not technically true. There's
one number that, when raised to the 0th power, does not result in 1. That
number is NaN -- NaN^0 results in NaN.

> I also tried -12^0 and got -1. Should be 1. 12 ^ 0 is 1 which is OK.
>
> Anyone know what's happening?

See above.

--
Steve Lord
slord@mathworks.com

Subject: any number raised to zero power should be positive one

From: Matt Fig

Date: 30 Mar, 2009 01:47:01

Message: 4 of 8

"Aaron Friedman" <aaron-friedman@att.net> wrote in message <gqp6o6$3vv$1@fred.mathworks.com>...
> I am new to MatLab. I inputted a very basic equation:
>
> (-1)^0 (I also tried (-1).^0 )
>
> I got -1. That's an incorrect answer. Anything raised to zero power is 1 not -1.
> I also tried -12^0 and got -1. Should be 1. 12 ^ 0 is 1 which is OK.
>
> Anyone know what's happening?


Simply by what you wrote, I am going to guess that you didn't always place parenthesis when you actually entered the calculation into Matlab. This has everything to do with operator precedence.

>> (-1)^0
ans =
     1
>> (-12)^0
ans =
     1

Subject: any number raised to zero power should be positive one

From: Roger Stafford

Date: 30 Mar, 2009 02:36:01

Message: 5 of 8

"Steven Lord" <slord@mathworks.com> wrote in message <gqp839$p7a$1@fred.mathworks.com>...
> .......
> Note that what you wrote in your subject is not technically true. There's
> one number that, when raised to the 0th power, does not result in 1. That
> number is NaN -- NaN^0 results in NaN.
> .......

  There is also another number to the zero-th power that is indeterminate in the world of calculus and that is zero to the zero-th power. Its limiting value depends, as is characteristic of all indeterminate forms, on how fast the two quantities x and y in x^y respectively approach zero. It can be made to approach any value between zero and one or oscillate endlessly between the two without a limit.

  Nevertheless my matlab version does return a one in this case. However, my hand calculator correctly indicates "error". I have a vague memory of someone on CSSM complaining about that at some time in the very distance past. (Perhaps it was I - I can't remember.)

Roger Stafford

Subject: any number raised to zero power should be positive one

From: Steven Lord

Date: 30 Mar, 2009 03:03:28

Message: 6 of 8


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message news:gqpb6h$4fg$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
> <gqp839$p7a$1@fred.mathworks.com>...
>> .......
>> Note that what you wrote in your subject is not technically true.
>> There's
>> one number that, when raised to the 0th power, does not result in 1.
>> That
>> number is NaN -- NaN^0 results in NaN.
>> .......
>
> There is also another number to the zero-th power that is indeterminate
> in the world of calculus and that is zero to the zero-th power. Its
> limiting value depends, as is characteristic of all indeterminate forms,
> on how fast the two quantities x and y in x^y respectively approach zero.
> It can be made to approach any value between zero and one or oscillate
> endlessly between the two without a limit.
>
> Nevertheless my matlab version does return a one in this case. However,
> my hand calculator correctly indicates "error". I have a vague memory of
> someone on CSSM complaining about that at some time in the very distance
> past. (Perhaps it was I - I can't remember.)

This is a (very) FAQ on the sci.math newsgroup:

http://www.faqs.org/faqs/sci-math-faq/specialnumbers/0to0/

--
Steve Lord
slord@mathworks.com

Subject: any number raised to zero power should be positive one

From: Chaos

Date: 30 Mar, 2009 19:55:03

Message: 7 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gqpb6h$4fg$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <gqp839$p7a$1@fred.mathworks.com>...
> > .......
> > Note that what you wrote in your subject is not technically true. There's
> > one number that, when raised to the 0th power, does not result in 1. That
> > number is NaN -- NaN^0 results in NaN.
> > .......
>
> There is also another number to the zero-th power that is indeterminate in the world of calculus and that is zero to the zero-th power. Its limiting value depends, as is characteristic of all indeterminate forms, on how fast the two quantities x and y in x^y respectively approach zero. It can be made to approach any value between zero and one or oscillate endlessly between the two without a limit.
>
> Nevertheless my matlab version does return a one in this case. However, my hand calculator correctly indicates "error". I have a vague memory of someone on CSSM complaining about that at some time in the very distance past. (Perhaps it was I - I can't remember.)
>
> Roger Stafford

from my grad school days, he is not working in the proper domain. he is trying to calculate a Real number from purely Imaginary number WITHOUT using a Complex domain. i.e., WRONG branch cut!

simple log Real math easily shows the poster doesn't have an idea

B^N = N log (B)

i'm not aware of log of any negative numbers.

Subject: any number raised to zero power should be positive one

From: Roger Stafford

Date: 30 Mar, 2009 21:40:03

Message: 8 of 8

"Chaos" <rothko.fan@gmail.com> wrote in message <gqr82n$b5a$1@fred.mathworks.com>...
> from my grad school days, he is not working in the proper domain. he is trying to calculate a Real number from purely Imaginary number WITHOUT using a Complex domain. i.e., WRONG branch cut!
>
> simple log Real math easily shows the poster doesn't have an idea
>
> B^N = N log (B)
>
> i'm not aware of log of any negative numbers.

  I am not sure what your point is, Chaos. As long as x and y are not both zero, the expression x^y = exp(y*log(x)) gives a perfectly consistent result, with the 'log' function choosing the principal branch, as is done in matlab. That places the branch cut along the negative real axis and selects the imaginary part of the logarithm between -pi*i and +pi*i.

  In the case of x = -1 and y = 0, you get exp(0*log(-1)) = exp(0*pi*i) = exp(0) = 1, regardless of which branch is selected for the logarithm, so Aaron is entirely correct in assuming he ought to get an answer of 1 for (-1)^0.

  Presumably his only mistake was that he evidently wrote -1^0, expecting it to mean (-1)^0 rather than -(1^0) in violation of matlab's laws of precedence of the minus and power operators.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us