Solving Linear equations with constraint in Python - python

I have a system of linear equations with some constraints. I would appreciate it if someone could help me solving this system of equations in Python.

Should be fairly easy to solve with sympy: http://docs.sympy.org/dev/modules/solvers/solveset.html#sympy.solvers.solveset.linsolve
Add all your equations to a list. Then pass that list to linsolve(). You'll probably loop through each value of j to generate those equations.

Related

Solving nonlinear stiff ODE system in python or matlab

My problem is stationary combustion equations (BVP) with temperature and concentration-dependent equations with a form similar to that:
d(Lambda(C_i, T)dT/dx)/dx-C_eff(C_i, T)*dT/dx+Q(C_i,T)=0,
d(D(C_i, T)dC_i/dx)/dx-u*dC_i/dx+G(C_i,T)=0
i=1
These equations are pretty stiff and very non-linear because the source term exponentially depends on T.
Is there a Python or MATLAB package or solver or something that could help me? Standard MATLAB solvers are not suitable for such tasks. I have not tried Python yet, but I think it should be the same.

linear programming with python

I'am trying to solve a following problem.
In fact, this is Least Absolute Deviation Regression problem. I want to know how to solve this with python. I know that scipy has "linprog" which solve linear system with linear inequality constraints. But here there is two variable in inequality constraints, t, x. So, I want to know how to apply the "linprog" or is there other library which can solve this problem? Thanks
You have to write your problem in standard form, splitting the second inequality constraint and concatenating the two optimization variables. Then, you can feed it to linprog.
It is more of a math problem than an implementation one.

How to numerically solve this system of arbitrary number of differential equations?

How can I solve a system of k differential equations with derivatives appearing in every equation? I am trying to use Scipy's solve_ivp.
All the equations are of the following form:
equations
How can this system of equations be numerically solved using any solver? using solve_ivp, it seems you should be able to write every equation independent of the other ones, which seems not possible in this case when we have more than 2 equations.
If you set C[i]=B[i,i] then you can transform the equations to the linear system B*z'=A. This can be solved as
zdot = numpy.linalg.solve(B,A)
so that the derivative is this constant solution of a constant linear system, and the resulting solution for z is linear, z(t)=z(0)+zdot*t.

Symbolic solution of ODE with matix and vector

I'm trying to solve symbolically a system of the two following differential equations either in python or in r:
I want to find symbolic solutions for dH/dt=0 and dV/dt=0. However, I struggle to convert summations with matrixes and vector into code (python or R). Could someone help me?
Thanks in advance!

Solve N^2 nonlinear equations system

I am trying to solve a system of N*N nonlinear equations, but I get stuck and do not understand what is the problem.
My equations are :
h_{j,i} = (T/2) \sum_{k=1..N}{f(h_{k,j})} - (T/2) f(h_{i,j})
for i and j in [1..N]^2, and where the h are the unknowns, f is a known function and T is a parameter.
In all the examples I have found, there are maybe two or three equations/unknowns, so one can implement the equations directly. Nevertheless, I have too many equations here, and I do not understand how to implement a code without explicitly writing all the equations, and using fsolve (on python).
Thanks for your help

Categories

Resources