Questions tagged [lambdify]

Module lambdify of sympy package provides convenient functions to transform sympy expressions to lambda functions which can be used to calculate numerical values

Module lambdify provides convenient functions to transform sympy expressions to lambda functions which can be used to calculate numerical values.

For more information look for sympy documentation about Lambdify module.

75 questions
1
vote
1 answer

Use Sum Indexed and Lambdify, and scipy to minimize a large expression

I have a huge expression around 231 terms and each of these expressions has some power of cos(e) or sin(e) and they can be mixed as well, each term also has an r(distance) term in the denominator raised to some power as well. Here is a small…
arrhhh
  • 99
  • 2
  • 16
1
vote
1 answer

Python Sympy substitute symbolic matrix for (into a) symbol

q_vec, omega_vec, q1, q2, q3, w1, w2, w3 = \ sym.symbols('q_vec, omega_vec, q1, q2, q3, w1, w2, w3') q_0_dot_str = '.5 * dot(q_vec, omega_vec)' q_0_dot_symp = sym.sympify(q_0_dot_str) q_0_dot_symp = q_0_dot_symp.subs([(q_vec,…
1
vote
1 answer

Python 3: Sympy: Include list information to optimize lambdify

I use lambdify to compile an expression which is a function of certain parameters. Each parameter has N points. So I need to evaluate the expression N times. The following shows a simplified example on how this is done. import numpy as np from…
The Quantum Physicist
  • 24,987
  • 19
  • 103
  • 189
0
votes
1 answer

What is the correct way to pass TensorFlow arrays to Sympy's lambdify() function?

I am trying to generate a function from Sympy using lambdify() with tensorflow module. I am not getting the right answer when I pass a tensorflow array. I think this could be a problem with how I am passing the arguments to the function. import…
raktimb
  • 1
  • 1
0
votes
1 answer

How to find min distance between a point and a surface

I have equation of a surface (for example: x^2+y^2=400) and a point (for example: 1,2,3). I want to calculate the approx min. distance between that surface and a point. I tried using following function for it: def distance_to_surface(equation,…
somnath
  • 21
  • 3
0
votes
2 answers

SymPy - Kronecker Delta Function Evaluation

I am using SymPy for the numerical analysis of large sets of equations. Part of my equation contains a Kronecker Delta function acting as an impulse such that when q = 0 -> dirac_delta = 1, otherwise dirac_delta = 0. I need to perform this for…
Euan Tough
  • 13
  • 3
0
votes
2 answers

Problem with plotting multiple functions with a for loop in matplotlib

I am using a for loop to plot a curve for each parameter-value (k) - this works just fine for all the negative k-values, but when the loop reaches the k values = 0 or greater, the lambdify function seems to collapse and I get an error stating the…
0
votes
1 answer

TypeError: unhashable type 'numpy.ndarray' followed by SympifyError

I am following the steps on https://www.sympy.org/scipy-2017-codegen-tutorial/notebooks/22-lambdify.html in order to produce a plot of a surface. The example shown on the link works perfectly to me. Now, the problem appears to me when trying to…
0
votes
1 answer

Problems with quad when using lambdify

I'm trying to solve these two integrals, I want to use a numerical approach because C_i will eventually become more complicated and I want to use it for all cases. Currently, C_i is just a constant so _quad is not able to solve it. I'm assuming…
0
votes
0 answers

Problem with Sympy lambdify with functions of 'x' or constants

I have working code using sympy.lambdify for a user input function string and then to plot the function. It fails if the function entered is just a constant number. The code I am using is import sympy as sy import numpy as np import…
KitingPaul
  • 49
  • 5
0
votes
1 answer

Unexpected behaviour of sympy.lambdify with trigonometric functions

Given an expression, we can convert it into a function using sympy.lambdify. Similarly, given a function, we can convert it into an expression by evaluating it at symbol x. We would naturally expect that these two operations are inverses of each…
0
votes
2 answers

Big numbers in lambdify

I have (automatically generated by SymPy) expression, including sqrt function with big numbers under sqrt and small multiplier in front of it. So overall result must be within float range, but value under sqrt - is not. I coonvert this expression…
nickme
  • 37
  • 5
0
votes
1 answer

lambdify sympy with Variable-Length Arguments

I have a list of expr with a different number of variables as follows: G = [[-x_1 + y_1], [-x_2 + y_1 + y_2], [y_1 + y_2] , [-y_3] , ....] I want to evaluate these expressions using sympy and lambdify. For this purpose, I have written the following…
AComputer
  • 519
  • 2
  • 10
  • 21
0
votes
1 answer

How to use dictionary with lambdify

I wrote sympy functions with parameters. For example, ampl, freq, phase, cte, t =sp.symbols('ampl freq phase cte t') func=sp.Function("Func")(t) func=ampl*sp.cos(freq*t+phase)+cte To plot, this function, I use lambdify in this way…
Stef1611
  • 1,978
  • 2
  • 11
  • 30
0
votes
1 answer

python sympy lambdify not working inside function

I'm trying to write a function that has a literal function as a parameter: def derive(x, y): x = symbols(x) y = symbols(y) return lambdify(x, y) derive(5, 'x**2') This returns a syntax error: File "", line…
Reef
  • 35
  • 5