Ask Your Question

Oderyn's profile - activity

2019-04-18 12:53:12 -0500 received badge  Popular Question (source)
2019-03-20 12:02:50 -0500 received badge  Famous Question (source)
2018-08-26 04:44:42 -0500 received badge  Famous Question (source)
2018-08-26 04:44:42 -0500 received badge  Notable Question (source)
2017-11-16 08:44:36 -0500 received badge  Notable Question (source)
2017-02-06 11:38:05 -0500 received badge  Famous Question (source)
2017-01-04 13:10:06 -0500 received badge  Popular Question (source)
2016-12-05 01:22:03 -0500 received badge  Notable Question (source)
2016-12-05 01:22:03 -0500 received badge  Popular Question (source)
2016-11-16 04:44:22 -0500 received badge  Notable Question (source)
2016-09-04 16:41:20 -0500 received badge  Popular Question (source)
2016-08-06 11:45:38 -0500 received badge  Famous Question (source)
2016-08-06 11:45:38 -0500 received badge  Notable Question (source)
2016-08-06 11:45:38 -0500 received badge  Popular Question (source)
2016-07-19 00:07:18 -0500 received badge  Notable Question (source)
2016-07-19 00:07:18 -0500 received badge  Popular Question (source)
2015-08-06 17:46:02 -0500 received badge  Popular Question (source)
2015-06-19 08:33:10 -0500 asked a question Summing primes, cannot convert to int

What can I do so that the following code works:

sage: var('k')
sage: sum(nth_prime(k),k,1,10)
ValueError: cannot convert k to int

Thanks in advance!

2015-06-04 02:44:13 -0500 commented answer Protect built-in variables?

Where is the lower case i..? Anyway, I know how to get them back (one can also use restore). It's just that I want to avoid strange bugs which can happen if I set the value of a built-in variable.

2015-06-03 22:26:27 -0500 asked a question Protect built-in variables?

Is there a way to protect built-in variables? This means that I get a warning if I use code like this:

pi = 5
2015-05-26 01:41:33 -0500 asked a question How to find out if ideal is prime, principal, maximal in $\mathbb{Z}[X]$?
sage: PR.<xx> =PolynomialRing(ZZ)
sage: I_PR = PR.ideal(2,xx)
sage: I_PR.is_principal()

Is there another way?

2015-05-21 23:54:38 -0500 asked a question Fractional ideals for $\mathbb{Z}$

Why isn't it possible to construct fractional ideals for the integers $\mathbb{Z}$?

sage: ZZ.fractional_ideal(3/5)
AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'fractional_ideal'

sage: II = ZZ.ideal(5)
sage: II^(-1)
TypeError: bad operand type for unary ~: 'Ideal_pid'

But absurdly this works:

sage: JJ = NumberField(x-7,"a").ring_of_integers().fractional_ideal(3/5)
sage: JJ^(-1)
Fractional ideal (5/3)

What should I do? Use this crude workaround?

2015-05-09 02:09:24 -0500 asked a question Find out if matrix is positive semidefinite

What can I do to find out if a real or complex (symmetric/hermitian) matrix is positive definite (or better: positive semidefinite).

More specifically, the following code doesn't work:

f(t) = exp(I*t)
ts = [random() for k in range(3)]
var('k, l')
mm = matrix(CC,len(ts))
for k in range(1,len(ts)):
    for l in range(1,len(ts)):
        mm[k,l] = f(ts[k] - ts[l])

It gives the error:

TypeError: entries of the matrix must be in an exact ring, not Complex
Field with 53 bits of precision
2015-05-06 08:43:40 -0500 asked a question Factor out roots
sage: var('a, b, c, d')
sage: trm = 3*(a+b*sqrt(2))+(1+2*sqrt(2))*(c + d*sqrt(2))
sage: trm.expand()
3*sqrt(2)*b + 2*sqrt(2)*c + sqrt(2)*d + 3*a + c + 4*d

What could I do if I wanted a result like:

(3*b + 2*c + *d)*sqrt(2) + 3*a + c + 4*d

And similar, if there were other roots like sqrt(5), 7^(1/3) etc.

Thank you!

2015-05-02 09:05:56 -0500 asked a question Finding complex roots

So, what is the best way to find complex roots of polynomials?

I only found that one:

sage: from sage.rings.polynomial.complex_roots import complex_roots
sage: x=polygen(ZZ)
sage: complex_roots(1.3*x^3-x^2-5*x-1)
[(-1.479272103982880?, 1), (-0.2113935621844148?, 1),
(2.459896435398064?, 1)]

Should I use that? Isn't there an inbuilt function? Even PARI/GP has one, namely polroots...

And why is the x casted as an element of $\mathbb{Z}[X]$, why not $\mathbb{C}[X]$? Can somebody explain that to me?

Thank you!

2015-05-02 08:38:17 -0500 asked a question Can't use gp interface

I'm running Sage 6.6 on Windows as a virtual machine in VirtualBox. I can't use the gp interface:

sage: gp("3+3")
Traceback (click to the left of this block for traceback)
OSError: [Errno 2] No such file or directory: '/tmp/tmp5koDDd'

Does anybody have an idea? Thank you!

Ok, seems to work again after restarting...

2015-04-30 18:50:34 -0500 asked a question Check if element is irreducible in algebraic number field

If I have an algebraic number field

sage: S.<x> = NumberField(x^2+13)

is there a way to find out if an element is irreducible? There seems to be only a function to check if it is prime:

sage: (S(7)).is_prime()

But 7 is irreducible in $\mathbb{Q}(\sqrt{-13})$... how could I find that out?

2015-04-28 02:58:27 -0500 received badge  Supporter (source)
2015-04-28 02:52:04 -0500 asked a question Dot-angle syntax

Can somebody give me a hint where this kind of syntax

S.<x> = NumberField(x^2-5)

is defined? I mean the S.<x>. It's (relatively) clear from the examples what it does, but I've never seen an a real explanation in the manual.

Thank you.

2015-04-21 09:54:48 -0500 received badge  Editor (source)
2015-04-21 08:47:42 -0500 asked a question Alternative to piecewise functions?

If I only need indicator functions (the function is 1 in an interval [a, b], 0 outside of it). Is there an alternative to piecewise functions (with all their issues like plotting), which I can use? Thank you!

EDIT: Ok, I had an idea:


That does pretty much what I want.

2015-04-17 12:47:42 -0500 received badge  Scholar (source)
2015-04-16 05:12:32 -0500 received badge  Student (source)
2015-04-15 15:27:12 -0500 asked a question Solution of quadratic forms

If I have a quadratic form like (in the rational numbers)

452*X^2 - 628*Y^2 + 356*Z^2 + 80*X*Y + 724*X*Z + 56*Y*Z == 0

Can SAGE give me a few solutions? Or even solutions in p-adic integers?