Skip to content

Conversation

@jksuom
Copy link
Member

@jksuom jksuom commented Mar 4, 2018

Currently, the minimal polynomial of I is hard-coded x**2 + 1
over all domains. This PR returns x - I over domains that
contain I.

Current master:
>>> minimal_polynomial(I, x, domain=QQ.algebraic_field(I))
x**2 + 1

This PR:
>>> minimal_polynomial(I, x, domain=QQ.algebraic_field(I))
x - I

Currently, the minimal polynomial of I is hard-coded `x**2 + 1`
over all domains. This PR returns `x - I` over domains that
contain I.

Current master:
>>> minimal_polynomial(I, x, domain=QQ.algebraic_field(I))
x**2 + 1

This PR:
>>> minimal_polynomial(I, x, domain=QQ.algebraic_field(I))
x - I
# minimal polynomial of I
assert minimal_polynomial(I, x, domain=QQ.algebraic_field(I)) == x - I
K = QQ.algebraic_field(I*(sqrt(2) + 1))
assert minimal_polynomial(I, x, domain=K) == x - I
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these tests result in x - I. Is the other possibility, the minimal polynomial being x**2 + 1 , tested anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think it was necessary but maybe it could be included. Perhaps this would suffice?

>>> minimal_polynomial(I, x, domain=QQ)
x**2 + 1

Or this?

>>> minimal_polynomial(I, x, domain='QQ(y)')
x**2 + 1

@skirpichev
Copy link
Contributor

skirpichev commented Mar 5, 2018

I suspect, there are plenty of such hardcoded surprises...

In [11]: minimal_polynomial(exp(I*pi/3), x, domain=QQ.algebraic_field(sqrt(3)*I))
Out[11]: 
 2        
x  - x + 1

In [12]: factor(_, extension=sqrt(3)*I)
Out[12]: 
⎛          ___  ⎞ ⎛          ___  ⎞
⎜    1   ╲╱ 3 ⋅ⅈ⎟ ⎜    1   ╲╱ 3 ⋅ⅈ⎟
⎜x - ─ - ───────⎟⋅⎜x - ─ + ───────⎟
⎝    2      2   ⎠ ⎝    2      2   ⎠

More systematic workaround may be using compose=False algorithm (currently, it doesn't support anything except Q) for algebraic extensions.

@jksuom
Copy link
Member Author

jksuom commented Mar 5, 2018

That is disappointing. There is a whole range of private methods like _minpoly_exp(ex, x) that ignore the dom argument.

@skirpichev
Copy link
Contributor

As a variant, you could "sanitize" output of minpoly helpers: factorize one over specified dom (if it's badly supported) and select appropriate factor with _choose_factor().

@smichr
Copy link
Member

smichr commented Mar 13, 2018

That is disappointing. There is a whole range of private methods

Is that a blocker for this PR or should we let that be a new issue?

@jksuom
Copy link
Member Author

jksuom commented Mar 13, 2018

No, I think those other cases could be taken care of elsewhere. They are concerned with algebraic values of transcendental functions, and it seems that they are currently not considered in number field computations. I was the only one I have encountered so far.

@skirpichev
Copy link
Contributor

That's a damn simple problem, with a clear solution, explained above. Why just not fix it?

@jksuom
Copy link
Member Author

jksuom commented Mar 13, 2018

Why just not fix it?

Well, why not. (Maybe not all simple problems should be handed over to beginners...)

@smichr
Copy link
Member

smichr commented Mar 13, 2018

I will open a new issue. Feel free to edit it if I have misrepresented the issue. As the change here is minimal I will commit this.

@smichr smichr merged commit cdd5a23 into sympy:master Mar 13, 2018
@jksuom jksuom deleted the minpoly-of-I branch March 13, 2018 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants