[SciPy-user] Solve

Michael Nandris mnandris at btinternet.com
Tue Nov 6 08:42:43 EST 2007


These examples for solving equations are in scipy_tutorial.pdf

from scipy import mat, linalg 

"""
Solves three simultaneous equations: 
    x + 3y + 5z = 10
    2x + 5y + z = 8
    2x + 3y + 8z =3
"""

XYparameters = mat('[1 3 5; 2 5 1; 2 3 8]')
constants = mat('[10; 8; 3]')
print linalg.solve( XYparameters, constants )
                                        # array([[-9.28],
                                        #        [ 5.16],
                                        #      [ 0.76]])

"""
Solves two simultaneous equations: 
    5x + 2y - 9 = 0         
    3x + 4y - 4 = 0 
"""

XYparameters = mat('[5 2; 3 4]')
constants = mat('[9; 4]')
print linalg.solve( XYparameters, constants )  # should print (2,-0.5)

Eduardo Rodrigues <elr1979 at gmail.com> wrote: Hi, I am starting in Python. I usually use Maple and I am with a problem to 
do the same project in Python.
I would like to solve an equation like x+y+1=0 for x. In Maple I use 
"solve(x+y+1=0,x);".
Do exist a similar command in Python/NumPy/SciPy?
Regards,
Eduardo. 

_______________________________________________
SciPy-user mailing list
SciPy-user at scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20071106/a7b0b2b4/attachment.html>


More information about the SciPy-User mailing list