How to define the sequence of sum functions and plot this: $x_n = \sum_{k=1}^{n}\frac{1}{k(k+1)}$, where n - natural numbers. I am beginner in Wolfram Mathematica programming. Thanks for attention.
2 Answers
$\begingroup$
$\endgroup$
x[n_] := Refine[Sum[1/(k*(k + 1)), {k, 1, n}], Element[n, Integers]];
DiscretePlot[x[n], {n, 1, 20}]
Plot[x[n], {n, 1, 20}]
$\begingroup$
$\endgroup$
Clear["Global`*"]
x[n_] := Sum[1/(k*(k + 1)), {k, 1, n}]
Show[
Plot[x[n], {n, 0, 20},
PlotRange -> {0, 1.05}],
DiscretePlot[x[n], {n, 0, 20}]]
By using Set
rather than SetDelayed
the result is defined for smoothly continuous values of n
xc[n_] = Sum[1/(k*(k + 1)), {k, 1, n}]
(* 1 - 1/(1 + n) *)
Show[
Plot[xc[n], {n, 0, 20},
PlotRange -> {0, 1.05}],
DiscretePlot[x[n], {n, 0, 20}]]