# sympy

• ## Why does sympy.diff not differentiate sympy polynomials as expected?2019-03-18

I am trying to figure out why sympy.diff does not differentiate sympy polynomials as expected. Normally, sympy.diff works just fine if a symbolic variable is defined and the polynomial is NOT defined using sympy.Poly. However, if the function is defi

Tags: python, sympy, polynomials
• ## Non-linear system of equations Julia2019-03-13

I'm trying to solve a large number (50) of non-linear simultaneous equations in Julia. For the moment I'm just trying to make this work with 2 equations to get the syntax right etc. However, I've tried a variety of packages/tools - NLsolve, nsolve in

• ## Using sympy on strings2018-12-21

I have a file with some equations. I want to solve them using sympy. I can use open('problems.txt',mode='r') to open the file. But how to proceed with sympy? I'm getting following error sympy.core.sympify.SympifyError: Sympify of expression 'could no

Tags: python 3.x, sympy
• ## lambdify a sympy expression that contains a Derivative of UndefinedFunction2016-03-27

I have several expressions of an undefined function some of which contain the corresponding (undefined) derivatives of that function. Both the function and its derivatives exist only as numerical data. I want to make functions out of my expressions a

Tags: python, python 3.x, sympy
• ## Evaluating math equation in Python2014-12-23

I would like to evaluate a first derivative of a math equation. I can hard code the formula and get the results but how I can do the same with different user input formulae. I am using Anaconda Python 2.7.9 The following one works when I first compil

Tags: python, math, numpy, eval, sympy
• ## Sympy Fourier Transform of exponential decay2014-11-17

Sympy correctly computes the FT of a double-sided exponential decay: x, k, k0 = symbols('x k k0') fourier_transform(exp(-k0 * abs(x)), x, k) --> 2k0 / (4pi^2k^2 + k0^2) Expected by hand calculation and confirmed by http://www.thefouriertransform.c

Tags: python, transform, fft, sympy, exponential
• ## Separating real and imaginary parts using Sympy2014-09-19

I am trying to segregate real and imaginary parts of the output for the following program. import sympy as sp a = sp.symbols('a', imaginary=True) b=sp.symbols('b',real=True) V=sp.symbols('V',imaginary=True) a=4*sp.I b=5 V=a+b print V Kindly help. Tha

Tags: python, sympy
• ## Sympy: Drop higher order terms in polynomial2014-07-28

Using Sympy, say we have an expression f, which is a polynomial of the Symbol "x" (and of potentially other symbols). I would like to know what if there is an efficient way to drop all terms in f of order greater than some integer n. As a special cas

• ## Equation roots: parameter doesn't get simplified2014-06-26

I am using Python with Sympy. I need to solve the following equation, finding the 4 roots (omega is my unknown): deter= 0.6*omega**4*cos(omega*t)**2 - 229.0*omega**2*cos(omega*t)**2 + 5880.0*cos(omega*t)**2 I tried to use solve: eqcarr=solve(deter,om

Tags: python, parameters, equation, sympy
• ## How to solve simbolically a pair of nonlinear equations using Python (sympy)?2014-03-25

I have the following code for a system of three nonlinear equations with three unknowns: import sympy as sp from sympy import symbols, cos, sin v0, a0, f0 = symbols('v0 a0 f0') v1, a1, f1 = symbols('v1 a1 f1') w, t = symbols('w t') g1 = v0 + a0 * w *

Tags: python 2.7, sympy
• ## Solve 2 sides of equation with SymPy2014-03-12

I have the following equation to calculate the boundary inductance in an electronic circuit. With SymPy, I can use Lb.evalf(subs={...}) to calculate Lb value when I have D, f and R. Lb = ((1-D)**2*D*R)/(2*f) Without having to re-arrange the equation,

Tags: python, math, solver, sympy
• ## compute x-component of vector in sympy2013-07-16

I'm sure this is a really basic question, but I've googled and haven't found it. Supposed I have a vector in sympy z = 3*x + 4*y How do I compute the x-component of the vector (i.e. the 3)? z/x doesn't give it (there's still the y-part), nor does z[x

Tags: python, sympy
• ## Substituting values using SymPy for initial conditions of odeint if they are present2013-06-24

I'm trying to solve a set of coupled ODE's using odeint in python; I initially created the program to solve 3 specified equations (where I use sympy.subs for each value I knew was present), but now I wish to solve N many coupled ODE's. The issue I am

Tags: python, numpy, sympy, scipy, enthought
• ## sympy and numpy or IPython compatibility?2012-04-22

I found that if I have both sympy and numpy (EDIT: or IPython) installed (32-bit windows 7), then I can only run sympy through its isympy script file, e.g., from a git-bash console pushd /c/Python27/Lib/site-packages/sympy/bin python isympy limit(dif

Tags: numpy, python 2.7, sympy
• ## Complex Roots of equation in Python 2012-04-16

I am trying to solve the following equation, def f(u1, u2, u3, u4, a11, a16, a12, a66, a26, a22): return a11*u4-2*a16*u3+(2*a12+a66)*u2-2*a26*u1+a22 where u1 to u4 are complex variables that I want the root for f() = 0 and a11 to a66 are arguments(fl

Tags: python, math, sympy, scipy
• ## Python: Using sympy.sympify to perform a safe eval() on mathematical functions2012-04-09

I am writing a program where users need to be able to use self written mathematical functions containing functions from numpy and scipy, eg. scipy.special.wofz(). These functions will be stored in files and imported as strings by the program. I looke

Tags: python, parsing, eval, sympy
• ## Factor/collect expression in Sympy2012-03-10

I have an equation like: R₂⋅V₁ + R₃⋅V₁ - R₃⋅V₂ i₁ = ───────────────────── R₁⋅R₂ + R₁⋅R₃ + R₂⋅R₃ defined and I'd like to split it into factors that include only single variable - in this case V1 and V2. So as a result I'd expect -R₃ (R₂ + R₃) i₁ = V₂⋅

• ## Sympy "global" substitution2012-03-05

I have a number of symbolic expressions in sympy, and I may come to realize that one of the coefficients is zero. I would think, perhaps because I am used to mathematica, that the following makes sense: from sympy import Symbol x = Symbol('x') y = Sy

Tags: python, sympy, symbolic math
• ## SymPy - Arbitrary number of Symbols2012-02-29

I am coding a function that solves an arbitrary number of simultaneous equations. The number of equations is set by one of the parameters of the function and each equation is built from a number of symbols - as many symbols as there are equations. Th

• ## Solving Systems of Equations with SymPy2012-02-25

I'm trying to solve a set of equations with SymPy 0.7.1: from sympy import * equations = [ Eq(S('vf'), S('vi + a*t')), Eq(S('d'), S('vi*t + 1/2*a*t**2')), Eq(S('a'), S('10')), Eq(S('d'), S('60')), Eq(S('vi'), S('5')) ] print solve(equations) produces

Tags: python, sympy