$\vec{v_1}$

$\vec{v_2$

$\vec{a}$

$\vec{v_2}$

\vec{v_1}

\vec{v_2}

\vec{a}

A = (-4, 2)
B = (-2, 4)
u = Vector(A, B)
C = (-4, -1)
D = (-2, -2)
v = Vector(C, D)
P = (1, 4)
M: {{x(u), x(v)}, {y(u), y(v)}}
M1 = Invert(M)
w = Vector(P)
sol: (M1 * w)
solu: x(sol)
solv: y(sol)
L_u = Sequence(Vector[(0, 0), (0, 0) + (i * u)], i, 0, (sgn(solu) * floor(abs(solu))), sgn(solu))
L_v = Sequence(Vector[(0, 0) + (solu * u), (0, 0) + (solu * u) + (i * v)], i, 0, (sgn(solv) * floor(abs(solv))), sgn(solv))
a = Vector((0, 0) + ((sgn(solu) * floor(abs(solu))) * u), (0, 0) + (solu * u))
b = Vector((0, 0) + ((sgn(solv) * floor(abs(solv))) * v) + (solu * u), (0, 0) + (solu * u) + (solv * v))
text1: "\vec{v_1} = " + (LaTeX[u]) + ""
text2: "\vec{v_2} = " + (LaTeX[v]) + ""
L = Sequence(Line[(0, 0) + (i * u), v], i, -14, 14)
L1 = Sequence(Line[(0, 0) + (i * v), u], i, -14, 14)
solvtext = If(Defined[solv], If[solv < 0, "(" + solv + ")", Text[solv]], "?")
text3: "\textcolor{#339900}{\vec{a} =} " + (LaTeX[solu]) + " \cdot \textcolor{#0000ff}{" + (LaTeX[u]) + "} +" + (LaTeX[solvtext]) + " \cdot \textcolor{#ff0000}{" + (LaTeX[v]) + "} \textcolor{#339900}{= " + (LaTeX[w]) + "}"