Ask Your Question

dstahlke's profile - activity

2016-07-28 04:29:04 -0500 received badge  Famous Question (source)
2012-10-12 08:43:28 -0500 received badge  Notable Question (source)
2012-05-03 05:09:44 -0500 received badge  Necromancer (source)
2012-05-03 05:09:44 -0500 received badge  Teacher (source)
2011-12-05 12:30:38 -0500 answered a question Lovasz number

Here you go. I've tested this against all of the graphs in the graph database. This code is adapted from someone's thesis which I found online. I cannot find the author's email address to ask if it can be made GPL or similar.

import cvxopt.base import cvxopt.solvers

# Adapted from Program 4.2, page 44, of the dissertation of Constantinos # Skarakis, http://keithbriggs.info/documents/Skarakis_MSc.pdf def lovasz_theta(G): '''Computes the Lovasz theta function for a graph.'''

Gc = G.complement() n = Gc.num_verts() m = Gc.num_edges()

# This case needs to be handled specially. if n == 1: return 1.0

d = m+n c = -cvxopt.base.matrix([0.0](n-1) + [2.0](d-n)) Xrow = [i(1+n) for i in xrange(n-1)] + \ [b+an for (a, b, _w) in Gc.edge_iterator()] Xcol = range(n-1) + range(d-1)[n-1:] X = cvxopt.base.spmatrix(1.0, Xrow, Xcol, (nn, d-1)) for i in xrange(n-1): X[nn-1, i] = -1.0 sol = cvxopt.solvers.sdp(c, Gs=[-X], hs=[-cvxopt.base.matrix([0.0](nn-1) + [-1.0], (n,n))]) v = 1.0 + cvxopt.base.matrix(-c, (1, d-1)) * sol['x']

return v[0]

# Some options I like to set. # http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#algorithm-parameters cvxopt.solvers.options['show_progress'] = False cvxopt.solvers.options['abstol'] = float(1e-10) cvxopt.solvers.options['reltol'] = float(1e-10)

#print lovasz_theta(graphs.CycleGraph(5))

2011-11-06 04:51:07 -0500 received badge  Popular Question (source)
2011-01-07 02:27:57 -0500 received badge  Student (source)
2011-01-06 16:54:26 -0500 asked a question Round trip through Mathematica's FullSimplify

The following command returns 1:

mathematica(-2/(1 + sqrt(3)*I)).FullSimplify().sage()

The issue is that Mathematica simplifies this expression to (-1)/(2/3), which it considers to be defined in terms of the primitive root. Sage on the other hand converts (-1)/(2/3) to 1, with the idea that any root will do. My question: is it a bug that putting this equation into Mathematica and bringing it back to Sage changes it from a complex number to a real number?