Ask Your Question

BrentBaccala's profile - activity

2022-03-17 03:47:06 +0200 received badge  Popular Question (source)
2020-08-12 01:12:31 +0200 commented answer Sage pip not compatible with PyPI

Sage 9.0 switched to Python 3, so if you have a newer version of Sage use sage -f python3 instead of sage -f python2

2019-03-11 11:35:50 +0200 received badge  Nice Answer (source)
2019-03-07 19:30:13 +0200 answered a question How to change sqrt(5) to decimal?

Try RR(sqrt(5)). The default precision is 53 bits, but that can be changed. For 100 bits of precision, use RealField(100)(sqrt(5))

2019-02-04 21:59:43 +0200 asked a question basis of subspace of complex field

Hi -

Given a set of elements of CC, or perhaps QQbar, I want to compute a basis for a subspace over QQ that contains those elements.

For example, given $3$, $1+\sqrt{5}$, $i$, and $i-1$, I'd expect my output to be $\{1, \sqrt{5}, i\}$, since my original four elements can be written as $(3,0,0)$, $(1,1,0)$, $(0,0,1)$, and $(-1,0,1)$ with respect to that basis.

Obviously, the basis won't be unique.

Can anybody suggest what tools in Sage might be useful for this calculation?

2019-01-23 21:28:40 +0200 received badge  Teacher (source)
2019-01-23 19:24:52 +0200 received badge  Editor (source)
2019-01-23 19:24:03 +0200 answered a question Multiplying Roots of a Polynomial

You can also get exact results by using the Algebraic Field QQbar, which avoids the need of manually constructing a splitting field (like rburing shows in his answer).

In Sage 8.4, I'd also suggest setting QQbar's display option to radical instead of decimal (the default). Try both and see the difference; it's the simplest way I know how to explain it!

sage: QQbar.options.display_format = 'radical'
sage: R.<x> = PolynomialRing(QQbar)
sage: f = x^2*((x+1/x)^2-1)
sage: f.factor()
(x - 1/2*I*sqrt(3) - 1/2) * (x + 1/2*I*sqrt(3) - 1/2) * (x - 1/2*I*sqrt(3) + 1/2) * (x + 1/2*I*sqrt(3) + 1/2)
sage: mul([p.constant_coefficient() for p,m in f.factor()])
1
2018-06-15 04:38:16 +0200 commented answer How to access variables from libsingular?

I wasn't able to get it working using only the Singular language. libsingular prohibits subroutines changing the basering, and I couldn't figure how to access the variable without changing the basering. @nbruin seems to be right - something in cython/C is probably required.

2018-05-25 21:44:05 +0200 commented answer How to access variables from libsingular?

I was hoping for something else, but your suggestion (write a wrapper function) might be the most practical solution.

2018-05-23 23:47:38 +0200 asked a question How to access variables from libsingular?

I have some Sage code that works using the expect interface, and I'm trying to port it to libsingular.

The Singular function in question (absFactorize) returns a ring with an associated variable. In the expect interface, we setring the returned ring, then evaluate the variable name, i.e:

    R = norm_f._singular_().absFactorize()

    singular.setring(R)
    L = singular('absolute_factors')

Anybody know how to do this with libsingular?

2018-04-15 07:00:09 +0200 received badge  Scholar (source)
2018-04-15 07:00:07 +0200 received badge  Supporter (source)
2018-04-14 14:37:12 +0200 received badge  Student (source)
2018-04-13 23:30:04 +0200 asked a question Mapping between isomorphic NumberFields

If I set up two NumberFields that differ only in the variable used in their defining polynomials, they don't report equal:

sage: a=QQ['a'].0
sage: aRing = NumberField(a^2 + 1, 'a')
sage: 
sage: b=QQ['b'].0
sage: bRing = NumberField(b^2 + 1, 'a')
sage: 
sage: aRing is bRing
False

This I can live with. But shouldn't I be able to convert elements between them?

sage: aa=aRing.0
sage: bb=bRing.0
sage: bRing(aa)
TypeError: No compatible natural embeddings found for Number Field in a with defining polynomial b^2 + 1 and Number Field in a with defining polynomial a^2 + 1

I can convert like this:

sage: bbb = aa.polynomial()(bb)
sage: bbb.parent() == bRing
True

...but this seems awkward, and requires defining an auxilary function if you want to pass it to map or map_coefficients.

Is this a bug? Should I report it on Sage's Trac, or is there a good reason for this?