Skip to content

change conjugate(X) to try X.conjugate() #7916

@williamstein

Description

@williamstein
On Tue, Jan 12, 2010 at 8:36 PM, jtyard <> wrote:
> Hi,
>
> I don't know if this counts as a bug, so sorry if I'm posting this to
> the wrong list.  Say I define a cyclotomic field in Sage as follows:
>
> sage: Q3 = CyclotomicField(3)
> sage: z3 = Q3.0
>
> Then Sage can compute the complex conjugate independent of an
> embedding into the complexes:
>
> sage: z3.conjugate()
> -zeta3 - 1
>
> But I get a different answer by typing:
>
> sage: conjugate(z3)
> conjugate(e^(2/3*I*pi))
>
> Wouldn't it make sense for these to do the same thing?  Another
> difference comes up as follows:
>
> sage: Q2.<s> = QuadraticField(-2)
> sage: s.conjugate()
> -s
> sage: conjugate(s)
> -I*sqrt(2)
>
> Yet, the problem doesn't exist with this slightly different
> definition:
>
> sage: QQ2.<ss> = QQ[sqrt(-2)]
> sage: ss.conjugate()
> -a
> sage: conjugate(ss)
> -a

Yes, I agree that this is a bug.  
What is happening is that the *symbolic* conjugate function is coercing its input X to the symbolic ring SR before applying itself.  It would be much better to test if X has a .conjugate method, and if so return that; if not, then return SR(X).conjugate().

Here's the beginning of the course code for conjugate(X):

sage: conjugate.__call__??
        # we want to convert the result to the original parent if the input
        # is not exact, so we store the parent here
        org_parent = parent(args[0])

CC: @sagetrac-rossk

Component: calculus

Author: Burcin Erocal

Reviewer: Karl-Dieter Crisman

Merged: sage-4.3.3.alpha1

Issue created by migration from https://trac.sagemath.org/ticket/7916

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions