Ask Your Question

Oderyn's profile - activity

2024-02-20 16:54:10 +0200 received badge  Popular Question (source)
2020-06-01 11:43:39 +0200 received badge  Famous Question (source)
2019-04-18 19:53:12 +0200 received badge  Popular Question (source)
2019-03-20 18:02:50 +0200 received badge  Famous Question (source)
2018-08-26 11:44:42 +0200 received badge  Famous Question (source)
2018-08-26 11:44:42 +0200 received badge  Notable Question (source)
2017-11-16 15:44:36 +0200 received badge  Notable Question (source)
2017-02-06 18:38:05 +0200 received badge  Famous Question (source)
2017-01-04 20:10:06 +0200 received badge  Popular Question (source)
2016-12-05 08:22:03 +0200 received badge  Notable Question (source)
2016-12-05 08:22:03 +0200 received badge  Popular Question (source)
2016-11-16 11:44:22 +0200 received badge  Notable Question (source)
2016-09-04 23:41:20 +0200 received badge  Popular Question (source)
2016-08-06 18:45:38 +0200 received badge  Notable Question (source)
2016-08-06 18:45:38 +0200 received badge  Popular Question (source)
2016-08-06 18:45:38 +0200 received badge  Famous Question (source)
2016-07-19 07:07:18 +0200 received badge  Popular Question (source)
2016-07-19 07:07:18 +0200 received badge  Notable Question (source)
2015-08-07 00:46:02 +0200 received badge  Popular Question (source)
2015-06-19 15:33:10 +0200 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 09:44:13 +0200 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-04 05:26:27 +0200 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
var('I')
2015-05-26 08:41:33 +0200 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()
NotImplementedError

Is there another way?

2015-05-22 06:54:38 +0200 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 09:09:24 +0200 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:

reset()
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])
mm.is_positive_definite()

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 15:43:40 +0200 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 16:05:56 +0200 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 15:38:17 +0200 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-05-01 01:50:34 +0200 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()
False

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

2015-04-28 09:58:27 +0200 received badge  Supporter (source)
2015-04-28 09:52:04 +0200 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 16:54:48 +0200 received badge  Editor (source)
2015-04-21 15:47:42 +0200 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:

indicator(x,a,b)=(sign(x-a)-sign(x-b))/2

That does pretty much what I want.

2015-04-17 19:47:42 +0200 received badge  Scholar (source)
2015-04-16 12:12:32 +0200 received badge  Student (source)
2015-04-15 22:27:12 +0200 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?