# sympy

## Can SymPy Lambdify translate core functions like Add and Mul?

Can SymPy Lambdify translate core functions like Add and Mul? Question: My goal is to evaluate a basic symbolic equation such as ad(b + c) with my own custom implementaions of multiply and addition. I’m trying to use lambdify to translate the two core SymPy functions (Add and Mul) with my own functions, but I …

## subscripts in sympy and python

subscripts in sympy and python Question: I’m learning sympy and python by studying sample codes I found online. I came across this line of code z = symbols("z_{0:2}") which creates the variables z_0 and z_1. This is very handy! Now, the z_{0:2} construction reminds me of the range function in basic python. My question: Is …

## Numeric calculation of nullspace with Sympy is slow

Numeric calculation of nullspace with Sympy is slow Question: I want to obtain the bases for kernel (nullspace) of a matrix using the Row Reduced Echelon Form (RREF). Although scipy has the function to calculate nullspace, it does not give me sparse vectors because it uses singular value decomposition (SVD). #make an example import random …

## How to substitute values in matrix operation without solving?

How to substitute values in matrix operation without solving? Question: Literally what it says in the title. Let’s pretend the operation is addition of matrices. from sympy import Matrix, latex A = Matrix([[-7, 0], [4, 0]]) B = Matrix([[2, 0], [-3, -3]]) print( (A+B).a_method_that_evaluates_but_does_not_solve() ) I would like to get the following output. [[-7 + …

## How to solve logarithm and exponential equations in python

How to solve logarithm and exponential equations in python Question: i’m trying to write a function which take input as logarithm equations(examples as below) and return results. examples:log(2x+1)=2, log(x+1)=3, log(y+1)=4, log(2y+1)=4 ….. i’m not able to write a standardised code for above so can anyone help me with that. import sympy def solve_expression(expression): return solution …

## How to find x and y value for following expressions using python expressions 1:2x+1=2 and expressions 2:x-y=3

How to find x and y value for following expressions using python expressions 1:2x+1=2 and expressions 2:x-y=3 Question: 2x+1=2, x-y=3 In python i’m trying to solve above equations to get x and y value using python. from sympy import symbols, solve, sympify, Eq def find_variables(eq1, eq2, var1, var2): x, y, a, b = symbols(‘x y …

## TypeError: cannot create mpf from x

TypeError: cannot create mpf from x Question: I’ve checked multiple other answers for this error, but can’t figure out why this is occuring. from sympy.solvers import nsolve from sympy import Symbol, log x = Symbol(‘x’) u = nsolve(log(x/0.06) / (x-0.06) – 8,x) print(u) Traceback (most recent call last): File "C:UserscyjacPycharmProjectspharmacomescrap.py", line 5, in <module> u …

## How can I use sympy sum over elements of a list in python?

How can I use sympy sum over elements of a list in python? Question: I am just trying to use a sympy sum over a list of elements, for example: x = [1,2,3,4,5] expression = sympy.sum(x[i], (i,0,2)) * sympy.sum(x[j], (j,1,3)) and I just want it to numerically evaluate this. I always get index out of …