# Negative bases in exponents in computation layer

**URL:** <https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440>\
**Category:** Questions\
**Created:** [September 5, 2022, 4:49pm UTC](https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440 "2022-09-05T16:49:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kimberly\_Macey](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/kimberly_macey/32/1460_2.png) [@Kimberly\_Macey](https://cl.desmos.com/u/Kimberly_Macey)\
**Post date:** [September 5, 2022, 4:49pm UTC](https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440/1 "2022-09-05T16:49:49Z")

</div>

I am trying to create an infinite practice for exponents and have the students pay particular attention to the difference between -2^2 vs (-2)^2.

I created code to random generate the problems but when the answers are calculated it seems to calculate the ones with a negative base incorrectly.

For example if b=-2 and 3=2 then it will calculate b^2 = -4 instead of 4.

I tried to add absolute values into the coding but it didn’t seem to “read” them.

Any ideas? (I “called” the variables on the notes page so that I could see them as I was trying to troubleshoot)

[https://teacher.desmos.com/activitybuilder/custom/631628329cd45d0609c4a32a](https://teacher.desmos.com/activitybuilder/custom/631628329cd45d0609c4a32a)

---

<div class="post-metadata">

**Author:** ![pirsquared](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@pirsquared](https://cl.desmos.com/u/pirsquared)\
**Post date:** [September 5, 2022, 5:42pm UTC](https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440/2 "2022-09-05T17:42:07Z")

</div>

I think it’s a quirk of `numericValue` or possibly the way the latex is parsed.

You can use  
`... otherwise simpleFunction(`a^f`,`a`,`f`).evaluateAt(a,e)`

which works better. (Originally I tried `simpleFunction(`a^e`...)` but I think it treated the e as Euler’s constant instead of the variable).

---

<div class="post-metadata">

**Author:** ![Lexi\_Kans](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/lexi_kans/32/1548_2.png) [@Lexi\_Kans](https://cl.desmos.com/u/Lexi_Kans)\
**Post date:** [January 12, 2023, 11:46am UTC](https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440/3 "2023-01-12T11:46:06Z")

</div>

1. If the base is negative and the exponent is an even number[,](https://curiousdesire.com/importance-of-respect/) the final product will always be a positive number.
2. If the base is negative and the exponent is an odd number, the final product will always be a negative number.

---

<div class="post-metadata">

**Author:** ![Mike\_Gleeson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/mike_gleeson/32/650_2.png) [@Mike\_Gleeson](https://cl.desmos.com/u/Mike_Gleeson)\
**Post date:** [January 12, 2023, 8:08pm UTC](https://cl.desmos.com/t/negative-bases-in-exponents-in-computation-layer/4440/5 "2023-01-12T20:08:12Z")

</div>

Not sure what your code is doing exactly but certainly it seems to me that Desmos is doing things correctly.

See: [Negative Base • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/63c066a5a991e54335332868)
