<s>[INST] Find any affine transformation that swaps affine lines The task is to find any affine transformation that will swap the following two lines:
$$L_1:(1,1,1) + span((1,0,2))$$
$$L_2:(1,0,1) + span((1,0,-1))$$
From what I understand there is a number of equations I can make:
$$f((1,1,1))=(1,0,1)$$
$$f((1,0,1))=(1,1,1)$$
I am not sure how to create the other two equations that I need.
I also understand that an affine transformation consists of a linear transformation and a translation.
Does this translation have to be $(1,1,1) - (1,0,1)$ or what else could it be.
I'm really confused by the affine transformations.
 [/INST] \begin{pmatrix} 2\\ 0\\ 0 \end{pmatrix} 
   \rightarrow 
   \begin{pmatrix} 2\\ 1\\ 3 \end{pmatrix}.
$$
I will use general approach from "Beginner's guide to mapping simplexes affinely" and "Workbook on mapping simplexes affinely" to solve the latter problem. It is shown there, the transformation can be presented as
$$
\vec{A}(\vec{x}) =
(-1)
\frac{
    \det
    \begin{pmatrix}
        0 & (1,0,1)^T & (2,0,0)^T & (1,1,1)^T & (2,1,3)^T \\
        \begin{matrix}
            x_{1} \vphantom{x_{1}^{(1)}} \\
            x_{2} \vphantom{x_{1}^{(1)}} \\
            x_{3} \vphantom{x_{1}^{(1)}} \\
        \end{matrix} &
%
        \begin{matrix}
            1  \\
            1  \\
            1  \\
        \end{matrix} &
%
        \begin{matrix}
            2  \\
            1  \\
            3  \\
        \end{matrix} &
%
        \begin{matrix}
            1  \\
            0  \\
            1  \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            0 \\
            0 \\
        \end{matrix} \\
%
        1 & 1 & 1 & 1 & 1
    \end{pmatrix}
}{
    \det
    \begin{pmatrix}
        \begin{matrix}
            1 \\
            1 \\
            1 \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            1 \\
            3 \\
        \end{matrix} &
%
        \begin{matrix}
            1 \\
            0 \\
            1 \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            0 \\
            0 \\
        \end{matrix} \\
%
        1 & 1 & 1 & 1
    \end{pmatrix}
}.
$$
Doing determinants I get
$$
= \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix}
  \frac{2 - x_1 +  3 x_2 - x_3}{3} +
  \begin{pmatrix} 2 \\ 0 \\ 0 \end{pmatrix}
  \frac{x_1 + x_3 - 2}{3} +
  \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix}
  \frac{4 - 2 x_1 - 3 x_2 + x_3}{3} +
  \begin{pmatrix} 2 \\ 1 \\ 3 \end{pmatrix}
  \frac{2 x_1 - x_3 - 1}{3}
$$
or simplified
$$
\vec{A}(\vec{x}) =
    \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix} x_1 + 
    \begin{pmatrix} 0 \\ -1 \\ 0 \end{pmatrix} x_2 + 
    \begin{pmatrix} 0 \\ 0 \\ -1 \end{pmatrix} x_3 +
    \begin{pmatrix} 0 \\ 1 \\ 1 \end{pmatrix}
$$
or in canonical form
$$
\vec{A}(\vec{x}) =
    \begin{pmatrix} 1 & 0 & 0 \\ 
                    0 & -1 & 0 \\
                    1 & 0 & -1 \end{pmatrix} 
    \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} +
\begin{pmatrix} 0 \\ 1 \\ 1 \end{pmatrix}.
$$
For more details on the methods used, you can always refer to "Beginner's guide to mapping simplexes affinely" and "Workbook on mapping simplexes affinely". The latter contains many problems similar to this one as explained by the authors of the method presented.
</s>