Skip to content

Tag: sympy

Convert list of strings SymPy to symbols and use in solveset

The post “How can I convert a list of strings into sympy variables?” discusses how to generate SymPy symbols from a list of strings. My question is what steps are needed to use these symbols x, y and z in SymPy calculations? I tried something along the lines but I get the error “NameError: n…

How to solve the ‘mul objective has no attribute ‘cos’ ‘

How to solve the multi object problem? If I input 2, the expected result should be 2*cos(2*x). Answer Your code contains a few misconceptions. One problem is an important general programming rule: try to use different variable names for variables with different meanings. So, x shouldn’t be assigned a fl…

Displaying sympy equations on matplot

Now I want to display the sympy equation “eq” on the plot. I have seen many methods to display the same equation using tex commands, but I specifically want to display the sympy eq. Thanks in advance Answer You could use sympy’s latex() function like this:

symbolic complex expression simplification

Although my question is related to a specific problem, I would like to approach it in more general terms. I would like to simplify a fractional complex expression obtained by multiplying symbolic matrices using the sympy package. What I get is a fraction with real parameters and many complex exponential terms…

How to use sympy to algebraically solve a two sided equation

I’d like to use sympy to solve he following equation in terms of x, g, and w. Here’s what I thought I should code But this seems to be trying to solve for a numerical answer. Answer You can create a 2-sided equation with Eq: When you say that you want to solve “in terms of x, g and w”