6,032 questions
Score of 0
1 answer
110 views
sympy only partially simplifies equation
README
I have written a Jupyter Notebook to check if an identity is true: for example
$\tan{x}=\frac{\sin{x}}{\cos{x}}$
(which is converted to Eq(sin(x)**2, (1 - cos(x))/2))
returns
True
whilst for
...
Advice
1
vote
2
replies
86
views
Make sympy use ≠ when equality is False
I have written a Jupyter Notebook (Q29175.ipynb) with the following contents:
$\frac{d}{d x}\cos^{3}{x}=-3\cdot (\cos^{2}{x})\cdot(\sin{x})$
import json
from sympy import *
from latex2sympy2_extended ...
Score of 3
0 answers
222 views
Higher order derivatives (20+) with SymPy give wrong results
(If it rings a bell but not really necessary to understand my question: I'm trying to look at high order dispersion in a medium using Sellmeier equations for the refractive index.)
I have two ...
Score of 2
2 answers
107 views
Substituting values for variables in an expression does not give the expected result
I have this little piece of Sympy code
import sympy as s
L1, L2, x = s.symbols('L1, L2, x', real=True, positive=True)
P, q = s.symbols('P, q')
m, kN = s.symbols('m, kN', real=True, positive=True)
E, J ...
Score of 1
1 answer
106 views
How to replace non-commutative products in SymPy with expressions?
I want to work around sympy's limitation of assuming partially commutative behavior. If I define the non-commutative symbols
import sympy as sy
u = sy.Symbol('u',commutative=False)
v = sy.Symbol('v',...
Advice
1
vote
2
replies
67
views
How to add an assumption (about commutativity) to sympy's expression algebra?
Suppose I define sympy.Symbols as follows
import sympy as sy
A = sy.Symbol('A',commutative=False)
B = sy.Symbol('B',commutative=False)
and combine them as
sy.simplify(AB-BA)
sympy correctly does not ...
Score of 3
1 answer
179 views
Infinite sum involving a parameter
How do I persuade SymPy to evaluate an infinite sum which converges and I know SymPy should be able to do? For example, the following just gives back the unevaluated infinite sum:
a = Symbol('a',real=...
Score of 3
1 answer
67 views
Sympy random_poly in GF(2) - looks like polynomial is on ZZ instead of GF(2)
I would like to generate random polynomial ith coefficient in GF(2), but I fail to do so, random_poly returns a polynomial with coef in ZZ. Here below is the python sequence (with ipython3)
In [23]: p=...
Score of 2
2 answers
231 views
How can I programmatically derive Taylor series?
So I know from physics that position at a given time can be calculated using its derivatives like this:
Now I know this looks awfully similar to Taylor series:
In fact they are exactly the same. ...
Score of 8
2 answers
213 views
Display problem using UnevaluatedExpr in Sympy with python
When I add another expression to Unevaluated(), then try to print it, the unevaluated output is surrounded by ().
The problem comes when the first coefficient in the resulting expression to be ...
Score of 4
1 answer
74 views
SymPy .equals() in combination with parse_latex() not giving the same results as .equals() without parsing?
I have a question about the way .equals() interacts with .parse_latex():
pef = parse_latex("\sin(\pi/2)")
print(pef.equals(1))
> False
print(sin(pi/2).equals(1))
> True
I've tried ...
Score of 1
2 answers
123 views
How to check if variable is infinite in sympy
Sympy has (at least?) three types of infinity (infinity, negative infinity, and complex infinity). I have come across the problem of testing if a sympy expression is infinite and my program failed ...
Score of 2
1 answer
113 views
parse_latex() incorrectly parsing Latex to Sympy
I'm trying to make a simple program that compares two Latex inputs and checks whether it's the same regarding math and notation. First, I wanted to check which mathematic expressions work without any ...
Score of 1
1 answer
58 views
Getting an TypeError when trying to use parse_latex() [closed]
I'm currently working on a project which needs to convert Latex strings into SymPy code. I am very new to SymPy. I've encountered a problem which I can't find the answer for myself:
from sympy.parsing....
Best practices
0
votes
2
replies
79
views
How to show step-by-step simplification and solution of a linear equation in Python?
I have a linear equation like this:
((x + b) * a) / (c * d) + ((x - b) * e) / (f * g) = 0
I want to solve it in Python step by step, showing all intermediate steps like in a school notebook.
I know I ...