It is just a linear function with parameters $\beta_1 = 1$ and $\beta_2 = -1$ $$ \beta_1 x_1 + \beta_2 x_2 = 1 \times x_1 + (-1) \times x_2 = x_1 - x_2 $$ Neural networks use such linear functions commonly. If you have a simple multilayer feed-forward network, just one of the layers would need to learn the parameters above to calculate the new feature to be used by the next layer. That said, [there are cases][1] where engineering the features by hand makes life easier for the algorithm so it does not need to figure them out. [1]: https://stats.stackexchange.com/questions/350220/utility-of-feature-engineering-why-create-new-features-based-on-existing-featu/350238#350238