diff --git a/reihen/serie_4_3.py b/reihen/serie_4_3.py new file mode 100644 index 0000000..a1921bf --- /dev/null +++ b/reihen/serie_4_3.py @@ -0,0 +1,28 @@ +# %% +import sympy as sp +from IPython.display import display, Math + +# Define the symbolic variable +k = sp.symbols("k") + +# List of operations: each entry is [expression, (variable, lower_bound, upper_bound)] +operations = [ + [k, (k, 4, 10)], + [2 * k, (k, 4, 10)], + [k**3, (k, -2, 2)], + [1 / k, (k, 2, 4)], + [2**k, (k, 0, 4)], + [(-1) ** k, (k, 4, 9)], +] + +for operation in operations: + # Build the symbolic Sum object (Σ notation) + # *operation unpacks the list into separate arguments: expression, bounds + summenzeichen = sp.Sum(*operation) + + # Compute the actual numeric result of the summation + summe = sp.summation(*operation) + + # Convert both to LaTeX strings, join them with "=", + # wrap in Math() for rendering, and display in the interactive window + display(Math(r"{} = {}".format(sp.latex(summenzeichen), sp.latex(summe))))