Questions tagged [sympy]

SymPy is an open source Python library for symbolic mathematics.

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.

Some examples of usage can be found here.

SymPy includes features ranging from basic symbolic arithmetic to calculus, algebra, discrete mathematics, quantum physics. It is capable of formatting the result of the computations as LaTeX code.

Some Core capabilities:

  • Basic arithmetic: *, /, +, -, **
  • Simplification
  • Expansion
  • Functions: trigonometric, hyperbolic, exponential, roots, logarithms, absolute value, spherical harmonics, factorials and gamma functions, zeta functions, polynomials, hypergeometric, special functions, ...
  • Substitution
  • Arbitrary precision integers, rational and floats
  • Non-commutative symbols
  • Pattern matching
  • Polynomials
  • Basic arithmetic: division, gcd, ...
  • Factorization
  • Square-free factorization
  • Calculus
  • Limits
  • Differentiation
  • Pretty-printing: ASCII/Unicode pretty-printing, LaTeX
  • Code generation: C, Fortran, Python
5602 questions
2
votes
1 answer

How do you iterate over Points in a Polygon?

I have created a Polygon using the sympy.geometry package as below: poly1 = Polygon((39.,4.), (32.,30.), (40.,10.), (42.,10.), (43.,14.)) The points of the Polygon are lon/lat co-ordinates. I now want to project the polygon onto an ellipsoid (the…
user7146075
2
votes
1 answer

Integrating Log-Normal PDF in sympy

Why won't SymPy integrate a standard Log-Normal PDF to 1? I'm running the following code in Python 3.x and SymPy 1.0.1: from sympy.stats import density, LogNormal from sympy import Symbol, integrate, oo mu, sigma = 0, 1 z = Symbol('z') X =…
user7123236
2
votes
1 answer

sympy ccode number type

I am using Sympy to manipulate and differentiate a user-defined input function in order to generate a C++ library to be used with an external C++ program. It works great, except that for the fact that Sympy insists on expressing 1/2 as 1.0L/2.0L.…
samwise
  • 23
  • 4
2
votes
1 answer

Make this painfull process a bit faster (python, sympy, latex)

well frst of all I have one big project from mechanical engineering rolling at the moment. I need to construct and calculate whole crane construction and I am looking for help because I'm new in python. It will be over 100 pages of calculations and…
bubiZG
  • 21
  • 2
2
votes
2 answers

Working with abstract mathematical Operators/Objects in Sympy

I am wondering if there is an easy way to implement abstract mathematical Operators in Sympy. With operators I simply mean some objects that have 3 values as an input or 3 indices, something like "Operator(a,b,c)". Please note that I am refering to…
P. Aumann
  • 41
  • 4
2
votes
3 answers

sympy arbitrary function range

I want to define the arbitrary function f. I know that f always returns a positive number. I want sympy to be able to use this knowledge when running simplifications (especially the three power rules mentioned in the simplify documentation). Is…
bramtayl
  • 4,004
  • 2
  • 11
  • 18
2
votes
3 answers

Solve set of simple equations given only a few variables

I have a set of a few hundred simple sum equations. For example here are 3: w1 - u1 - u2 = 0 w1 + w2 - w3 - u3 = 0 w1 - w2 - w4 = 0 I am trying to find a way to solve as many as possible given only a few of the values. For example, in the above…
jprockbelly
  • 1,533
  • 15
  • 30
2
votes
1 answer

How to use SymPy to substitute a pattern

In my code I need to substitute ALL the expressions of sin(g(t)) (g being a continuous function) to g(t) (it's the tight angle approximation). This is a sample of what I get from my code: -29.4*sin(2*t) - 19.6*sin(f(t)) + 4.0*Derivative(f(t),…
zivo
  • 120
  • 8
2
votes
1 answer

Sympy: using a symbolic expression as a numerical integrand

I need to manipulate a function symbolically, and then numerically integrate the function. How do I correctly use my expression f in the integrand function. How do I use lambdify correctly if that is even the sensible way to do it? Many thanks. from…
Tom
  • 223
  • 1
  • 2
  • 11
2
votes
1 answer

Error when using sympy's solver on polynomials with complex coefficients (4th deg)

Trying to solve a 4th degree polynomial equation with sympy, I arrived at some difficulties. My code and the equation i'm trying to solve: import sympy as sym from sympy import I sym.init_printing() k = sym.Symbol('k') t, sigma ,k0, L , V =…
Ranc
  • 135
  • 5
2
votes
1 answer

Can't use sympy parser in my class; TypeError : 'module' object is not callable

I wrote some code for calculating the differential equation and it's solution using sympy, but I'm getting an error, my code : ( example ) from sympy.parsing import sympy_parser expr=1/2 r='3/2' r=sympy_parser(r) I get TypeError: 'module' object…
zivo
  • 120
  • 8
2
votes
1 answer

Disable automatically rationalizing denominators in sympy

Is there any way to stop automatically rationalizing denominators in sympy? I want to get non-rationalizing output 1/sqrt(2) as output of cos(pi/4). Now I get sqrt(2)/2 as output of cos(pi/4).
user6695701
  • 197
  • 1
  • 10
2
votes
1 answer

sympy solve linear equations XOR, NOT

I have 60 equations with 70 variables. all of them are in one list: (x0,x1,...,x239) are sympy symbols list_a = [Xor(Not(x40), Not(x86)), Xor(x41, Not(x87)), ...] and my question is, if it is possible somehow transform this equations to matrix or…
lukas kiss
  • 381
  • 2
  • 15
2
votes
1 answer

How can I install mpmath as an external library for Blender?

I'm interested in trying out sympy with Blender (v2.76, Python 3.4.2 Console, Windows 8.1). I followed this answer from Blender SE, downloaded sympy as a ZIP from Githib, and moved the sympy folder to C:\Program Files\Blender…
DragonautX
  • 860
  • 1
  • 12
  • 22
2
votes
1 answer

Naming a set of equality equations Python

I am currently working on solving a system of equations. A subset of the equations are: eq1 = pi1 * q[0+1] == pi0 * r[0+1] eq2 = pi2 * q[0+1] == pi0 * r[1+1] + pi1 * r[1+1] eq3 = pi3 * q[0+1] == pi0 * r[2+1] + pi1 * r[2+1] + pi2 *…
Student NL
  • 409
  • 6
  • 16