Complex numbers are exponentiated incorrectly

Bug #1566513 reported by Ruslan Batdalov on 2016-04-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNOME Calculator
Fix Released
gnome-calculator (Ubuntu)
FanJun Kong - ( BH1SCW )

Bug Description

The calculator incorrectly performs exponentiation if the base is complex and the exponent is a positive integer. Under these conditions the calculator exponentiates the real part of the base and leaves its imaginary part intact, that does not agree with the complex numbers operation rules. If the exponent is not a positive integer, the calculation is performed correctly.

Steps to reproduce the bug:

1. Start the program.
2. Evaluate expression "i^2". The displayed result is "i".
3. Evaluate expression "(1+i)^2". The displayed result is "1+i".
4. Evaluate expression "(2+i)^2". The displayed result is "4+i".

Please find a quick fix patch attached. I did not study its comprehensiveness and optimality, but it seems to work.

ProblemType: Bug
DistroRelease: Ubuntu 15.10
Package: gnome-calculator 1:3.16.2-1ubuntu1
ProcVersionSignature: Ubuntu 4.2.0-34.39-generic 4.2.8-ckt4
Uname: Linux 4.2.0-34-generic x86_64
NonfreeKernelModules: wl
ApportVersion: 2.19.1-0ubuntu5
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Apr 5 22:59:29 2016
InstallationDate: Installed on 2014-09-29 (554 days ago)
InstallationMedia: Ubuntu 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.2)
SourcePackage: gnome-calculator
UpgradeStatus: Upgraded to wily on 2015-10-29 (159 days ago)

Ruslan Batdalov (linnando) wrote :

The attachment "complex-exponentiation.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Jeremy Bicha (jbicha) wrote :

The test cases work correctly with gnome-calculator 3.23.4. The results I get are:

This was fixed by using the mpc library, which is probably too much to backport that change to Ubuntu 16.04 LTS.

Changed in gnome-calculator (Ubuntu):
status: New → Fix Committed
Jeremy Bicha (jbicha) wrote :

Thanks for submitting the patch. I talked to the gnome-calculator developer and he is probably doing a 3.18.4 release within the next week or so that will include your patch. Let's wait for that before uploading to Ubuntu 16.04 LTS.

Changed in gnome-calculator (Ubuntu Xenial):
status: New → Triaged
importance: Undecided → Low
Changed in gnome-calculator (Ubuntu):
importance: Undecided → Low
Changed in gnome-calculator (Ubuntu Yakkety):
importance: Undecided → Low
status: New → Triaged
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gnome-calculator - 1:3.23.4-0ubuntu1

gnome-calculator (1:3.23.4-0ubuntu1) zesty; urgency=medium

  * New upstream release.
    - Complex numbers are handled more accurately using mpc (LP: #1566513)
    - Titlebar now displays correct app name in Unity (LP: #1615408)
  * debian/
    - Build-depend on libmpc-dev
    - Bump minimum libgtk-3-dev
  * Refreshed git_no_headerbars_in_unity.patch
  * Add git_fix_ans_value_in_popup.patch:
    - Display 'ans' value correctly in variable list

 -- Jeremy Bicha <email address hidden> Mon, 06 Feb 2017 14:41:00 -0500

Changed in gnome-calculator (Ubuntu):
status: Fix Committed → Fix Released
Changed in gnome-calculator:
importance: Unknown → Medium
status: Unknown → Fix Released
Jeremy Bicha (jbicha) wrote :

This will be fixed in this version for Ubuntu 16.10. I'm going to go ahead and close the 16.10 bug task now since it wasn't mentioned in the changelog.

Changed in gnome-calculator (Ubuntu Yakkety):
status: Triaged → Fix Released
Changed in gnome-calculator (Ubuntu Xenial):
status: Triaged → In Progress
assignee: nobody → FanJun Kong - ( BH1SCW ) (fjkong)


I test on 16.04, gnome-calculator 3.18.3 it works fine.
result is as follow:

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.