Author Topic: Exponents  (Read 9929 times)

0 Members and 1 Guest are viewing this topic.

Offline RandallMcRee

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Re: Exponents
« Reply #25 on: April 09, 2019, 03:08:31 pm »
The - is part of the number, not an operator, so it's the same as -3 * -3 * -3 * -3.

Wow - it's brave to claim that, after about ten people have stated the opposite.  ;)
And I'm afraid it is wrong: https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign

Yeah:
https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/artnege.htm
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Exponents
« Reply #26 on: April 09, 2019, 03:13:29 pm »
The - is part of the number, not an operator, so it's the same as -3 * -3 * -3 * -3.

No!
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2213
  • Country: 00
Re: Exponents
« Reply #27 on: April 09, 2019, 03:13:54 pm »
Yes, thanks all. I see no reasonable solution to my problem.

What's your problem?

My applied calculus exam had 10 parts to solve: a bowling ball is dropped onto a table at t0. Show the derivations of the equations to, and  calculate a number of things, such as the speed of ball at impact and time; the position, velocity, and acceleration of point (x,y) on the table at time tn. You are given such things as the modulus of expansion of the table (legs considered infinitely rigid), its thickness, density, and all the other things I've forgotten that you'd need to actually solve the problem. I got all 10 parts correct and aced the course. I ranked the top fifth in my graduating class, and have both physics and applied engineering degrees.

I was trying to apply context of primary school introduction to exponents. The only question I had was the one I could not answer. I looked at it, tried to apply context, and arrived at the wrong answer.

I'm sure the image below will illustrate another failure of applied context.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 19517
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Exponents
« Reply #28 on: April 09, 2019, 03:25:25 pm »
I'm sure the image below will illustrate another failure of applied context.


Oooh, tasty.

That ranks alongside 1+2*3=9.

RPN rulesz :)
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Exponents
« Reply #29 on: April 09, 2019, 03:34:05 pm »
I'm sure the image below will illustrate another failure of applied context.


Oooh, tasty.

That ranks alongside 1+2*3=9.

RPN rulesz :)

Ditto re RPN

Excel is wrong.  However, MS does tell you what rules they are following as shown in the attached from MS.
 

Offline ebastler

  • Super Contributor
  • ***
  • Posts: 6510
  • Country: de
Re: Exponents
« Reply #30 on: April 09, 2019, 03:34:52 pm »
I'm sure the image below will illustrate another failure of applied context.

At the danger of repeating myself:

https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign
Quote
Some applications and programming languages, notably Microsoft Excel (and other spreadsheet applications) and the programming language bc, unary operators have a higher priority than binary operators, that is, the unary minus has higher precedence than exponentiation, so in those languages −32 will be interpreted as (−3)2 = 9.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Exponents
« Reply #31 on: April 09, 2019, 03:44:43 pm »
 

Offline RandallMcRee

  • Frequent Contributor
  • **
  • Posts: 541
  • Country: us
Re: Exponents
« Reply #32 on: April 09, 2019, 03:58:20 pm »
Yes, thanks all. I see no reasonable solution to my problem.

What's your problem?

My applied calculus exam had 10 parts to solve: a bowling ball is dropped onto a table at t0. Show the derivations of the equations to, and  calculate a number of things, such as the speed of ball at impact and time; the position, velocity, and acceleration of point (x,y) on the table at time tn. You are given such things as the modulus of expansion of the table (legs considered infinitely rigid), its thickness, density, and all the other things I've forgotten that you'd need to actually solve the problem. I got all 10 parts correct and aced the course. I ranked the top fifth in my graduating class, and have both physics and applied engineering degrees.

I was trying to apply context of primary school introduction to exponents. The only question I had was the one I could not answer. I looked at it, tried to apply context, and arrived at the wrong answer.

I'm sure the image below will illustrate another failure of applied context.

Are you trolling? I ask because you put in a lot of stuff about your past performance but left out the most important piece of information that would allow someone to help you! I.e. What exactly are you confused about??

My guess is that you were never taught properly about operator precedence. It creates ambiguity in expressions like -3^4.

If you are actually still confused try to explain (in words).
 

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Exponents
« Reply #33 on: April 09, 2019, 04:18:05 pm »
see APL for some interesting examples :)
APL, my first love...though sadly mostly forgotten. :'(
Its rules are is astonishingly easy: right to left evaluation of expression, and that's it.
Even the tirade on WP about long right and short left function context seems a bit of mental wankery: it is simply the application of the same rule.
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Online soldar

  • Super Contributor
  • ***
  • Posts: 3167
  • Country: es
Re: Exponents
« Reply #34 on: April 09, 2019, 04:37:19 pm »
What is the answer to this?

-34

OK, with the additional information you have provided the answer is most definitely "it depends".

The order of operations is a matter of convention and, as such, there is no universal correct answer.

Unless otherwise stated the most common convention is what Wikipedia says and has been said here.

Then Excel states and abides by the exception:
Quote
There are differing conventions concerning the unary operator − (usually read "minus"). In written or printed mathematics, the expression −32 is interpreted to mean 0 − (32) = − 9,[1][3]

Some applications and programming languages, notably Microsoft Excel (and other spreadsheet applications) and the programming language bc, unary operators have a higher priority than binary operators, that is, the unary minus has higher precedence than exponentiation, so in those languages −32 will be interpreted as (−3)2 = 9.[4] This does not apply to the binary minus operator −; for example while the formulas =-2^2 and =0+-2^2 return 4 in Microsoft Excel, the formula =0-2^2 returns −4. In cases where there is the possibility that the notation might be misinterpreted, a binary minus operation can be enforced by explicitly specifying a leading 0 (as in 0-2^2 instead of just -2^2), or parentheses can be used to clarify the intended meaning.


It is not "wrong". It is just another convention. If you do not specify people will assume the most widespread convention is in use. If you ask "what is the correct result in Excel?" that is a different question with a different answer.

Note that it is easy to avoid any ambiguity by just using parentheses.

This is like asking  if people should drive on the right hand side of the road. The answer is yes because people are assuming you are in a country where that is the convention but if you further clarify you are talking of England then the answer changes.

So,
What is the answer to this?

-34
My answer is "where?".
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Exponents
« Reply #35 on: April 09, 2019, 05:21:22 pm »
That ranks alongside 1+2*3=9.

And that's exactly the answer you would have gotten in the original spreadsheet, VisiCalc! The original designers, in hindsight, admit that ignoring precedence was a poor choice on their part.

I don't know how Microsoft got their rules for Excel, but they're stuck with them now. Documenting them is safer than changing them and breaking umpteen existing spreadsheets.

So the problem with the OP's original question is that he presented it without the relevant context.
 

Online soldar

  • Super Contributor
  • ***
  • Posts: 3167
  • Country: es
Re: Exponents
« Reply #36 on: April 09, 2019, 06:05:51 pm »
Context is everything.

OTOH, I use Excel quite a bit and have never really been aware of this "problem".  I don't know if I have unconsciously worked around it or just been lucky or what.  Or maybe I have been getting wrong results and never became aware of their wrongness.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Exponents
« Reply #37 on: April 09, 2019, 06:23:48 pm »
This has been linked a couple of times above:

https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign

There is no universal agreement on the precedence of the unary minus.  In some languages it might mean (-3)4 in others it might mean -(34)

And that's why we have parentheses.
« Last Edit: April 09, 2019, 06:26:38 pm by rstofer »
 

Offline MyEEVBlogAccount

  • Contributor
  • Posts: 11
  • Country: us
Re: Exponents
« Reply #38 on: April 09, 2019, 07:04:38 pm »
This question and circumstance seems awfully close to being an https://en.wikipedia.org/wiki/XY_problem.  It seemed as though the question was asked within the standard mathematical domain, but in actually had to do how different systems may not work the same.  For the Excel formula language, they probably chose higher strength for negation because that is what most people without their mathematician hat on would probably think should happen.

Now, because of my academic background, I tend to write math problems that are complicated or are beyond the DMAS operations in https://en.wikipedia.org/wiki/Well-formed_formula format without implied multiplication.  No ambiguity in reading, transcribing, or in reading off to another person.
 

Offline Nusa

  • Super Contributor
  • ***
  • Posts: 2416
  • Country: us
Re: Exponents
« Reply #39 on: April 09, 2019, 07:11:29 pm »
There's no universal agreement on anything, because you can always find one person who will disagree with everything.

In the context of written math, the agebra meaning is about as close to internationally universal as one can get in this day and age. The verbal languages the reader speaks is largely irrelevant to this understanding, other than some tolerable differences in notation.

In the context of computer applications, it's less universal, obviously, but trends toward the algebraic meaning unless otherwise identified.

In the context of spoken languages, confusion reins for anyone but expert speakers of formula without written props. Math precedence isn't even on the minds of most people when language is created or evolved.
 
The following users thanked this post: ebastler, tooki

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Exponents
« Reply #40 on: April 09, 2019, 08:15:08 pm »
MATLAB:
>> -3^4
ans =  -81

wxMaxima
(%i1)   -3^4
(%o1)   -81

GNU Fortran
Program Exponents
    print *, -3**4
end program Exponents

-81

Symbolab.com
-3^4=-81

Of the math tools I am currently using, exponentiation has a higher precedence than the unary minus.  This is what I expected.  But it's nice to be certain!

 
The following users thanked this post: Wimberleytech

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2213
  • Country: 00
Re: Exponents
« Reply #41 on: April 09, 2019, 08:42:32 pm »
I'm sure the image below will illustrate another failure of applied context.

At the danger of repeating myself:

https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign
Quote
Some applications and programming languages, notably Microsoft Excel (and other spreadsheet applications) and the programming language bc, unary operators have a higher priority than binary operators, that is, the unary minus has higher precedence than exponentiation, so in those languages −32 will be interpreted as (−3)2 = 9.

In the time it took me to make my post, and test Excel to see what it would do (because I have been merely aware of Excel's order of operations for many years, and had to see rather than recall it), you made your post above. I saw the red warning banner. I see it a lot, but am getting too lazy to go back and see what someone has posted. Usually it would not affect my post, so I would still post the same. In this case, I would have edited my post to acknowledge the redundancy I created, but is leaving myself open for you more enjoyable? I can't always be perfect.

This time, I see the red banner as I'm posting. I want to finish this post anyway, because I have another one open to add below. I probably will not have time to address those posts I've missed, sorry in advance...

Are you trolling? I ask because you put in a lot of stuff about your past performance but left out the most important piece of information that would allow someone to help you! I.e. What exactly are you confused about??

My guess is that you were never taught properly about operator precedence. It creates ambiguity in expressions like -3^4.

If you are actually still confused try to explain (in words).

I am not at all confused and not trolling. I wasn't confused last night when I started this topic. I was more frustrated that I got the wrong answer, as I should have known. I really do not recall how my first exposure to exponents was presented in school. I provided an example that makes it obvious in my follow-up post, and one that I'm sure is not ambiguous in an algebraic expression.

Anyway, I was confident that I'd learn more than I ever knew about operators by posting here, and I was curious how wrong I really was. I mean, if I walked up to an average engineer and just asked them what is minus two squared, or even wrote it down, how many would get it wrong too? I was never a practicing physicist or engineer. My life took a turn in another direction.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
Re: Exponents
« Reply #42 on: April 09, 2019, 09:11:19 pm »
Anyway, I was confident that I'd learn more than I ever knew about operators by posting here, and I was curious how wrong I really was. I mean, if I walked up to an average engineer and just asked them what is minus two squared, or even wrote it down, how many would get it wrong too? I was never a practicing physicist or engineer. My life took a turn in another direction.

You would probably get more wrong answers than you expect.  It's not that engineers don't know operator precedence, it just doesn't come up a lot unless you do some kind of math that involves precedence.  I'm sure if they sat down and thought for a few seconds, they would get the right answer but it would probably involve some conscious thinking, not just a quickie answer.  They would have to mentally run through the rules.

I can tell you for a fact, at first glance, I'm not sure what answer I got.  Sure, I know how it should work but I still have to stop and think.  I don't rely on operator precedence, I use parentheses.
 

Offline metrologistTopic starter

  • Super Contributor
  • ***
  • Posts: 2213
  • Country: 00
Re: Exponents
« Reply #43 on: April 09, 2019, 11:53:46 pm »
Operator precedence was the only thought on my mind. I even thought of this expression in parenthetical terms. I knew the point of the question, but did not arrive. That irritates me.

There is an adage, use it or lose it, and you are your own worst enemy.

I had to look these things up and now see terms like ngram (or is that n-gram?) that I do not recall. And what is an obelus, or what we know as a division symbol?

In some ways I feel a victim of the train me stupid system that is designed to achieve a certain objective, and in other ways I feel there are people who are born to be...

I do really appreciate everyone's posts here. Thank you.
 

Online soldar

  • Super Contributor
  • ***
  • Posts: 3167
  • Country: es
Re: Exponents
« Reply #44 on: April 10, 2019, 06:12:32 am »
Excel gives different results for -3^4 (81) and for 0-3^4 (-81) which I find very strange. I don't know how they came up with that but I find it to be confusing and a bad idea.
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6779
  • Country: pl
Re: Exponents
« Reply #45 on: April 10, 2019, 06:19:22 am »
Well, having studied computer science at a somewhat maths-heavy uni I can say with certainty:

No one would ever read -3⁴ as (-3)⁴, it's definitely -(3⁴).
I can understand why a naively written parser could misinterpret -3^4.

Ergo, big  :-- for Microsoft.

OK, somebody just asked how they come up with it. Simple: their software just doesn't realize that - without anything on the left is still subtraction, albeit from implied zero. So it ignores it and treats it as part of the number. Then it sees ^ and calculates the exponent.
 

Online soldar

  • Super Contributor
  • ***
  • Posts: 3167
  • Country: es
Re: Exponents
« Reply #46 on: April 10, 2019, 07:31:21 am »
I started using Excel when it was still called Multiplan. I bet few people remember that name or that spreadsheet. It used the row-column notation R4C5 for absolute address and R[-2]C[-1] for relative addressing which I still use in Excel because, thankfully, you can choose that.

In these decades of using Multiplan and Excel I never noticed this quirk which they should have corrected from the beginning. As has been said, changing it now might create a compatibility problem with older sheets.

In the early 1980s, before using Multiplan, I was using another spreadsheet, Dynacalc, on a UNIX-like operating system called OS9, on a Dragon (Tandy) computer.  It is just amazing what they could do with such limited hardware.
« Last Edit: April 10, 2019, 08:09:53 am by soldar »
All my posts are made with 100% recycled electrons and bare traces of grey matter.
 

Offline Wimberleytech

  • Super Contributor
  • ***
  • Posts: 1133
  • Country: us
Re: Exponents
« Reply #47 on: April 10, 2019, 12:35:35 pm »
Quote

And that's exactly the answer you would have gotten in the original spreadsheet, VisiCalc! The original designers, in hindsight, admit that ignoring precedence was a poor choice on their part.


Son of a gun!  You are correct.  I just tested that expression in Visicalc...who knew??  I guess you did.
 

Online Nominal Animal

  • Super Contributor
  • ***
  • Posts: 6264
  • Country: fi
    • My home page and email address
Re: Exponents
« Reply #48 on: April 10, 2019, 02:52:57 pm »
Further example:

Code: [Select]
echo ' 3 ^ 4 ' | bc
echo ' - 3 ^ 4 ' | bc
echo ' - - 3 ^ 4 ' | bc
all output 81, because the negation operator - has higher precedence in bc than the exponentiation operator ^ .

That is, the above expressions are equivalent to
Code: [Select]
echo ' 3 ^ 4 ' | bc
echo ' (-3)^4 ' | bc
echo ' (-(-3))^4 ' | bc
Similarly for Bash, bash -c 'echo $[-3**4]', bash -c 'echo $[--3**4]', and bash -c 'echo $[---3**4]' all output 81 .  (The same with bash -c 'echo $(( -3**4 ))' and so on, for the same reason.)

This is explained in their documentation by stating that the negation operator - has higher precedence than the exponentiation operator (^ in bc, ** in Bash), which has higher precedence than subtraction (-).

However, Python, Perl, and Ruby all parse/associate the expressions correctly:
Code: [Select]
python -c 'print(-3**4)'
perl -E 'say -3**4'
ruby -e 'puts -3**4'
all output -81.
Their documentation, fortunately, clearly says that exponentiation ** has higher precedence than negation - .  (Note, however, that they do have slightly different operator precedences from each other, so expressions in one are not necessarily parsed the exact same way in the other.  Trap for young players!)

In general, because many programmers aren't that good at math and changing the precedence/associativity rules when your users have gotten used to them would be downright evil, one must assume that software environments do not always parse or compute expressions correctly.  However, they can almost always be forced to Do The Right Thing, by using parentheses.

(It would be better if there was a separate operators for negation and subtraction instead. I wouldn't mind a superscript minus, -, myself.  It would completely remove the ambiquity.  Similarly for exclusive-or/exponentiation (^).  I blame ASCII for not having suitable glyphs to port to the Portable Character Set.

In all the above environments and languages, adding parentheses will fix the issue: -(3**4) or -(3^4) (depending on what is used to signify exponentiation) will yield the expected answer, -81.

TL;DR: Consider it a human interface problem in various applications and programming languages.  Always use parentheses to avoid mistakes.
 

Offline ebastler

  • Super Contributor
  • ***
  • Posts: 6510
  • Country: de
Re: Exponents
« Reply #49 on: April 10, 2019, 03:15:25 pm »
In general, because many programmers aren't that good at math and changing the precedence/associativity rules when your users have gotten used to them would be downright evil, one must assume that software environments do not always parse or compute expressions correctly.

You have a point there, but nevertheless it's pretty disappointing. By the same token, you could argue that one should expect some spelling errors in programming languages' keywords -- programmers aren't that good at spelling, and cannot break backwards compatibility once a language has been rolled out. But I have yet to see a language with a "prnit" or "inputt" command.  ;)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf