When I use lambdify to turn a sympy function into one that can be used numerically, I need to pass the variables in the function as the first argument. I know that the number of Arguments is important, but is the order also important? How do I know, which letter is assigned to which variable in the original equation. For example:
x, b , c , d , r , z , p = symbols('x b c d r z p')
eq = x*b*c*d
la = lambdify((x, b, c, d), eq)
I have entered the right order with the variables used prior, but I can also use the following without getting an error:
la = lambdify((r, x, z, p), eq)
Now I don't know what is assigned to what. And when I try to solve the equation with la(...) I don't know in what order to put the values. Is x now the first or the second value?
As per the documentation:
(I bolded the text to highlight the important line.)
This means that you should call the lambdified result with the arguments in the same order as they were passed when you lambdified it. So, in your first version
xshould be the first argument and in the second it should be the second.But keep in mind that in your second version,
r,z, andqwon't do anything since they don't appear ineq, but you will still have to pass something for those variables.Also, you can call
help(la)and it will show you the generated function.Here you can see that the function signature is
(x, b, c, d).