sympy

SymPy when trying to solve equations, you get an infinite loop

SymPy when trying to solve equations, you get an infinite loop Question: I’m trying to solve the equation 15*exp(ln(0.5)/4 * x) = 1 and I get into an infinity loop x = symbols("x") fun = 15 * exp(log(0.5)/4 * x) eq = Eq(fun, 1) ans = solve(eq, x) #infinity loop SymPy version 1.11.1 python version …

Total answers: 2

Simplify expressions given by sympy.sympify

Simplify expressions given by sympy.sympify Question: sp.simplify doesn’t seem to work when your expression is given by sp.sympify. How can I change that? import sympy as sp r = sp.Symbol(‘r’, real = True) f_str = ‘sqrt(1/r**4)’ f1 = sp.sympify( f_str ) f2 = sp.sqrt(1/r**4) for f in f1,f2: sp.pprint(sp.simplify(f)) which outputs ____ ╱ 1 ╱ …

Total answers: 2

How to extract symbols from parsed LaTeX equation in Sympy?

How to extract symbols from parsed LaTeX equation in Sympy? Question: I have parsed a LaTeX equation in Sympy, but now I need to extract the variables to symbols so that I can have Sympy solve/rearrange the equation for specific variables. I know I can use equation.free_symbols to see the symbols contained in the equation, …

Total answers: 1

Sympy not simplifying polygamma

Sympy not simplifying polygamma Question: I have a python script that finds the derivative of a function, within which is the gamma function. When substituting values in, instead of finding the digamma of the values and returning it as a float, sympy only returns polygamma (0, 1.05) or whatever the output is. Below is my …

Total answers: 1

Automatic reduction and cancellation of units with SymPy

Automatic reduction and cancellation of units with SymPy Question: I am having issues with getting units to cleanly simplify. The program I am writing is involved with the calculation of spring properties, requiring 10/11 user controlled variables and about a dozen equations, all of which deal with mixed sets of units. The one missing variable …

Total answers: 1

Deriving Heron's formula with Sympy using Groebner basis

Deriving Heron's formula with Sympy using Groebner basis Question: I’m trying to implement with Sympy the procedure described in this lecture, where Groebner basis is used to derive Heron’s formula, but I’m not able to implement the last step, the computation of the correct Groebner basis, surely because of my lack of understanding of the …

Total answers: 1

How to get a decimal instead of a fraction in sympy?

How to get a decimal instead of a fraction in sympy? Question: I am making a chemistry project for school, I want to use sympy for solving some density and concentration problems. solveset function returns the value as a fraction, for example: mL = Symbol("mL") density = Symbol("p") mass = 115*g volume = 100*ml print(solveset(Eq(density, …

Total answers: 1

Curve translation in Python does not reach expected value

Curve translation in Python does not reach expected value Question: Suppose I have two curves, f(x) and g(x), and I want to evaluate if g(x) is a translation of f(x). I used Sympy Curve to do the job with the function translate. However, I need help to reach the correct result. Consider the two functions: …

Total answers: 2