Tech News World, Contacts Samsung Galaxy, Windows 8, Nokia Lumia, Quad Core Smart Phones, HTC smartphone, Google Nexus, MacBook, PayPal

Friday, October 25, 2013

Solving a Linear Systes of Equations Using python

Solving a Linear Systes of Equations Using python - Although I work in the office and a lot of work that makes me tired but still I make a blog Tech News World and still will update it for you because this is part of my hobby who likes the world of technology, especially about the gadget, now we will discuss first about Solving a Linear Systes of Equations Using python because it is the topic that you are now looking for, please refer to the information I provide in the guarantee for you,

Articles : Solving a Linear Systes of Equations Using python
full Link : Solving a Linear Systes of Equations Using python

You can also see our article on:


Solving a Linear Systes of Equations Using python

Solving linear systems of equations is straightforward using the scipy command linalg.solve. This command expects an input matrix and a right-hand-side vector. The solution vector is then computed. An option for entering a symmetrix matrix is offered which can speed up the processing when applicable. As an example, suppose it is desired to solve the following simultaneous equations:
\begin{eqnarray*} x+3y+5z & = & 10\\ 2x+5y+z & = & 8\\ 2x+3y+8z & = & 3\end{eqnarray*}
We could find the solution vector using a matrix inverse:
\[ \left[\begin{array}{c} x\\ y\\ z\end{array}\right]=\left[\begin{array}{ccc} 1 & 3 & 5\\ 2 & 5 & 1\\ 2 & 3 & 8\end{array}\right]^{-1}\left[\begin{array}{c} 10\\ 8\\ 3\end{array}\right]=\frac{1}{25}\left[\begin{array}{c} -232\\ 129\\ 19\end{array}\right]=\left[\begin{array}{c} -9.28\\ 5.16\\ 0.76\end{array}\right].\]
However, it is better to use the linalg.solve command which can be faster and more numerically stable. In this case it however gives the same answer as shown in the following example:
>>> import numpy as np
>>> from scipy import linalg
>>> A = np.array([[1,2],[3,4]])
>>> A
array([[1, 2],
[3, 4]])
>>> b = np.array([[5],[6]])
>>> b
array([[5],
[6]])
>>> linalg.inv(A).dot(b) #slow
array([[-4. ],
[ 4.5]]
>>> A.dot(linalg.inv(A).dot(b))-b #check
array([[ 8.88178420e-16],
[ 2.66453526e-15]])
>>> np.linalg.solve(A,b) #fast
array([[-4. ],
[ 4.5]])
>>> A.dot(np.linalg.solve(A,b))-b #check
array([[ 0.],
[ 0.]])



so much information about Solving a Linear Systes of Equations Using python

hopefully information Solving a Linear Systes of Equations Using python can provide useful knowledge for you in getting information about the latest gadgets,

just finished your reading article about Solving a Linear Systes of Equations Using python if you feel this article useful for you please bookmark or share using link http://aziin5teens.blogspot.com/2013/10/solving-linear-systes-of-equations.html for more people know

Tag :
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : Solving a Linear Systes of Equations Using python

0 comments:

Post a Comment