microsoft/calculator

Raising a negative number to a fractional power

raven-xr opened this issue · 3 comments

Describe the bug
The calculator can raise a negative number to a fractional power, which is mathematically impossible. . The function g(x) = x^(1/n) is only defined on the ray [0; +∞), because the following property a^(m/n) = ⁿ√(a^m) works for only positive numbers a > 0

P. S. The calculator works fine with even denominators and returns an error. I guess, the reason is that computers cannot execute the square root of a negative number

Steps To Reproduce

  1. Go to engineer mode
  2. Execute (-8)^(1/3) or something else, where the base is negative and the power is fractional rational with an odd denominator. The calculator works fine with even denominators and returns an error. I guess, the reason is that computers cannot execute the square root of a negative number
  3. Get the answer

Expected behavior
The calculator has to return an error

Screenshots

last three images shows how it should be

Image

Image

Image

Image

Image

Image

Image

Device and Application Information

  • OS Build: Windows 10.0.19045.5371.0
  • Architecture: X64
  • Application Version: 11.2411.1.0
  • Region: ru-RU
  • Dev Version Installed: False

Additional context
Some people think that a^(m/n) = ⁿ√(a^m) for any value of a, but it's wrong. Let me explain...

Let's assume that a^(m/n) = ⁿ√(a^m) works for any numbers...

(-8)^(1/3) = (-8)^(1/3)
We know that (2a)/(2b) = a/b, so 1/3 = 2/6
Let's rewrite one of the expressions in a different way
(-8)^(1/3) = (-8)^(2/6)
It seems to be OK, so let's use the following property and rewrite the expression:
a^(n/m) = ⁿ√(a^m)
³√(-8) = ⁶√((-8)^2)
³√(-8) = ⁶√64
-2 = 2
And this is why we can't raise negative numbers to a fractional rational power and why a^(m/n) = ⁿ√(a^m) doesn't work for negative numbers.

Now, let a be zero, then:
0^(-2/3) = ³√(0^(-2)) = ³√(1/0)
So this rule also doesn't work for a = 0

Requested Assignment
I'm just reporting this problem. I don't want to fix it.

Let's assume that a^(m/n) = ⁿ√(a^m) works for any numbers...
This assumption fails for negative bases and zero because:

  • Even roots of negative numbers are not real.
  • Taking roots before applying the exponent can change the sign.
  • Negative exponents for zero lead to division by zero.

Thus, the rule only holds when a is positive.

As for $(-8)^{(2/6)}=2$ I think it's really a bug, since the $2/6$ has to be evaluated first resulting in $-2$ rather than $2$