Skip to content

Instantly share code, notes, and snippets.

@mango314
Created March 23, 2015 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mango314/cd9bbc0da078481767fd to your computer and use it in GitHub Desktop.
Save mango314/cd9bbc0da078481767fd to your computer and use it in GitHub Desktop.
from sympy import symbols
from sympy.matrices import *
from sympy import collect
x,t = symbols('x a b c d')
V = Matrix([[2*x+a, 1, 0,0], [1, 2*x+b, 1,0], [0, 1, 2*x+c,1], [0,0,1,2*x+d]])
collect(V.det(),a)
"""a*(b*c*d + 2*b*c*x + 2*b*d*x + 4*b*x**2 - b + 2*c*d*x + 4*c*x**2 + 4*d*x**2 - d + 8*x**3 - 4*x) + 2*b*c*d*x + 4*b*c*x**2 + 4*b*d*x**2 + 8*b*x**3 - 2*b*x + 4*c*d*x**2 - c*d + 8*c*x**3 - 2*c*x + 8*d*x**3 - 4*d*x + 16*x**4 - 12*x**2 + 1"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment