Ok I've modified the code to plain sage to make it more useful and I've 
copied it below. Given that it's hard to compare the determinants of the 
raw matrices, as they are defined in terms of different variables, I have 
found the z^2 coefficient in each case and you can see they are different. 
I've tested this in Sage 9.1 command line and this has worked. 

rank = 4
N = 9

p = [var("p{}".format(i), latex_name="p_{}".format(i)) for i in (1..rank)]
w = var('w')
z = var('z')
Q = [var("Q{}".format(i), latex_name="Q_{}".format(i)) for i in (0..rank)]
ni = [1,1,2,2,2]
Qn = [Q[i]^ni[i] for i in (0..rank)]

L1 = Matrix([[-p1, Q1, 0, 0, 0, -4*Q0/z, 0, 0, 0],
            [Q1, p1-p2, Q2, 0, 4*Q0/z, 0, 0, 0, 0],
            [0, Q2, p2-p3, Q3, 0, 0, 0, 0, 0],
            [0, 0, Q3, p3-2*p4, 0, 0, 0, 0, 2*Q4],
            [0, Q0*z, 0, 0, p1, -Q1, 0, 0, 0],
            [-Q0*z, 0, 0, 0, -Q1, -p1+p2, -Q2, 0, 0],
            [0, 0, 0, 0, 0, -Q2, -p2+p3, -Q3, 0],
            [0, 0, 0, 0, 0, 0, -Q3, -p3+2*p4, -Q4],
            [0, 0, 0, Q4, 0, 0, 0, -2*Q4, 0]])

C1 = L1 - w*matrix.identity(N)
C1 = C1.det()
C1 = C1.subs({Q0:prod(ni)/prod(Qn[1:])}).simplify_full()
D1 = C1*z
print(D1.collect(z).coefficients(z)[2])

variables = ["p{}".format(i) for i in (1..rank)] + ["Q{}".format(i) for i 
in (0..rank)]
R = PolynomialRing(QQ,variables)
R.inject_variables()
Q = R.gens()[rank:2*rank+1]
Qn = [Q[i]^ni[i] for i in (0..rank)]
I = R.ideal(prod(Qn)-prod(ni))
Rq = QuotientRing(R,I,variables)
p = Rq.gens()[0:rank]
Q = Rq.gens()[rank:2*rank+1]
LR = LaurentPolynomialRing(Rq,['w','z'])
LR.inject_variables()

L2 = Matrix([[-p1, Q1, 0, 0, 0, -4*Q0/z, 0, 0, 0],
            [Q1, p1-p2, Q2, 0, 4*Q0/z, 0, 0, 0, 0],
            [0, Q2, p2-p3, Q3, 0, 0, 0, 0, 0],
            [0, 0, Q3, p3-2*p4, 0, 0, 0, 0, 2*Q4],
            [0, Q0*z, 0, 0, p1, -Q1, 0, 0, 0],
            [-Q0*z, 0, 0, 0, -Q1, -p1+p2, -Q2, 0, 0],
            [0, 0, 0, 0, 0, -Q2, -p2+p3, -Q3, 0],
            [0, 0, 0, 0, 0, 0, -Q3, -p3+2*p4, -Q4],
            [0, 0, 0, Q4, 0, 0, 0, -2*Q4, 0]])

C2 = L2 - w*matrix.identity(N)
C2 = C2.det()
D2 = C2*z
display(D2.exponents(), D2.coefficients()[4])




On Tuesday, December 15, 2020 at 10:41:05 PM UTC Michael Orlitzky wrote:

> On 10/12/20 8:16 AM, Linden Disney wrote:
> > Attached is a jupyter notebook that runs Sage 9.1, a (slightly more) 
> > minimal example of a problem that I discovered. When calculating the 
> > determinant of a large (in the sense n>=9 I have currently found) 
> > symbolic matrix the answer is not correct....
>
> I've tried to translate this into a plain sage script (for the 
> command-line) to get a minimal example. Really, all we need is the 
> matrices, but I ran into some trouble with indices in the Qsimplify=True 
> branch. That could mean I don't know enough about Jupyter, but it also 
> might just mean that there's a bug in that part of the code.
>
> Is this still a problem for you? If so, can you try to reproduce only 
> the two (equivalent) matrices whose determinants are different? The 
> sage_input() function might be of some help here. Ideally the example 
> would look like
>
> <some variable definitions>
> A = matrix(...)
> B = matrix(...)
> A.det() == B.det()
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/f5897f51-c247-4095-8b53-b8209d9c2408n%40googlegroups.com.

Reply via email to