Expanded error functions to individual patterns

Error functions now calculate error on a per pattern basis
just like the derivative functions. This makes them
logically easier, but also makes it possible to verify
and test the error on a per pattern basis.

Signed-off-by: Jonas Kalderstam <jonas@kalderstam.se>