Created attachment 117143 [details] Screenshot SUMMARY STEPS TO REPRODUCE Try to make plots for functions like x^(1/3) or root(x, 3) in KAlgebra. Also (-8)^(1/3) gives 1, not -2. OBSERVED RESULT See the screenshot attached. EXPECTED RESULT The function plot looks properly, and (-8)^(1/3) gives -2 as a result. ADDITIONAL INFORMATION This seems to be a bug in Qalculate, which is used by KAlgebra, because qalc gives the following as a result: $ qalc > (-8)^(1/3) (-8)^(1 / 3) = approx. 1 + 1,7320508i
So, basically, there are two issues: 1) If qalculate returns complex number, KAlgebra uses only its real part, which produces wrong answer 2) root(-8;3) = -2 in qalculate, but seems that root(x;y) is implemented via x^(1/y) in KAlgrebra, so the same bug here.
KAlgebra doesn't use qalc, yet we probably use the same API hence the same behaviour. https://en.cppreference.com/w/cpp/numeric/complex/pow Even wolfram shows it: https://www.wolframalpha.com/input/?i=%28-8%29%5E%281%2F3%29&assumption=%22%5E%22+-%3E+%22Principal%22 Under the "decimal approximation" section. Now this doesn't make much sense, will need to investigate further why it happens, brush off some knowledge I haven't used in a while...
> Even wolfram shows it: >https://www.wolframalpha.com/input/?i=%28-8%29%5E%281%2F3%29&assumption=%22%5E%22+-%3E+%22Principal%22 depends on what sort of root you want to take (real or principal) https://www.wolframalpha.com/input/?i=%28-8%29%5E%281%2F3%29&assumption=%22%5E%22+-%3E+%22Real%22 actually the situation is described here https://mathworld.wolfram.com/nthRoot.html
Git commit 02fe404a8ff550d3b39f758b24d7eb697788078f by Aleix Pol. Committed on 16/03/2020 at 18:11. Pushed by apol into branch 'master'. Provide a realpower command Allows getting results such as root(-8, 1/3)=-2, with root(-8,1/3) we get the complex root which is less fun to work with. M +1 -0 analitza/CMakeLists.txt M +2 -0 analitza/analyzer.cpp A +47 -0 analitza/commands/realpower.cpp [License: GPL (v2+)] A +33 -0 analitza/commands/realpower.h [License: GPL (v2+)] M +5 -3 analitza/operations.cpp M +2 -1 analitza/tests/analitzatest.cpp M +2 -0 analitza/tests/builtintest.cpp M +3 -2 analitza/value.h https://commits.kde.org/analitza/02fe404a8ff550d3b39f758b24d7eb697788078f