I've heard that there's a question which every programmer considers obvious...

I've heard that there's a question which every programmer considers obvious, but the "obvious" answers differ between programmers:
>You need to invert a 2x2 matrix in your program. Do you code it yourself or pull in a linear algebra library?
For me, it's obvious that you should code it yourself if you don't also need other linear algebra operations. Inverting a 2x2 matrix is just a few lines of code and it would be retarded to add a dependency for this. Shit "developers" adding libraries for every trivial thing to avoid writing 2-10 lines of code is why the JavaScript ecosystem is in such a terrible state.
Which answer is it for you?

Attached: formula-or-trick-to-find-inverse-of-2x2-matrix-1630645048.png (511x414, 19.76K)

Never work on anything that uses matrixes

I don't know the linear algebra

professional software developer here
i look it up on the internet and copy paste

Why do you need to invert it? Give me some use cases where it may be useful. Maybe we can do without inverting anything at all.

Same here

>it's obvious that you should code it yourself
Enjoy your numerical instability

>Numerical instability
You don't know math?

The opposite, so much so that whenever I see someone trying to implement their own numerical linear algebra I know they've no idea what they're doing. Writing code to invert a (2x2) matrix is trivial, writing code that won't suddenly blow up or loose precision for certain inputs is hard.

>Inverting a 2x2 matrix
Most western children know how to do this operation before they leave high school. At least this used to be the case. I'd doubt that now though.
Solving a simple set of linear equations in two variables.

You need to check whether a number is even or odd. Do you do it yourself, or pull in a library?

If it's a single matrix, I'd hand-code it. If it's two or more, use a library.

Its kinda cute. You literally just proven that you have no idea about math with your post. Stay stupid.

If I know something is just 5-20 lines of code I usually write it myself

It just seems very weird to me that you would have a single linear algebra formula in your program.

not op, but in /3/ it can be useful to transform a mesh, do some operations on it, and then invert the transform.

a very specific example is to do quick and cheap wood splinter type fracturing: squash the geo, voronoi fracture it, and then stretch it back to get elongated fractures (there are better ways to do this, this is just cheap)

Converting from one transform space to another. When you shove a set of poly's into your default matrix stack it converts from world space -> screen space. If you invert that matrix you can convert from screen space -> world space (though obviously you'll have to select a particular depth).

>Most western children know how to do this operation
In the abstract world of maths, it is trivial. In the real world, where you don't have the luxury of having a proper field for your vector space and have to deal with the intricacies of IEEE 754, it is not as trivial.

How would you code this operation then, if you had to and couldn't use a library?

Var a
Var b
Var c
Var d
Var A
Var n
Switch A(^n)
Case 1:
a,b,c,d
Break;
Case -1:
a, -b,c,-d
Break;
//Fag

>How would you code this operation
That depends on what it would be used for. But i'd probably just consult my copy of 9780898715217 before even thinking about writing a single line.