1 | initial version |

Here is how it works. In fact it is only slightly different from the above, but the two things that helped were `canonicalize_radical()`

and mapping the simplify to the final vector.

```
v1 = var('v1');
v2 = var('v2');
v3 = var('v3');
e1 = vector([1,0,0]);
v = vector([v1, v2, v3]);
T=(v1^2 + v2^2 + v3^2);
u = v/sqrt(T);
z=u.cross_product(e1);
c=u.dot_product(e1);
mat=Matrix( [[0, -z[3-1], z[2-1]], [z[3-1], 0, -z[1-1]], [-z[2-1], z[1-1], 0]] );
mrot=(matrix.identity(3) + mat + (1/(1+c)) * mat*mat);
mrot = mrot*sqrt(T);
mrot = mrot.apply_map(lambda e: e.canonicalize_radical());
view(["mrot*sqrt(T)", mrot])
e = mrot/sqrt(T)*u;
e = e.apply_map(lambda e: e.full_simplify())
e
```

Multiplying `sqrt(T)`

into `mrot`

and taking it out again when multiplying with `u`

is only for better readability.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.