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
  Lidar in python - Quaternions, Angular Velocity, Linear Accelleration? jttolleson 2 546 Nov-27-2023, 02:05 AM
Last Post: jttolleson
Question Linear Programming Problem Axel_LF 0 739 Feb-23-2023, 11:03 PM
Last Post: Axel_LF
  Matplot / numpy noisy data problem the57chambers 1 700 Feb-09-2023, 03:27 AM
Last Post: deanhystad
  problem adding two numpy arrays djf123 2 2,104 Aug-09-2022, 08:31 PM
Last Post: deanhystad
  Need help solving a problem rufenghk 7 2,615 Jun-04-2022, 10:15 PM
Last Post: rufenghk
Heart how to solve complex equations in python HoangF 3 2,810 Dec-26-2021, 07:04 PM
Last Post: HoangF
  Solve a system of linear equations with binary variables lopeslimagabriel 3 2,510 Sep-24-2020, 07:09 AM
Last Post: scidam
  Problem in solving optimization problem Ruchika 0 1,577 Jul-27-2020, 05:28 AM
Last Post: Ruchika
  How to Solving non-linear equation using scipy.optimize fsolve with variable list djhak 3 4,551 Jun-10-2020, 04:12 PM
Last Post: Gribouillis
  Python scipy odeint: solving with solution-dependent functions etienne 0 2,756 Jun-05-2020, 01:29 PM
Last Post: etienne

Forum Jump:

User Panel Messages

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