I'm having a problem concerning function addition. The following code shows an example that illustrates my problem. I had this list of functions that have the same variable. I had them by using the Total function and declared a function of that variable equal to the Total[list], like in this example:
f1[x_] := 2 x + 1;
f2[x_] := x;
f3[x_] = 4 x;
l1 = List[f1[x], f2[x], f3[x]];
o[x_] := Total[l1];
o[1]
The output of o[1] was 1+7x, instead of 8, which is what I want. Any suggestion on how to approach this problem?
Thank you
f1[x_] := 2 x + 1; f2[x_] := x; f3[x_] = 4 x; l1[x_] := List[f1[x], f2[x], f3[x]]; o[x_] := Total[l1[x]]; o[1]– Nasser Oct 07 '17 at 19:32x_parameter is scoped differently from thexsymbol you provide inl1. So you could also mostly keep your code but replaceowith this:o[v_] := Total[l1] /. x -> v– b3m2a1 Oct 07 '17 at 19:33Evaluatein definition ofo[x_], i.e.,o[x_] := Evaluate@Total[l1];– Bob Hanlon Oct 07 '17 at 20:03SetDelayedandEvaluate! – Roman Dec 22 '22 at 09:04