Serious bug in order of evaluation?

C

Cagdas Ozgenc

Greetings,

I am using Excel 2007 and I don't know if this is a feature or a bug.
I wrote the following expression:

=-(A1^2+A2^2+A3^2 -1)^2

The result is always positive. It seems like Excel is also squaring
the negative sign. In mathematical expressions

-X^2 means -(X^2) not (-X)^2. Otherwise all polynomial expressions are
messed up.

Thanks in advance.
 
R

Ron Rosenfeld

Greetings,

I am using Excel 2007 and I don't know if this is a feature or a bug.
I wrote the following expression:

=-(A1^2+A2^2+A3^2 -1)^2

The result is always positive. It seems like Excel is also squaring
the negative sign. In mathematical expressions

-X^2 means -(X^2) not (-X)^2. Otherwise all polynomial expressions are
messed up.

Thanks in advance.

Excel has a reasonably well defined order of precedence, which you can see by searching for "operator precedence" in Excel HELP.

Negation comes first, so your results are expected. If you want something other than Excel's stated order, you can use parentheses to force your desired order. If I understand you correctly,

=-((A1^2+A2^2+A3^2 -1)^2) should do what you want.

God, give us grace to accept with serenity the things that cannot be changed,
Courage to change the things which should be changed,
and the Wisdom to distinguish the one from the other.
Reinhold Niebuhr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top