| Summary: | KAlgebra produces wrong output on functions like root(x, 3) or x^(1/3) | ||
|---|---|---|---|
| Product: | [Applications] kalgebra | Reporter: | Alexander Kernozhitsky <sh200105> |
| Component: | general | Assignee: | Aleix Pol <aleixpol> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | kde |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Debian testing | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/analitza/02fe404a8ff550d3b39f758b24d7eb697788078f | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
| Attachments: | Screenshot | ||
|
Description
Alexander Kernozhitsky
2018-12-28 10:45:46 UTC
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 |