0
$\begingroup$

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.

$\endgroup$

2 Answers 2

2
$\begingroup$
x[n_] := Refine[Sum[1/(k*(k + 1)), {k, 1, n}], Element[n, Integers]]; 


DiscretePlot[x[n], {n, 1, 20}]

enter image description here

Plot[x[n], {n, 1, 20}]

enter image description here

$\endgroup$
1
$\begingroup$
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}]]

enter image description here

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}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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