[SciPy-user] Solve

Eduardo Rodrigues elr1979 at gmail.com
Tue Nov 6 11:31:39 EST 2007


If I want to solve an equation with linalg.solve I must know the equation, right? 

>From help:
"solve(a, b)
    Return the solution of a*x = b"

But if I don't know - or if I don't want to look - the equation for x, how can I solve it?
I will import equations from a file.

[]'s.




  ----- Original Message ----- 
  From: Michael Nandris 
  To: SciPy Users List 
  Sent: Tuesday, November 06, 2007 10:42 AM
  Subject: Re: [SciPy-user] Solve


  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





------------------------------------------------------------------------------


  _______________________________________________
  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/e18a2d87/attachment.html>


More information about the SciPy-User mailing list