Solution 1:

I'll use vector algebra, which is not too different from standard algebra. This is as simple and matrix-free as it can get (using the definition $y=mx + a$ is just ugly in my opinion). The derivation also requires basic calculus. Let $L$ be a line, and $\mathbf{q} = (q_1, q_2)$ be a point. The line can be described using the parametric equation $$ L(t) = \mathbf{v}t + \mathbf{a} = (v_1t + a_1, v_2t + a_2), $$ where $\mathbf{v}=(v_1, v_2)$ is a direction vector, and $\mathbf{a}=(a_1, a_2)$ is a point on $L$.

Then the reflection $\mathbf{q}^*$ of $\mathbf{q}$ over $L$ is simply $$ \mathbf{q}^*= 2(\mathbf{v}t^* + \mathbf{a}) - \mathbf{q} = (2(v_1t^* + a_1) - q_1, 2(v_2t^* + a_2) - q_2),\label{eq:1}\tag{1} $$ where $$t^* = \frac{q_1v_1 + q_2v_2 - a_1v_1 - a_2v_2}{v_1^2 + v_2^2}.$$

Now plug $a_1=l_{x1},a_2 = l_{x2},v_1 = l_{x2}-l_{x1}$, $v_2 = l_{y2}-l_{y1}$, and the rest is just algebra. The parametric equation of the line is particularly convenient, because it allows us to define a line from two points on the line.

Derivation: Let $\mathbf{u}=(u_1, u_2)$ be a point on $L$ that minimizes the distance between $\mathbf{q}$ and $L$, i.e. we want to find a $\mathbf{u} = L(t^*)$ that minimizes $$ f(t) = \frac{1}{2}\lVert L(t) - \mathbf{q}\rVert^2 = \frac{1}{2}\left\{(v_1t + a_1 - q_1)^2 + (v_2t + a_2 - q_2)^2\right\}. $$ Then the reflection $\mathbf{q}^*$ is simply $\mathbf{q}^* = \mathbf{q} + 2(\mathbf{u} - \mathbf{q}) = 2\mathbf{u} - \mathbf{q} = (2u_1 - q_1, 2u_2 - q_2)$, see figure below (blue arrow is $2(\mathbf{u} - \mathbf{q})$)Reflection of a point <span class=$\mathbf{q} across a line $L$" />

Now, using calculus, we know that $f'(t^*) = 0$, so $$f'(t^*) = (v_1t^* + a_1 - q_1)v_1 + (v_2t^* + a_2 - q_2)v_2 = 0,$$ or $$ t^* = \frac{(a_1 - q_1)v_1 + (a_2 - q_2)v_2}{v_1^2 + v_2^2}. $$ Finally, $\mathbf{u} = \mathbf{v}t^* + \mathbf{a} = (v_1t^* + a_1, v_2t^* + a_2)$, leading to \ref{eq:1} after putting everything together.

Note that $\mathbf{u} - \mathbf{q}$ is orthogonal to $\mathbf{v}$, i.e. $$ (\mathbf{u} - \mathbf{q})\cdot \mathbf{v} = (u_1 - q_1)v_1 + (u_2 - q_2)v_2 = (v_1t^* + a_1 - q_1)v_1 + (v_2t^* + a_2 - q_2)v_2 = f'(t^*) = 0. $$