For FindFit I want to have a norm that just sums up all residuals.

For the sum of absolute values there is NormFunction -> (Norm[#, 1] &), but I don't know how to sum up residuals as they are. I tried to define my own norm but failed, for instance NormFunction -> (# &) or NormFunction -> (Total[#] &).

MWE:

xdata = {1, 2, 3, 4, 5, 6, 7};
ydata = {1.2, 2.5, 2.3, 4.3, 5.9, 3.2, 4.9};
data = Transpose [{xdata, ydata}];
value = FindFit[data, a + b x , {a, b}, x,
NormFunction -> Total](*(Norm[#,1]&)*)

• This succeeds as I would expect it to: FindFit[data, a x Log[b + c x], {a, b, c}, x, NormFunction -> Total]. Please show what failed and explain why you think it failed. May 14 at 14:47
• I think this is problematic. As residuals have a sign, they can give a small sum for large residuals. Is this what you want? May 14 at 14:52
• The message is not an error. It's just informing you that a better method is available. -- The main problem is that the goal is to minimize the norm. With the norm given by Total, the minimum will be $-\infty$. This modification of your code gives a proper error: FindFit[data, b (x + a), {a, b}, x, NormFunction -> Total]. (Technically, a norm should be positive-definite.) May 14 at 14:59
• This might be what you're after: FindFit[data, b (x + a), {a, b}, x, NormFunction -> Abs@*Total]. The norm is positive but not definite. Consequently, there should be infinitely many solutions for which the sum of the residuals is zero. FindFit returns one of them along with an error. But it does return one solution. And different starting points return others: FindFit[data, b (x + a), {{a, -2}, {b, 3}}, x, NormFunction -> Abs@*Total] May 14 at 15:08
• If you use the linear model and get two values, you can get all of them parametrized by t with value = Thread[{a, b} -> (1 - t) ({a, b} /. value1) + t ({a, b} /. value2)]. (As long as you understand that I don't know why you want solve such a problem, but it seems a well-defined problem, even if not a common fitting problem.) May 14 at 15:14