Python Forum
SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem
#1
Hello I am trying to solve set of equations and I actually know the how to solve them but I am having some problems and for some reason I cannot give the coefficients correctly I guess

So, Here is my equations:

(a + d)*(rho00*(a + d) + rho10*(b - 1.0*I*c)) + (b + 1.0*I*c)*(rho01*(a + d) + rho11*(b - 1.0*I*c)) = rho00
(a - d)*(rho01*(a + d) + rho11*(b - 1.0*I*c)) + (b - 1.0*I*c)*(rho00*(a + d) + rho10*(b - 1.0*I*c)) = 0.937*rho01
(a + d)*(rho00*(b + 1.0*I*c) + rho10*(a - d)) + (b + 1.0*I*c)*(rho01*(b + 1.0*I*c) + rho11*(a - d))=0.9358*rho10
(a - d)*(rho01*(b + 1.0*I*c) + rho11*(a - d)) + (b - 1.0*I*c)*(rho00*(b + 1.0*I*c) + rho10*(a - d))=0.98*rho11
And I wrote this code line after all
#sympy.linsolve([dwe[0][0]-exp_idt[0][0], dwe[0][1]-exp_idt[1][1],dwe[1][0]-exp_idt[2][2],dwe[1][1]-exp_idt[3][3] ], (a, b, c,d))
But I got a never endless error :////
How to solve this set of equations?
Fyi, here is my arrays:
exp_idt=[ 1.   ,  0.   ,  0.   ,  0.   ],
              [-0.   ,  0.937, -0.004, -0.005],
              [ 0.023,  0.014,  0.935, -0.03 ],
              [ 0.011, -0.009,  0.017,  0.983]]
dwe=[[(a + d)*(rho00*(a + d) + rho10*(b - 1.0*I*c)) + (b + 1.0*I*c)*(rho01*(a + d) + rho11*(b - 1.0*I*c))
  (a - d)*(rho01*(a + d) + rho11*(b - 1.0*I*c)) + (b - 1.0*I*c)*(rho00*(a + d) + rho10*(b - 1.0*I*c))]
 [(a + d)*(rho00*(b + 1.0*I*c) + rho10*(a - d)) + (b + 1.0*I*c)*(rho01*(b + 1.0*I*c) + rho11*(a - d))



  (a - d)*(rho01*(b + 1.0*I*c) + rho11*(a - d)) + (b - 1.0*I*c)*(rho00*(b + 1.0*I*c) + rho10*(a - d))]]
Reply
#2
The equations are not linear. Linsolve can solve only systems of linear equations.
Reply
#3
you can use np.polyfit see: https://numpy.org/doc/stable/reference/g...lyfit.html
Reply
#4
well, the problem is here a,b,c,d are variables which I want to find them but rho00, rho01 rho10, rho11 are the free varibles which will not take a value and I do not know how to give these equations to python. Otherwise I can use
fsolve
for non linear equations or
nonlinear solver
is one of the tool too. But I do not know how to give these equations to python to solve them with free variables
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to properly extract mathematical equations and images from PDF for a Python RAG c IchNar 2 97 Jan-27-2026, 11:53 PM
Last Post: Pedroski55
  Solving graph problem Dolyk 1 846 Mar-18-2025, 07:40 PM
Last Post: Larz60+
  Lidar in python - Quaternions, Angular Velocity, Linear Accelleration? jttolleson 2 2,313 Nov-27-2023, 02:05 AM
Last Post: jttolleson
Question Linear Programming Problem Axel_LF 0 1,705 Feb-23-2023, 11:03 PM
Last Post: Axel_LF
  Matplot / numpy noisy data problem the57chambers 1 2,204 Feb-09-2023, 03:27 AM
Last Post: deanhystad
  problem adding two numpy arrays djf123 2 3,458 Aug-09-2022, 08:31 PM
Last Post: deanhystad
  Need help solving a problem rufenghk 7 5,622 Jun-04-2022, 10:15 PM
Last Post: rufenghk
Heart how to solve complex equations in python HoangF 3 4,530 Dec-26-2021, 07:04 PM
Last Post: HoangF
  Solve a system of linear equations with binary variables lopeslimagabriel 3 4,350 Sep-24-2020, 07:09 AM
Last Post: scidam
  Problem in solving optimization problem Ruchika 0 2,313 Jul-27-2020, 05:28 AM
Last Post: Ruchika

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020