Another alternative would be to use Math::Symbolic to solve certain classes of equations. The manual of Math::Symbolic::MiscAlgebra has the following on it:
linear_solve
Calculates the solutions x (vector) of a linear
equation system of the form "Ax = b" with "A"
being a matrix, "b" a vector and the solution "x"
a vector. Due to implementation limitations, "A"
must be a quadratic matrix and "b" must have a
dimension that is equivalent to that of "A".
Furthermore, the determinant of "A" must be
non-zero. The algorithm used is devised from
Cramer's Rule and thus inefficient. The preferred
algorithm for this task is Gaussian Elimination.
If you have a matrix and a vector of real numbers,
please consider using either Math::MatrixReal or
Math::Pari instead.
Note that the complexity of Cramer's rule is O(n!) whereas Gaussian Elimination works in O(n^3) as noted by others in this thread.
Steffen
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|