### Matrix projection blues

Hi
on OpenCourseware MIT site:
Lecture 15: Projections onto subspaces

[edited :the code on sagecell.sagemath.org was not the good one ~~!]
[code on sagecell.sagemath.org](https://sagecell.sagemath.org/?z=eJytVMFuozAQvfsrRvQQHNykkKaHlXwAqYeVshKVcogURSsDDvGW2Ajclu7Xrw2UkKbpaW_DzLw38-Y5YSu6XZDlDgBuIFWqyoRkmtdQiFrDK0-1qoChxLbNA3K_-6YtQcWKLueBadmzNsObkslaKAlaQSbqsmDvUPHMwCQHIYcBpliZ0HQidAMHXnH4CSxTpQZ94GaifOXSlk1rjxG1iVNVvBwlHJmuRINC2gXu0xNhKzzTlZleqpq72OzU14LGxygadSbfdt5AXKk_3W7wqy0AgZQVhZGxsRrsgq8i4wpt5MuRhjAFNxwznighaAK0ybikrnvRNIUQ8CzjukPUZgar0IZa1rkFjTcLMKoP6s11DOgHOCQk4EDUhpENLaj9skGbsARtwgRtovvCKPeptcPdbm-L1ZTD3hpnhYUz666Ld2R7pbAjUPCcy-x3wRJe0ImxpDydy9JOhhbjlaroxNg_IaPYLBDQslDa7Yx1I9yXnbziXDrkTWT6QJfk06iPV3cxoYVZ3sUZbzjwJgVLnz94F1d4wwveFmZ42RooaN5o12EO-czet5G9kroWfzkN7jBKTpBkgAxC-43PITHdTKPxy_H_k-PEgbiNYgBzpPuzI8UjGS_GvCu37002P4H-WvEX1zJ4jMqT8nJQHuOpP7tbno8a1C-M-kca3cbn6vNltymrKnOGeJYqvt-LVJg_htrFJPqc6MlLIZ-v6ui3v3ylLQpjxE_r82H9RzwPvK-ldNPOjGxdy30vD7x84eX3Xr702NpL1l659via7EXe9roPBB4waY5C0tvhiWzvdibFGjrOeAvyPsqFeOvvPN_kLNTH_wDXithb&lang=sage&interacts=eJyLjgUAARUAuQ==)~~!]

```
Q1:
p is the b projected vector on vector a
below all letters are matrices
E=B-P with P=X*A
E=B-X*A as E perpendicular to A => dot product(A,E)) = 0 means A.transpose()*E=0
then A^T*(B-X*A)=0 so A^T*(X*A)=A^T*B (and this is false !)
but Gilbert Strang write X*A^T*A=A^T*B (and this is good !)
but we are not allowed to commute A^T*X*A by X*A^T*A if X is a matrix !
I know I made a mistake in my raisonning but I fail to find it !
Q2 : Why I must write X=A * (A.transpose())/(( (A.transpose()) * A ).det())
instead of X=A * (A.transpose())/(( (A.transpose()) * A ))
why I need to add .det() ?
```