Home > Blockchain >  Solving non linear equations where equations are equals in python
Solving non linear equations where equations are equals in python

Time:03-27

I wonder and tried to google it, but I am not sure what to google it, how to solve linear equations where equations are equal between each other. I am able to write a specific algorithm for two equations but not dynamically for N equations. I will show the example of three (how my equations approximately looks like):

enter image description here

C1, C2, C3, X - are unknows, but I do not need to know result of X.

It can be interpreted like this (last equation C1 C2 C3 = 1 is not integrated here):

enter image description here

Please, don't try to solve this, I am not sure if these equations have results. I just randomly typed coefficients. But this is how my equations can looks like. Only with different coefficients. Ideally in python, but I will be happy if I know how to do it in maths with matrixes. I tried to calculated it with only two unknows and I have got quadratic equation in the end so with three unknowns there will be cubic in the end. With N unknows there will be polynomial equation with degree N. Also, I have to say, it do not have to be with 100% accuracy. I am not sure if its help somehow or not.

CodePudding user response:

Looks like you have a system of non-linear equations. For the example you provided, the system has four equations for four unknowns

enter image description here

where u is vector of unknowns C1, C2, C3, X, and f is vector function with components

enter image description here

You need to google for solvers of nonlinear systems of equations (e.g. nonlinear rootfinding problem). For python there is scipy.optimize.root, for example. Also, you may be interested to read chapters 4.5 and 4.6 of Fundamentals of Numerical Computation to understand choice of the solver.

  • Related