{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "39a632f2", "metadata": {}, "source": [ "École Polytechnique de Montréal\n", "
\n", "Cours MTH2210A : Calcul scientifique pour ingénieurs\n", "
\n", "Session d'hiver 2023\n", "\n", "

Laboratoire 2

\n", "\n", "| Nom et prénoms | Nom et prénoms |\n", "|-------------------|---------------------|\n", "| Matricule 9999999 | Matricule 0000000 |" ] }, { "cell_type": "markdown", "id": "501b57da", "metadata": {}, "source": [ "# Initialisation du notebook" ] }, { "cell_type": "code", "execution_count": null, "id": "31a1c6b5", "metadata": {}, "outputs": [], "source": [ "# Réinitialisation complète de l'environnement\n", "%reset -f\n", "\n", "# Import des bibliothèques requises\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "421fe283", "metadata": {}, "source": [ "# Exercice 1" ] }, { "cell_type": "code", "execution_count": null, "id": "cacc054b", "metadata": {}, "outputs": [], "source": [ "# a)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "8b5de2ab", "metadata": {}, "outputs": [], "source": [ "# b)\n", "\n" ] }, { "cell_type": "markdown", "id": "99870e71", "metadata": {}, "source": [ "Commentaire éventuel." ] }, { "cell_type": "markdown", "id": "f46e872a", "metadata": {}, "source": [ "# Exercice 2" ] }, { "cell_type": "code", "execution_count": null, "id": "50ee6fff", "metadata": {}, "outputs": [], "source": [ "# a)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "d66c5c0c", "metadata": {}, "outputs": [], "source": [ "# b)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "48d9f8ea", "metadata": {}, "outputs": [], "source": [ "# c)\n", "\n", "# La version Python de l'algorithme de Horner proposé dans le sujet est disponible via la fonction ci-dessous.\n", "# argument d'entrée: n, le degré du polynôme\n", "# argument de sortie: y, la valeur de P_n(alpha^2)\n", "def hhorner(n):\n", " alphacarre = 0.006694380022903415749574948586\n", " a = np.zeros(n+1)\n", " for i in range(len(a)):\n", " a[i] = np.math.factorial(2*i+1)/((2*i+3)*(2*i+5)*np.math.factorial(i)**2*2**(2*i-2))\n", " y = a[-1]\n", " for i in range(len(a)-2,-1,-1):\n", " y = a[i] + alphacarre*y\n", " return y\n", "\n" ] }, { "cell_type": "markdown", "id": "d8425571", "metadata": {}, "source": [ "d) Discussion." ] }, { "cell_type": "markdown", "id": "4ebe28fc", "metadata": {}, "source": [ "# Exercice 3" ] }, { "cell_type": "code", "execution_count": null, "id": "01c7daf3", "metadata": {}, "outputs": [], "source": [ "# a) - code\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "fde1c749", "metadata": {}, "outputs": [], "source": [ "# a) - tableau\n", "\n" ] }, { "cell_type": "markdown", "id": "d73f694a", "metadata": {}, "source": [ "a) - Commentaire." ] }, { "cell_type": "code", "execution_count": null, "id": "f2709962", "metadata": {}, "outputs": [], "source": [ "# b) - code\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "12ca340a", "metadata": {}, "outputs": [], "source": [ "# b) - tableau\n", "\n" ] }, { "cell_type": "markdown", "id": "934af01e", "metadata": {}, "source": [ "b) - Commentaire." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.12" } }, "nbformat": 4, "nbformat_minor": 5 }