SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem (/thread-36229.html) |
SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem - quest - Jan-30-2022 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*rho11And 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))]] RE: SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem - Gribouillis - Jan-30-2022 The equations are not linear. Linsolve can solve only systems of linear equations. RE: SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem - Larz60+ - Jan-30-2022 you can use np.polyfit see: https://numpy.org/doc/stable/reference/generated/numpy.polyfit.html RE: SOlving LInear Equations in Python(Symoy, NUmpy) - Coefficient Problem - quest - Jan-30-2022 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 fsolvefor non linear equations or nonlinear solveris one of the tool too. But I do not know how to give these equations to python to solve them with free variables |