Ask Your Question

rlg23's profile - activity

2019-07-01 04:51:55 -0500 received badge  Popular Question (source)
2016-10-19 11:30:01 -0500 commented answer Converting a symbolic expression to an element of a number field

QQbar works okay for some basic calculations but when doing something like finding eigenvectors of matrices, sage seems to like to move to floating point numbers even when all entries are rational. In addition, the Groebner basis computations over QQbar fall back to toy Buchberger, which is very, very slow.

2016-10-18 23:10:39 -0500 received badge  Editor (source)
2016-10-18 22:35:58 -0500 asked a question Converting a symbolic expression to an element of a number field

At some point in a calculation in the symbolic ring I end up with some numbers which are complex rationals of the form (a/b + I*(c/d). At this point I would like to no longer treat them as symbolic expressions and rather work with them in a more well behaved field. Since all of the computation I will be doing will keep things as complex rationals it seems like the number field QQ[I] is my best option.

My question is: How can I convert a symbolic expression like SR(2/3+4/5*I) to an element of QQ[I]. In general, there is no coercion from the symbolic ring to a number field, but in this special case there is a pretty clear map I would like to use.

Edit: I suppose since the map from the symbolic ring to the number field depends on an assumed embedding of the number field in the complex numbers, this might not be doable in any clean way. For now the following helper function works

def SRtoQQI(v, imGen):      # imGen = the immaginary unit in a ring QQ[I]
    rp = QQ(v.real_part())  # get real part of input
    ip = QQ(v.imag_part())  # get immaginary part of input
    return rp + ip*imGen    # combine parts to get output

I am still interested to know if there is a build in way, maybe making use of the embedding maps from QQ[I] to SR.

2016-09-05 09:27:31 -0500 received badge  Supporter (source)
2016-09-05 09:27:20 -0500 received badge  Scholar (source)
2016-04-02 13:33:27 -0500 received badge  Nice Question (source)
2016-04-01 17:51:42 -0500 received badge  Student (source)
2016-04-01 17:51:29 -0500 asked a question Getting symbolic variable without resetting python variable.

When calling

 var('x')

the variable x gets set to the symbolic expression x just as if we had called

x = var('x')

In particular, any value stored in x is deleted. Is there a way to get a symbolic variable without setting the python variable to be that symbolic variable? I'm not super familiar with how sage handles symbolic variables so this might be unreasonable.