I am trying to write a set of homework questions.
I would like the output to evaluate the constants but not the sum, so that I may present the homework question as something like this:
$$\sum_{n=1}^{340}(-4n^2-n+3)$$
Here's what I have:
c1 = RandomInteger[{-5, 5}];
c2 = RandomInteger[{-5, 5}];
c3 = RandomInteger[{-5, 5}];
c4 = RandomInteger[{1, 50}]*20
f[x_] := c1*x^2 + c2*x + c3
f[n]
(* 340
3 - n - 4 n^2 *)
Defer[Sum[f[n], {n, 1, c4}]]
$\sum _{n=1}^{\text{c4}} f(n)$
It seems like I am not using Defer
correctly. How can I fix this?