On May 2, 11:23 pm, Stefan Behnel <stefan...@behnel.de> wrote: > Terry Reedy, 03.05.2011 08:00: > > > 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). > > As your above paragraph proves, it's the kind of implementation that > requires three lines of executing code and at least 6 lines of additional > comment. Hopefully accompanied by an excuse of the developer.
If you found nothing educational, interesting, or amusing about the three-line linear equation solver, then you're *really* going to hate this one: http://groups.google.com/group/comp.lang.python/browse_frm/thread/e46de4596e93188b/ Raymond @raymondh -- http://mail.python.org/mailman/listinfo/python-list