# Summing functions in a Do loop [closed]

I can print these functions like this:

n = 3;
Do[
Print[D[Total[
Table[ToExpression[
ToString["a"] <>
ToString[i]]/(ToExpression[ToString["b"] <> ToString[i]] +
ToExpression[ToString["c"] <> ToString[i]]*
Exp[-ToExpression[ToString["d"] <> ToString[i]]*
ToExpression[ToString["x"] <> ToString[i]]]), {i, n}]],
ToExpression[ToString["x"] <> ToString[j]]]], {j, 1, n}]


But I can't figure out how to add all of them together and make it a single function (Which I want to use for a Nonlinear fit). Can anyone help me in the right direction?

• Have you looked at Sum or Table? Aug 16, 2021 at 14:21
• @Szabolcs Yes, as you can see I've used Table in my code. But Since I'm differentiating these functions, I have no idea how to put all of them in a table or add them together Aug 16, 2021 at 14:29
• Table[(a[i] c[i] d[i] E^(-d[i] x[i]))/(b[i] + c[i] E^(-d[i] x[i]))^2, {i, 1, 3}] Aug 16, 2021 at 14:43
• It makes no sense whatsoever to be "summing" strings as you do. Aug 16, 2021 at 18:47

## 1 Answer

Try this:

 expr= Table[D[Total[Table[a[i]/(b[i] + c[i]*Exp[-d[i] + x[i]]), {i, 1, 3}]],
x[j]], {j, 1, 3}]

(*  {-((E^(-d[1] + x[1]) a[1] c[1])/(b[1] + E^(-d[1] + x[1]) c[1])^2), -((
E^(-d[2] + x[2]) a[2] c[2])/(b[2] + E^(-d[2] + x[2]) c[2])^2), -((
E^(-d[3] + x[3]) a[3] c[3])/(b[3] + E^(-d[3] + x[3]) c[3])^2)}  *)


To better see it I show the result also as an image:

Then you can address to any of the results separately. For example, this

expr[[1]]

(*  -((E^(-d[1] + x[1]) a[1] c[1])/(b[1] + E^(-d[1] + x[1]) c[1])^2) *)


returns the first element of the resulting list.

Have fun!