{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# Sección 1.5" ], "metadata": { "id": "U4P_5ZWouagv" } }, { "cell_type": "markdown", "source": [ "La función div de sympy puede recibir dos polinomios, como parámetros, y almacenarlos en dos variables. La primera será el cociente, y la segunda será el residuo." ], "metadata": { "id": "vhAqXheGfBgT" } }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 38 }, "id": "76adfd1d", "outputId": "92348cd6-8417-4fd2-d7e2-c289e29bfe9d" }, "source": [ "import sympy as sym\n", "x = sym.symbols('x')\n", "\n", "# Definir los polinomios\n", "p1 = x**3 - 7*x**2 + 3*x + 9\n", "p2 = x - 2\n", "\n", "# Realizar la división\n", "cociente, residuo = sym.div(p1, p2)\n", "\n", "# Imprimir el cociente\n", "cociente" ], "execution_count": 1, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "x**2 - 5*x - 7" ], "text/latex": "$\\displaystyle x^{2} - 5 x - 7$" }, "metadata": {}, "execution_count": 1 } ] }, { "cell_type": "code", "source": [ "# Imprimir y el residuo\n", "residuo" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 37 }, "id": "a0xV1O0ZfYhe", "outputId": "17834d4a-e022-4f7c-e75d-0b886c20465f" }, "execution_count": 2, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "-5" ], "text/latex": "$\\displaystyle -5$" }, "metadata": {}, "execution_count": 2 } ] } ] }