Relative Content

Tag Archive for sympy

Python sympy: changing the arguments when substituting a function

After a page of sympy manipulations I get and expression involving LambertW, but the answer given is for the zeroth branch cut. I can tell that I wanted the -1 branch. So, I’d like to change every occurrence of LambertW(y) into LambertW(y, -1).real, where y is an arbitrary sympy expression (that is different in each instance), in a set of expressions that are large enough so that doing it by hand is error prone.

Symbolic center of mass of the solution of linear inequalities

Given m linear equations over n + m variables {v1, …, vn, c1, …, cm}, how can I find the center of mass (CoM) of the part of n-dimensional hyperspace defined by vi >=0 and the equations? The CoM in general will be an expression with the cj variables still free.

SymPy pauli algebra should simplify terms if labels are in a different order?

The evaluate_pauli_product function in the Pauli Algebra module doesn’t simplify by combining terms which have the the same “label” values specified in a different order. If I’m understanding correctly that Pauli symbols with different labels effectively describe tensor products, does it make sense for the simplification to be made?

Codegen SymPy matrix

I have the following code where Aij and Bij are matrix of Sympy expressions :

My implementation for reproducing a paper

I’m trying to reproduce this paper. I’ve basically done everything and I’ve obtained the final expression of page 3. My only problem is that my implementation gets slow for larger numbers really fast.