LUNAR
🌙
Dashboard
Browse
exams
ipynb
See Source
{ "cells": [ { "cell_type": "code", "execution_count": 66, "id": "d8c8ef33", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import scipy" ] }, { "cell_type": "markdown", "id": "3137aeb7", "metadata": {}, "source": [ "# FS 2022\n", "## Question 7" ] }, { "cell_type": "code", "execution_count": 67, "id": "f0b841ae", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ln(2): 0.6931471805599453\n", "Series: 0.6687714031754279\n", "Deviation: 0.9648331868495434 %\n" ] } ], "source": [ "print(f\"ln(2): {np.log(2)}\")\n", "\n", "partial_sum = 0\n", "for k in range(1,21):\n", " partial_sum += ((-1)**(k-1))/k\n", "print(\"Series:\", partial_sum)\n", "\n", "percentace_deviation = partial_sum/np.log(2)\n", "print(\"Deviation:\", percentace_deviation, \"%\")" ] }, { "cell_type": "markdown", "id": "1beeed61", "metadata": {}, "source": [ "# HS 2022\n", "## Question 7" ] }, { "cell_type": "code", "execution_count": 68, "id": "86544cd8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.9156536770949605\n" ] } ], "source": [ "partial_sum = 0\n", "for n in range(0,20):\n", " partial_sum += ((-1)**n)/((2*n + 1)**2)\n", "\n", "print(partial_sum)" ] }, { "cell_type": "markdown", "id": "349c0f46", "metadata": {}, "source": [ "# HS 2023\n", "## Question 7" ] }, { "cell_type": "code", "execution_count": 73, "id": "b6c39bf4", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[30, 23, 16, 9, 2, -5, -12, -19, -26, -33, -40, -47, -54, -61, -68, -75, -82, -89, -96, -103, -110, -117, -124, -131, -138, -145, -152, -159, -166, -173, -180, -187, -194, -201, -208, -215, -222, -229, -236, -243, -250, -257, -264, -271, -278, -285, -292, -299, -306, -313, -320, -327, -334, -341, -348, -355, -362, -369, -376, -383, -390, -397, -404, -411, -418, -425, -432, -439, -446, -453, -460, -467, -474, -481, -488, -495, -502, -509, -516, -523, -530, -537, -544, -551, -558, -565, -572, -579, -586, -593, -600, -607, -614, -621, -628, -635, -642, -649, -656, -663, -670, -677, -684, -691, -698, -705]\n" ] } ], "source": [ "list1 = list(range(30,-706,-7))\n", "print(list1)" ] }, { "cell_type": "code", "execution_count": 80, "id": "d766ee70", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[3.0, -1.5, 0.75, -0.375, 0.1875, -0.09375, 0.046875, -0.0234375, 0.01171875, -0.005859375, 0.0029296875, -0.00146484375, 0.000732421875, -0.0003662109375, 0.00018310546875, -9.1552734375e-05, 4.57763671875e-05, -2.288818359375e-05, 1.1444091796875e-05, -5.7220458984375e-06]\n" ] } ], "source": [ "list2 = []\n", "for i in range(20):\n", " sequence = (-1)**i * 3/(2**i)\n", " list2.append(sequence)\n", " \n", "print(list2)" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.4" } }, "nbformat": 4, "nbformat_minor": 5 }