3 ms·
I work in a department of applied math. Hard to conceive anybody around here who does not know how to solve a 2x2 linear system.
by enriquto 7y ago
I work in a department of applied math. Hard to conceive anybody around here who does not know how to solve a 2x2 linear system.
- zamadatix 7y agoSure in your individual case that may be but the scissor statement was presented generally as if one could walk up to any programmer. It only being immediately understood by a smaller subset makes it not very helpful. I can't think of a similar scissor the majority of programmers both already have a solid understanding of and would be likely to be divided on - but I'd love to be out thought!
- cle 7y agoI didn’t see it as trying I be helpful in the way you’re thinking, just illustrative. IMO, the best way to write the code (pulling in a lib vs doing it yourself) is to consider the context in which it’s going to be read, maintained, and used. If that’s by a bunch of applied scientists or linalg experts who can read a formula more easily than debugging and maintaining integrated libraries, then roll it yourself.
- zamadatix 7y agoIn the actual case of just needing to invert a single 2x2 matrix in one spot of the program it takes more to understand what the library is being asked to do, how to format the ask, and what it should be giving back than it does to understand the 3 commented steps to do it. Maybe put a comment that if the needs change in the future it might be worth pulling in <linear algebra library of choice>. On the flipside if you expect the needs to increase in the future might as well do it now. In the general case look at complexity of the options and then look at context of who has to maintain that complexity don't just assume 3rd party means it'll be easier for others to grok while bug hunting.
- jschwartzi 7y agoThe "scissor statement" ignores the very real fact that every individual system must be constructed with different tradeoffs and in a different context each time. You will find that engineers in one environment might include LAPACK, but then the same engineer given a different context would roll their own algorithm. Unless they're not really an engineer. Engineering is pragmatic, not dogmatic. Your job is to do the good thing for your system, not to apply first principles to everything. Approaching it from a position of dogma is not engineering.
- Someone 7y agoI have a M.Sc in maths. I can derive the algorithm to solve a 2x2 linear system in the reals or the complex numbers, but I’m not sure I know how to do that properly in IEEE floats or doubles. In particular, I wonder whether ill-conditioned edge cases (https://en.wikipedia.org/wiki/Condition_number https://en.wikipedia.org/wiki/Condition_number) might need special-casing. Having said that, I’m not convinced I could easily judge the quality of a third party solution, find a library that favors accuracy over speed, if I needed one, or whether existing libraries properly document how much overhead calling a routine taking nxn matrices for 2x2 matrices takes, if I needed a fast implementation.