I would like to do something very simple, i.e. replace the coefficients in a sum by a function:

c[1] + c[2] + c[3] /. {c[s] -> (s + 1)/(2 (2 s + 1))}

Unfortunately, this does not work. Any suggestion for something handy that would do the job?


I think you need to use RuleDelayed like this:

c[1] + c[2] + c[3] /. {c[s_] :> (s + 1)/(2 (2 s + 1))}
(* 193/210 *)

This replaces every coefficient with a formula and evaluates for the integer values.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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