Ask Your Question

rburing's profile - activity

2019-10-16 07:03:11 -0500 commented answer Finite field F_16=F_4[y]/(y**2+xy+1) (where F_4=F_2[x]/(x**2+x+1))

To avoid constructing the list you could use next on the iterator.

2019-10-15 16:12:33 -0500 received badge  Nice Answer (source)
2019-10-15 03:17:54 -0500 commented question how do I find kernel of a ring homomorphism?

Please add a code sample including a definition of f.

2019-10-15 02:47:06 -0500 answered a question Verma modules and accessing constants of proportionality

Not sure if it's the best way, but you can do the following:

sage: for n in range(10):
sage:    c = (x2^n*y2^n*v).coefficients()[0]
sage:    print('c_{} = {}'.format(n, c))
c_0 = 1
c_1 = -3
c_2 = 24
c_3 = -360
c_4 = 8640
c_5 = -302400
c_6 = 14515200
c_7 = -914457600
c_8 = 73156608000
c_9 = -7242504192000
2019-10-11 09:04:06 -0500 answered a question Adapt the nauty_directg function

Entering digraphs.nauty_directg?? into a SageMath session will show you the source code of the function.

In this case it simply calls an external program directg which is part of nauty.

You can download and edit that program's source code, compile your new version, and call that one instead.

To edit the source code you should start by looking at the file directg.c. Good luck!

2019-10-05 03:49:37 -0500 commented answer uniform way to iterate over terms of uni-/multi-variate polynomials

It's not very nice to change your question when it has received a correct answer, even if you suffered from the XY problem. Anyway, I updated the answer. In the future, please ask the new question separately (and link to the previous question).

2019-10-04 02:00:03 -0500 answered a question uniform way to iterate over terms of uni-/multi-variate polynomials

Define R2 as a multivariate polynomial ring in 1 variable:

sage: R2.<z> = PolynomialRing(QQ, 1)
sage: Q = z + 5
sage: for c,t in Q: print c,t
1 z
5 1

This ring (and its elements) will have different methods than the ordinary univariate ring (elements).

Alternatively: keep your original ring, define R3 = PolynomialRing(QQ, 1, name='z') and use R3(Q).


An answer to the new question:

def to_multivariate_poly(expr, base_ring):
    vars = expr.variables()
    if len(vars) == 0:
        vars = ['x']
    R = PolynomialRing(base_ring, len(vars), names=vars)
    return R(expr)

Then you can do:

sage: x,y,z = var('x,y,z')
sage: P = to_multivariate_poly(x + 2*y + x*y + 3, QQ)
sage: for c,t in P: print c,t
1 x*y
1 x
2 y
3 1
sage: Q = to_multivariate_poly(z + 5, QQ)
sage: for c,t in Q: print c,t
1 z
5 1
2019-10-04 01:45:45 -0500 commented answer Request: Have the len function output a Sage Integer instead of a Python int

Ah, there is a subtlety with srange (explained in the documentation) that by default the output consists of numbers of the type you put in. You can override that by passing universe=ZZ to srange; I've added this to the answer.

2019-10-03 00:02:21 -0500 commented answer Request: Have the len function output a Sage Integer instead of a Python int

It is not a bug. One should be aware of the difference between int and Integer. The second part of your code uses int division, there is no magic Sage can do to change that. Just be careful to write srange when you want Integers.

2019-10-02 09:20:41 -0500 answered a question Request: Have the len function output a Sage Integer instead of a Python int

In the second part you are using Python ints instead of SageMath Integers.

Use srange (with universe=ZZ if you're not passing an Integer) instead of range, or convert to an Integer before the division, e.g. Integer(i[0])/len(a).

2019-09-22 04:02:01 -0500 answered a question Defining q-binomial coefficients $\binom{n}{k}_q$ symbolic in $n, k$

If you want to make a symbolic sum then all the terms should be symbolic. Your example does not work because qbin(n,k) is not defined for symbolic n.

What you can do is to make qbin a symbolic function with custom typesetting:

var('q')
def qbin_latex(self, n, k):
    return '{' + str(n) + ' \choose ' + str(k) + '}_{' + str(q) + '}'
qbin = function('qbin', nargs=2, print_latex_func=qbin_latex)
var('k,n')
show(sum(qbin(n,k),k,0,n))

$$\sum_{k=0}^{n} {n \choose k}_{q}$$

To check the identities that you are interested in, you will probably have to do some substitutions by hand, and/or pass an evalf_func parameter to function in the definition of qbin. Have a look at the documentation for symbolic functions.

2019-09-22 03:42:51 -0500 answered a question Change of programmation of implicit

It seems that you want the following:

var('x')
y = function('y')(x)
f = function('f')(x,y)
f.diff(x)

Output:

D[1](f)(x, y(x))*diff(y(x), x) + D[0](f)(x, y(x))
2019-09-20 02:35:00 -0500 answered a question Wrong hessian

The matrix you constructed by hand doesn't look like a Hessian to me. Here is the Hessian:

sage: H = L.function(x,y,l).hessian()(x,y,l)
sage: H

$$\left(\begin{array}{rrr} A {\left(\alpha - 1\right)} \alpha x^{\alpha - 2} y^{\beta} & A \alpha \beta x^{\alpha - 1} y^{\beta - 1} & -p_{x} \\ A \alpha \beta x^{\alpha - 1} y^{\beta - 1} & A {\left(\beta - 1\right)} \beta x^{\alpha} y^{\beta - 2} & -p_{y} \\ -p_{x} & -p_{y} & 0 \end{array}\right)$$

2019-09-18 04:02:51 -0500 commented question How sage checks the irreducibility of a polynomial?

Polynomial in one variable? Over which ring?

2019-09-16 11:21:06 -0500 answered a question Check whether point is on a projective variety

Sure, you can take a point from the ambient projective space and do a membership test:

sage: PP.<x,y,z,w,u,v> = ProductProjectiveSpaces([3,1],QQ)
sage: W = PP.subscheme([y^2*z-x^3,z^2-w^2,u^3-v^3])
sage: PP.point([1,1,1,1,1,1]) in W
True
sage: PP.point([1,1,1,1,1,2]) in W
False

Internally this does a try - except block around W.point(...).

2019-09-14 10:05:17 -0500 answered a question Interactive simple Method

The documentation shows many examples with two variables, but in fact there is no restriction on the number of variables or constraints. Example with three variables and three constraints:

A = ([1, 1, 0], [3, 1, 0], [0, 0, 1])
b = (1000, 1500, 20)
c = (10, 5, 1)
P = InteractiveLPProblem(A, b, c, ["C", "B", "A"], variable_type=">=")
show(P)
P = P.standard_form()
P.run_simplex_method()

Three variables and two constraints:

A = ([1, 1, 0], [3, 1, 0])
b = (1000, 1500)
c = (10, 5, 1)
P = InteractiveLPProblem(A, b, c, ["C", "B", "A"], variable_type=">=")
show(P)
P = P.standard_form()
P.run_simplex_method()

Etc.

2019-09-13 11:31:47 -0500 answered a question Finite Fields: Basic Question

You have to define a = k.gen().

The shorthand notation to define both k and a is k.<a> = GF(9).

2019-09-09 01:44:56 -0500 commented answer solving simultaneous equations with solve()

Also solution_dict is used, as you show yourself. The strategy of trying maxima is already included in solve, so it could be improved to work with domain.

2019-09-09 01:34:48 -0500 commented answer solving simultaneous equations with solve()

The documentation is incorrect, the source shows that algorithm is used in case of a list (and only has a special case for sympy). Also, it seems like a bug that no error is raised about the unused extra arguments.

2019-09-08 12:44:28 -0500 answered a question Determinants of Matrices with Symmetric Functions

Yeah that's quite hacky. Try this instead:

N = 2
R = PolynomialRing(QQ, names=['h_{}'.format(k) for k in range(2*N)] + ['e_{}'.format(k) for k in range(2*N)])
H = R.gens()[0:2*N]
E = R.gens()[2*N:]
M = Matrix(R.fraction_field(), N, lambda i, j: H[i+j]/E[i+j])
Sym = SymmetricFunctions(QQ)
e = Sym.elementary()
h = Sym.homogeneous()
m = Sym.monomial()
he_subs = dict(zip(R.gens(), [h[k] for k in range(2*N)] + [e[k] for k in range(2*N)]))
print(m(M.det().numerator().subs(he_subs)))

A symbolic alternative (basically, a cleaner version of what you did):

N = 4
Sym = SymmetricFunctions(QQ)
e = Sym.elementary()
h = Sym.homogeneous()
m = Sym.monomial()
H = function('H', nargs=1, print_func=lambda self, *args: 'h[{}]'.format(args[0]))
E = function('E', nargs=1, print_func=lambda self, *args: 'e[{}]'.format(args[0]))
M = Matrix(SR, N, lambda i, j: H(i+j)/E(i+j))
print(m(sage_eval(str(M.det().numerator()), locals={'h': h, 'e': e})))
2019-09-08 12:12:37 -0500 answered a question How to evaluate polynomial in a polynomial ring at a particular value

Note R is not a polynomial ring but a quotient of one.

Let's name the vector

w = v([2*t, 3, 2, 0])

One thing you can do is lift all the elements to be polynomials in x again and do a substitution:

w.apply_map(lambda z: z.lift().subs({x : sqrt(2)}))

This lands in the vector space over the symbolic ring, because sqrt(2) is symbolic.

You can also replace sqrt(2) by things like sqrt(RR(2)) or sqrt(AA(2)).


More appropriate in this situation is to recognize that you are working in an abstract number field $K = \mathbb{Q}(t) = \mathbb{Q}[x]/(x^2-2)$, and you want to use an embedding:

sage: K.<t> = NumberField(x^2 - 2)
sage: V = VectorSpace(K,4)
sage: w = V([2*t, 3, 2, 0])
sage: w.apply_map(K.embeddings(AA)[1])
(2.828427124746190?, 3, 2, 0)

Here K.embeddings(AA)[1] is the embedding of $K$ into $\mathbb{R}$ that sends $t \mapsto \sqrt{2}$.

The other embedding K.embeddings(AA)[0] is the one that sends $t \mapsto -\sqrt{2}$:

sage: w.apply_map(K.embeddings(AA)[0])
(-2.828427124746190?, 3, 2, 0)

Again here you can replace the algebraic reals AA by other fields like QQbar, RR and CC.

2019-09-08 04:49:04 -0500 answered a question solving simultaneous equations with solve()

Looks like a bug in sympy. Here is an alternative method, for polynomial equations with a finite number of solutions:

sage: R.<x,y> = PolynomialRing(QQ)
sage: I = R.ideal([x*x*x-y*y-10.5, 3.0*x*y+y-4.6])
sage: I.variety(RR)
[{y: 0.601783026716651, x: 2.21465035058553}]

You might also like AA (the field of real algebraic numbers) instead of RR, for exact computations.

2019-09-07 06:48:08 -0500 commented question How to Latex-print matrices as a bold uppercase letter?

How do you LaTeX it without bold? Please add sample code.

2019-09-05 17:47:40 -0500 commented question Checking whether a real polynomial of 21 variables is non-negative
2019-09-05 03:33:54 -0500 commented question How did simplify_full() manipulate this expression?
2019-09-02 22:37:53 -0500 received badge  Nice Answer (source)
2019-09-02 10:26:15 -0500 commented question getting a float result from solve

Post your code please.

2019-09-02 05:15:18 -0500 answered a question Button to copy SageMath cell to clipboard

For a proper solution you should contact the developers of the SageMathCell.

Here is a hack that seems to work with text:

<!DOCTYPE HTML>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>SageMathCell</title>
    <script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>
    <script>
function add_copy_button() {
        var eval_button = $('#mysagecell').find('.sagecell_evalButton');
        console.log(eval_button.text());
        var copy_button = $('<button class="ui-button ui-corner-all ui-widget">Copy input and output</button>');
        copy_button.click(function() {
            console.log('hello');
            var input_lines = $('#mysagecell .sagecell_input pre')
            var output_lines = $('#mysagecell .sagecell_output pre')
            var input = $.map(input_lines, function(element) { return $(element).text() }).join('\n');
            var output = $.map(output_lines, function(element) { return $(element).text() }).join('\n');
            $('#clipboard').val('Input:\n\n' + input + '\n\nOutput:\n\n' + output);
            $('#clipboard').show();
            $('#clipboard').select();
            document.execCommand('copy');
            $('#clipboard').hide();
        });
        eval_button.after(copy_button);
}
$(document).ready(function() {
        $('#clipboard').hide();
        sagecell.makeSagecell({inputLocation: '#mysagecell',
                           evalButtonText: 'Evaluate'});
        var buttonExists = setInterval(function() {
           if ($('#mysagecell .sagecell_evalButton').length) {
              add_copy_button();
              clearInterval(buttonExists);
           }
        }, 100);
    });
    </script>
</head>
<body>

<h2>Your own computations</h2>
Type your own Sage computation below and click “Evaluate”.
<div id="mysagecell"><script type="text/x-sage">print next_prime(7)
print next_prime(11)
print next_prime(13)</script></div>
<textarea id="clipboard"></textarea>
  </body>
</html>
2019-09-01 16:33:33 -0500 commented question Button to copy SageMath cell to clipboard

I just tried to make this, but it's complicated. The output can contain LaTeX, images, etc. I can post a script that works only with text output (and ignores all other output), if you're interested.

2019-09-01 15:09:48 -0500 answered a question Vector valued function: unable to convert to symbolic expression

I just observed the same thing this morning (in the trac ticket #28434). The syntax you should currently use is

F(s,t) = (1,s,s*t)

I consider it a bug that your version doesn't work; it will be fixed as part of the aforementioned ticket.

2019-09-01 07:24:38 -0500 commented question Button to copy SageMath cell to clipboard

Do you mean a HTML page with an embedded SageMathCell?

2019-08-31 11:34:49 -0500 received badge  Nice Answer (source)
2019-08-31 04:53:15 -0500 answered a question Polynomial functions over nonprime finite fields

From your expression for e it is clear that you want to interpret an integer $n < 27$ as an element of the field $K = \mathbb{F}_{27} = \mathbb{F}_3[c]$ by taking the base-3 digits of $n$ as coefficients of the powers of the generator $c$. To do this in Sage you should be more explicit, because coercion of integers into $K$ is the "modulo 3" operation, which is not what you want.

For example:

sage: K(17) # modulo 3
2
sage: 17.digits(base=3)
[2, 2, 1]
sage: K(17.digits(base=3)) # "vector" to field element
c^2 + 2*c + 2

So what works is:

e = [P(K(i.digits(p))) for i in srange(0,p**q)]
2019-08-30 12:19:55 -0500 answered a question Is this a bug or intended behavior?

You have discovered the horror of the syntax for callable symbolic expressions.

  • Numbers confusion:

    sage: f(x) = x^2
    sage: f(2).factor()
    4
    
  • Polynomial confusion:

    sage: R.<z,w> = PolynomialRing(QQ)
    sage: f(x) = x^2
    sage: f(z+w).coefficient({z : 1})
    ...
    TypeError: no canonical coercion from <type 'dict'> to Symbolic Ring
    

    https://ask.sagemath.org/question/470...

  • Matrix confusion:

    sage: B(x) = matrix([[x, 0], [0, 0]])
    sage: B(12)
    [x 0]
    [0 0]
    

    https://ask.sagemath.org/question/104...

  • List confusion:

    sage: f(x) = [x,x]
    sage: f(2).parent()
    Vector space of dimension 2 over Symbolic Ring
    

    https://ask.sagemath.org/question/104...

  • Derivative confusion (and argument confusion):

    sage: f(x) = x.derivative()
    sage: f(x^2)
    1
    sage: f(y) = y.derivative(x)
    sage: f(x^2)
    0
    

    https://ask.sagemath.org/question/984...

  • Matrix argument confusion:

    sage: f(x) = x^2
    sage: f(2*identity_matrix(2))
    ...
    TypeError: no canonical coercion from Full MatrixSpace of 2 by 2 dense matrices over Integer Ring to Callable function ring with argument x
    

    https://ask.sagemath.org/question/385...

  • Adding confusion:

    sage: f(x) = x^2
    sage: g(x) = x^2
    sage: var('t')
    sage: h(t) = t^2
    sage: f+g
    x |--> 2*x^2
    sage: f+h
    (t, x) |--> t^2 + x^2
    

    https://ask.sagemath.org/question/107...

  • Non-symbolic function confusion (your question)

I've seen this too many times now. I went ahead and opened a ticket for it: #28434: Syntax for callable symbolic expressions causes too much confusion.

You should define your function in the way you did, or alternatively with a lambda:

 tau = lambda n: len(divisors(n))
2019-08-29 15:39:25 -0500 commented answer Changing chart multiple times in sagemanifolds

Can we catch the KeyError and raise a more meaningful error message instead?

2019-08-28 13:01:10 -0500 answered a question Finitely presented group simplification

The first example you gave is not cyclic, as seen e.g. by

sage: H.structure_description()
'Q8 : C27'

The meaning of this output can be found in GAP's manual for StructureDescription.

The second example (in your comment to tmonteil) is cyclic:

sage: G.<x0,x5> = FreeGroup()
sage: H = G/[x5*x0*x5*x0^-1*x5^-1*x0^-1, x0^-1*x5^-1*x0^-1*(x0^-1*x5^-3)^3*x0^-1*x5^-1]
sage: H.structure_description()
'C17'

In general, to find out if an element is a generator of a cyclic group you can take powers of it and see if you get the whole group. The difficulty here is that you need to put elements in a kind of normal form to compare them. Here you can do it with a confluent rewriting system:

sage: k = H.rewriting_system()
sage: k.make_confluent()
sage: H_reps = set([k.reduce(h) for h in H])
sage: next((h for h in H if set([k.reduce(h^m) for m in range(len(H))]) == H_reps), None)
x0

This shows x0 is a generator; the relation is x0^17 == 1. (Note there is room for optimization of this code, e.g. in calculating the powers.)

I'm not a group theorist, but I would guess that for finite groups such a rewriting system always exists.

Note for cyclic groups of prime order, all non-identity elements are generators, and more generally in a cyclic group of order $n$, $\varphi(n)$ of the elements are generators.

2019-08-26 11:19:01 -0500 answered a question Square roots in finite fields

The documentation does not specify it, but it is true. (It should be added to the documentation.)

When you call a.sqrt() first a square root x is computed, and then x = x._balanced_abs() is called.

def _balanced_abs(self):
    """
    This function returns `x` or `-x`, whichever has a
    positive representative in `-n/2 < x \leq n/2`.
    This is used so that the same square root is always returned,
    despite the possibly probabilistic nature of the underlying
    algorithm.
    """
    if self.lift() > self.__modulus.sageInteger >> 1:
        return -self
    else:
        return self
2019-08-26 10:40:15 -0500 answered a question How to draw the following graph

Here's a way:

n = 12
G = AdditiveAbelianGroup([n])
from collections import defaultdict
subgroup_gens = defaultdict(list)
for g in G:
    subgroup_gens[G.submodule([g])].append(ZZ(g[0]))
mylabel = lambda H: LatexExpr('$' + '='.join('\\langle ' + str(g) + ' \\rangle' for g in subgroup_gens[H]) + '$')
Graph([(mylabel(H),mylabel(K)) for H in subgroup_gens.keys() for K in subgroup_gens.keys() if H != K and H.is_submodule(K)]).plot(figsize=6)

additive subgroups of Z/12Z

2019-08-26 09:56:57 -0500 commented question How to draw the following graph

Why are $1$ and $3$ different vertices in your graph? They generate the same additive subgroup, i.e. $\langle 1\rangle = \langle 3 \rangle$.

2019-08-22 14:06:31 -0500 answered a question Calling singular.invariant_ring

This looks like a bug to me.

The problem is that SageMath doesn't understand the return type. You can work around it as follows:

sage: from sage.interfaces.singular import SingularElement
sage: SingularElement(singular, 'list', 'invariant_ring(%s)' % g.name(), False).sage()
[[            x0 x0^2*x1 - x1^3], [1]]

The problem has been reported as trac ticket #28386.

2019-08-21 05:14:31 -0500 commented answer Computing a formula in SAGE

@Vochau I do not study it, but you can write me an e-mail (see my profile/website).

2019-08-21 04:04:41 -0500 edited answer Computing a formula in SAGE

This is a polynomial of degree $5$ in the noncommutative variables $\lambda_n$ where the sum of the indices in each monomial is $t_1+t_2+t_3+t_4+t_5$.

It seems Sage doesn't easily generate partitions of $n$ into $k$ nonnegative integers, so we implement this helper function for it (we partition $n+k$ into $k$ positive integers and subtract 1 from each one):

def nonnegative_partitions(n, length):
    from itertools import permutations
    for part in Partitions(n+length, length=length):
        seen = set([])
        for shuffled_part in permutations(part):
            shuffled_part = tuple(x-1 for x in shuffled_part)
            if not shuffled_part in seen:
                yield shuffled_part
                seen.add(shuffled_part)

Here we also take care that $4 = 2+2$ is counted only once. You can implement the formula as:

def S(t):
    F2 = GF(2)
    Lamb = FreeAlgebra(F2, sum(t)+1, names='l_')
    lamb = Lamb.gens()
    result = Lamb.zero()
    for indices in nonnegative_partitions(sum(t), length=5):
        (i,j,h,m,idc) = indices
        for k in nonnegative_partitions(i-t[0], length=4):
            M1 = F2(binomial(t[4]-k[0], k[0]) * binomial(t[3]-k[1], k[1]) * binomial(t[2]-k[2], k[2]) * binomial(t[1]-k[3], k[3]))
            for l in nonnegative_partitions(j-t[1]+k[3], length=3):
                M2 = F2(binomial(t[4]-k[0]-l[0], l[0]) * binomial(t[3]-k[1]-l[1],l[1]) * binomial(t[2]-k[2]-l[2],l[2]))
                for u in nonnegative_partitions(h-t[2]+k[2]+l[2], length=2):
                    M3 = F2(binomial(t[4]-k[0]-l[0]-u[0], u[0]) * binomial(t[3]-k[1]-l[1]-u[1],u[1]))
                    M4 = F2(binomial(sum(t)-sum([i,j,h,m]), m-t[3]+k[1]+l[1]+u[1]))
                    result += M1*M2*M3*M4*lamb[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_3 + l_3*l_2*l_3*l_2*l_5 + l_3*l_2*l_4*l_1*l_5 + l_3*l_2*l_7*l_0*l_3 + l_3^3*l_1*l_5 + l_3^5 + l_3*l_5*l_1*l_3^2 + l_3*l_6*l_0*l_1*l_5 + l_4*l_0*l_3^2*l_5 + l_4*l_0*l_3*l_5*l_3 + l_4*l_0*l_5*l_3^2 + l_4*l_0*l_7*l_1*l_3 + l_4*l_2*l_3*l_1*l_5 + l_4*l_3*l_0*l_3*l_5 + l_4*l_3*l_0*l_5*l_3 + l_4*l_3*l_1*l_2*l_5 + l_4*l_3*l_2*l_3^2 + l_4*l_3*l_5*l_0*l_3 + l_4^2*l_1*l_3^2 + l_4*l_7*l_1*l_0*l_3 + l_5*l_0*l_3*l_2*l_5 + l_5*l_0*l_4*l_1*l_5 + l_5*l_0*l_7*l_0*l_3 + l_5*l_1*l_3^3 + l_5*l_3*l_1*l_3^2 + l_5*l_4*l_3*l_0*l_3 + l_5*l_6*l_1*l_0*l_3 + l_6*l_0*l_3*l_1*l_5 + l_6*l_3*l_0*l_1*l_5 + l_6*l_3^2*l_0*l_3 + l_6*l_5*l_1*l_0*l_3 + l_8*l_0*l_1*l_3^2 + l_8*l_1*l_0*l_1*l_5 + l_8*l_1*l_3*l_0*l_3 + l_9*l_0*l_3*l_0*l_3

When you compute S(t) for several t with different sum(t) then they will belong to different FreeAlgebras (with different number of generators $\lambda_n$), but the names of the generators are "compatible", so adding elements should coerce them into the larger parent FreeAlgebra. Unfortunately this doesn't work (yet), so you have to use a workaround like this:

sage: S_1 = S((1,1,1,3,4)); S_2 = S((1,2,3,4,5)); S_3 = S((1,1,1,6,6))
sage: S_2.parent()
Free Algebra on 16 generators (l_0, l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9, l_10, l_11, l_12, l_13, l_14, l_15) over Finite Field of size 2
sage: S_2.parent() == S_3.parent() # the biggest FreeAlgebra that contains all of them
True
sage: S_2.parent()(str(S_1)) + S_2 + S_3
l_1^3*l_3*l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