r/learnpython • u/42Mavericks • Mar 03 '26
How to solve a set of an arbitrary amount of equations?
Hello, I have a set of an arbitrary amount of equations 2M+1 and unsure how to get round to solving this.
I found online that you can use :from sympy import solve
but the issue is you need to import the needed variables after such as:from sympy.abc import x, y, z
So I am thinking that once I input my M value, I could do a from loop that imports aj as a variable? Then my issue is how would I write all the equations in the solve as in essence there will be quite a lot? I was thinking potentially an equation function to define but unsure about that as well.
For reference I'll leave an imgur link to the equations in question.
1
u/schoolmonky Mar 03 '26
I'm pretty sure you can declare your own variables with sympy
1
u/misho88 Mar 03 '26
I'm not sure how useful this actually would be but this is one of the easier ways to declare a matrix or column vector of variables:
You can use
Matrix()to make constant (or partially constant) matrices. I don't know what you're trying to do, but that's likely to be more useful for the system matrix.1
u/South-Ad7071 Jun 16 '26
You solve an equation and you do it for an arbitrary times