# How to determine the function is linear in linear regression problem?

I know that the first degree of the polynomial equation is considered as a linear function.

But, I found some things confusing in linear regression.

1. f(x)= w1 x1+ w2 x2 + W3 x3 --> linear function
2. f(x)= w1 x1+ w2 x2 + W3 x1 x3 --> is it linear? if not, then why?
3. f(x)= w1 x1+ w2 x2 + W3 W4 x3 --> is it linear? if not, then why?
4. f(x)= w1 x1+ w2 x2 + W3 x3 x3 --> it is not linear.


• To reduce any risk of confusion by others, this question and current answers deal with whether the function is linear in variables ($X$'s), not with whether these regression equations are linear in parameters, which all of them are. There is a separate question on what linear in parameters means: datascience.stackexchange.com/q/12274/69527. May 5, 2019 at 23:05

A function $$x = (x_1, \dots, x_n) \mapsto f(x_1, \dots, x_n) \in \mathbb{R}$$ is linear if and only if for every $$a,b \in \mathbb{R}$$ it holds that $$f(a (x_1, \dots, x_n) + b (\xi_1, \dots, \xi_n)) = a f(x_1, \dots, x_n) + b f(\xi_1, \dots,\xi_n)$$.
In your second example try computing $$f(a x + b \xi)$$ to see that the last term $$w_3 x_1 x_3$$ will make $$f(a x + b \xi) \neq a f(x) + b f(\xi)$$.
The third example has a coefficient which is expressed as a product, but the function remains linear (just rename $$w_3 w_4$$ to $$w$$).
Your third example is certainly linear as we can simply imagine $$W3.W4$$ to be some $$W5$$.
Regarding your other 2 examples, you need to clarify what your input is. If your input is $$f(x1, x2, x3)$$ then they are not linear. However, say in the second example if the input to your function is $$f(x1,x2,x1x3)$$ then it is still a linear function!