Coolest Python recipe of all time

Algis Kabaila akabaila at pcug.org.au
Tue May 3 19:25:57 EDT 2011


On Tuesday 03 May 2011 16:00:05 Terry Reedy wrote:
> On 5/3/2011 1:04 AM, Stefan Behnel wrote:
> > The bad thing about this recipe is that it requires quite a
> > bit of background knowledge in order to infer that the
> > code the developer is looking at is actually correct.
> 
> The main math knowledge needed is the trivial fact that if
> a*x + b = 0, then x = -b/a. The other math knowledge needed
> is that complex numbers add componentwise. The trick is that
> replacing x with j and evaluating therefore causes (in
> Python) all the coefficients of x (now j) to be added
> together separately from all the constant terms to reduce
> the linear equation to a*x+b (= 0 implied).

But the title of the project is wrong and misleading. In the 
description it says "linear equations solver" which suggests 
that it solves systems of linear equations - linalg.

As has been pointed out, a "linear" equation can be solved by 
had in one line...

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110504/b5e770af/attachment-0001.html>


More information about the Python-list mailing list