Maths question - exponents

Hi
I’m trying to understand a little bit about exponents and getting confused with the topic of negative base numbers and their exponents.
For example, I read that :

-5 (with no brackets) raised to the power of 2 = -25.

Contrast this with:
(-5) raised to the power of 2 = 25 :that is a positive number.
(-5) raised to the power of 2 = 25 :that is a positive number.

I don’t understand why the first with no brackets is negative but the second is positive. Can someone please help and explain to me exactly why this is the case? Many thanks
 
Hard to tell without an explicit reference to a programming language or platform, but I'm guessing this is an operator precedence problem. Any negative number times another negative number equals a positive number. This is why the square root of -1 is imaginary. Expanding what I think you mean:
-5 squared = -5 * -5 = +25
the negative of 5 squared = (5 * 5) * -1 = -25
 
The short answer is: because this is the correct result of applying the mathematical rules involved in the calculation. Loosely speaking:
  1. braces override operator precedence
  2. minus times minus = plus (- * - = +)
The long answer is:
  1. -5^2 = -(5^2) = -(5*5) = -(25) = -25
    because the exponent operator has higher precedence than the minus operator (see also: topic #4 3)
    I.e. the to-the-power-of operator ('^') applies first
  2. IFF -5^2 = 25 (THIS IS WRONG)
    then the programming language or calculator you use is errorneous (obscure) because it does not get the operator precedence right
  3. -5 = (-1)*5
    This is how integer (union of natural and negative) numbers are constructed (the negative numbers are derived from the natural (positive) numbers by preceding them with a minus sign, which is in turn means multiply with (-1))
  4. Thus (-5)^2 = ((-1)*5)*((-1)*5) = (-1)*5*(-1)*5
    Mathematic Law of Associativity i.e. you can set the braces as you want for some operations/operators, e.g. plus and multiply
  5. (-1)*5*(-1)*5 = (-1)*(-1)*5*5=((-1)*(-1))*(5*5)
    Mathematic Law of Commutativity, i.e. you can change the order of operands (usually numbers) for some operations/operators but the result stays the same (e.g. addition & multiplication).
  6. (-1)*(-1) = -(-1) and -(-1) = 1
    This is a property of the Multiplication operation (look for Negation) on the realm of integer numbers
  7. Thus (-5)^2 = ((-1)*5)*((-1)*5) = ((-1)*(-1))*(5*5) = 1*(5*5) = 1*25 = 25
    Voilà: q.e.d. (quod erat demonstrandum)
 
Just always use brackets. Like in programming, calling power2(-5) is smth diffrent than -1*power2(5). (Let: int power2(int a){return a*a})

Don't skip any operators, both in math or in programming language, unless you are fluent in them.

To be honest these are basics from mid school (at least in my country). No offence ofc, now as adult you should be able to learn faster.
imo You should redo basics of principles of math analysis, becouse you will find lot more things you don't uderstand and you can get lost. Basic algebra should be known also, to understand mjollnir answer.
It is hard to understand math only at random topics.

Cheers.
 
To be honest these are basics from mid school (at least in my country). No offence ofc, now as adult you should be able to learn faster.
Plenty of people still get this wrong. If I go by these "98% will get this wrong" type posts I see on Facebook. You know the ones, with something like "1+0*2+3=?" (the answer is 4, not 6. Multiplication is done before addition).

Back in school I was taught a mnemonic to remember the order; "Meneer Van Dalen Wacht Op Antwoord". It's in Dutch so it's not going to make sense in English. But it made it easier to remember the correct order.

 
  • Like
Reactions: a6h
Back in school I was taught a mnemonic to remember the order; "Meneer Van Dalen Wacht Op Antwoord"

Hey that's cool. what does it translate to in English? When I was a kid we memorized PEMDAS which was generally made into the mnemonic "Please Excuse My Dear Aunt Sally"
 
Roughly translated it means "Mister Van Dalen waits for an answer". But that really ruins the mnemonic and its meaning. It certainly did its job for me, after 30+ years I still remember it well.

When I was a kid we memorized PEMDAS which was generally made into the mnemonic "Please Excuse My Dear Aunt Sally"
Yeah, I was looking for those. I'm sure other languages have similar mnemonics. In Dutch we would call this an "Ezelsbrug" (Donkey Bridge; it really makes no sense in any other language :rolleyes: )
 
Plenty of people still get this wrong. If I go by these "98% will get this wrong" type posts I see on Facebook. You know the ones, with something like "1+0*2+3=?" (the answer is 4, not 6. Multiplication is done before addition).
Yeah, lots of people make this mistake. I meant it should be easy to learn for adult, expeccially with no exam stress and such.

When I was kid I invented for myself that "The more powerfull operator is (and its opposition) the higher priority it has". It works for Cartesian operators and is nice generalization imo. I think it is intuitive and it also works for function analysis (first you integrate f(x), then multiply).

I don't like mnemonics (like right hand rule) becouse there is propability for me to forget f.e. which hand mnemonic was about xd.

But everyone has their own way of thinking and think that works.
 
Just always use brackets. Like in programming, calling power2(-5) is smth diffrent than -1*power2(5). (Let: int power2(int a){return a*a})

Don't skip any operators, both in math or in programming language, unless you are fluent in them.

To be honest these are basics from mid school (at least in my country). No offence ofc, now as adult you should be able to learn faster.
imo You should redo basics of principles of math analysis, becouse you will find lot more things you don't uderstand and you can get lost. Basic algebra should be known also, to understand mjollnir answer.
It is hard to understand math only at random topics.

Cheers.
This question was asked not in relation to any programming problem. I am self studying basic pre algebra maths (to begin with) because I never had any formal education in mathematics at school.
No offence is taken.
 
In some ways languages without operator overloading make this a bit easier to read.

vec3 val = vec3_div(vec3_mul(a, b), c);

Obviously in this case the multiply happens first. But I suppose this is really just the same as using brackets for everything.
 
Obviously in this case the multiply happens first. But I suppose this is really just the same as using brackets for everything.

In programming is used smth called Łukasiewicz notation.

Example:

Infix notation with parenthesis: (3 + 2) * (5 – 1)

Łukasiewicz notation: * + 3 2 – 5 1

You could write the latter as *((+ 3 2)(- 5 1)), and in such way you have written your code.
 
I used to use dc a fair amount, mostly because I would keep forgetting to add -l to bc making it useless for decimals haha.
I was also tripped up too many times with expr and quoting the operators (looked and felt horrible). Now I use an alias for bc so I don't look weird infront of my colleagues ;)
 
I got a HP-42s back when I was in school, it was awesome. While I still have that calculator I mostly use the Free42 app on my phone nowadays. RPN takes some time to get used to it but it's really powerful. I've gotten so used to it I can't even use a 'regular' calculator any more. On FreeBSD you'll want to use dc(1) instead of bc(1) if you like RPN.
 
I've got some Youtube channels you might like if you're interested in math.

3Blue1Brown:

Mathologer:

Numberphile:

Stand-up Maths

Professor Dave Explains:
View: https://www.youtube.com/watch?v=JbhBdOfMEPs&list=PLybg94GvOJ9FoGQeUMFZ4SWZsr30jlUYK
 
Back
Top