-1
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ Have you looked at Sum or Table? $\endgroup$
    – Szabolcs
    Aug 16, 2021 at 14:21
  • $\begingroup$ @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 $\endgroup$ Aug 16, 2021 at 14:29
  • $\begingroup$ 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}] $\endgroup$
    – cvgmt
    Aug 16, 2021 at 14:43
  • $\begingroup$ It makes no sense whatsoever to be "summing" strings as you do. $\endgroup$ Aug 16, 2021 at 18:47

1 Answer 1

1
$\begingroup$

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:

enter image description here

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!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.