Now that we’re familiar with linear functions and linear combinations, let’s dive into the process of using these concepts to define real-life systems as mathematical systems.

Linear modeling

We often come across data consisting of several attributes of interest to us. For example, the records of COVID-19 patients contain many attributes worth recording, including confirmation data, fever level, blood cell counts, medicine in use, and so on. One important attribute is the survival rate, which may depend on the other attributes. If we think that there are dd attributes in numeric form that are represented as vectors or arrays, then a typical ithi^{th} record looks like the following: xi=[x1ix2ix3ixdi]\bold{x_i} = \begin{bmatrix} x_{1i}\\x_{2i}\\x_{3i} \\ \vdots \\x_{di}\end{bmatrix}. The corresponding attribute, survival, can be denoted with yiy_i having either the values, 00 or 11 , corresponding to “did not survive” and “survived,” respectively. If there’s a linear relationship between xi\bold{x_i} and yiy_i, then there exists a linear function ff with parameters w=[w1w2w3wd]\bold{w} = \begin{bmatrix} w_1\\w_2\\w_3 \\ \vdots \\w_d\end{bmatrix} that maps xi\bold{x_i} to yiy_i : fw(xi)=yi,if_\bold{w}(\bold{x_i})=y_i, \forall i. Although we don’t know if the linear relationship holds, we know that if it does, then: fw(xi)=w1x1i+w2x2i+...+wdxdi=yi,if_\bold{w}(\bold{x_i})=w_1x_{1i}+w_2x_{2i}+...+w_dx_{di} = y_i, \forall i.

Linear equation

An equation of the form w1x1i+w2x2i+...+wdxdi=yiw_1x_{1i}+w_2x_{2i}+...+w_dx_{di} = y_i is called linear in w\bold{w} if xi\bold{x_i} and yiy_i are given. For example, with d=4d=4, if we think of the ithi^{th} record to be represented as xi=[2.34.29.676.2]\bold{x_i} = \begin{bmatrix} -2.3\\-4.2\\9.6 \\76.2\end{bmatrix}, and we assume that the patient survived, say, yi=1y_i=1, then the above equation becomes 2.3w14.2w2+9.6w3+76.2w4=1-2.3w_1-4.2w_2+9.6w_3+76.2w_4 = 1

Example 1: One linear equation

For what values of w1w_1 and w2w_2, 2w14w2=92w_1-4w_2=9?

Solution: There are several solutions to this problem. For example, if we set w2=0w_2=0, then w1=92w_1=\frac{9}{2}. Also, if we set w2=2w_2=-2, then w1=12w_1=\frac{1}{2}. So, (92,0)(\frac{9}{2},0) and (12,2)(\frac{1}{2},-2) are two solutions. In general, if we set w2=αw_2=\alpha, then w1=9+4α2w_1=\frac{9+4\alpha}{2}. So, for every choice of α\alpha, we have a solution (9+4α2,α)(\frac{9+4\alpha}{2},\alpha).

The following code prints k solutions to every equation in variables w1 and w2, provided that x1 isn’t zero.

Get hands-on with 1200+ tech skills courses.