Skip to content

Commit

Permalink
Trac #12807: Taking the real part of a sum of exponentials with imagi…
Browse files Browse the repository at this point in the history
…nary exponents gives wrong result

In sage 4.8 the following computation gives 1/2, while the right result
is -3/2:
{{{
sage: a = exp(i*2*pi/3)
sage: b = exp(i*pi/3)
sage: c = 2*a-b
sage: c.real()
1/2
}}}

Doing the computation numerically gives the right result:
{{{
sage: N(c).real()
-1.50000000000000
}}}
and asking maxima directly also works:
{{{
sage: (c.maxima_methods().rectform()).real()
-3/2
}}}

This is sage 4.8 running on Fedora 16, linux 3.1.0-7.fc16.x86_64 SMP.

URL: http://trac.sagemath.org/12807
Reported by: inaki
Ticket author(s): Ralf Stephan
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed May 14, 2015
2 parents 1815d9b + 410bab7 commit 3cf557d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6407,6 +6407,13 @@ cdef class Expression(CommutativeRingElement):
sage: a = SR(2).real_part(hold=True); a.simplify()
2
TESTS:
Check that :trac:`12807` is fixed::
sage: (6*exp(i*pi/3)-6*exp(i*2*pi/3)).real_part()
6
"""
return new_Expression_from_GEx(self._parent,
g_hold_wrapper(g_real_part, self._gobj, hold))
Expand Down

0 comments on commit 3cf557d

Please sign in to comment.