{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "markdown", "source": [ "# Seccion 1.4" ], "metadata": { "id": "MSBZLjmrtBpb" } }, { "cell_type": "markdown", "source": [ "Utilizando unicamente la librería sympy, definimos las variables *x* y *a*. Luego, construímos la expresión $-2a^2 - 5ax + 12x^2$ de la siguiente manera:" ], "metadata": { "id": "yCDsbwdZW_7z" } }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 38 }, "id": "a7dbd63d", "outputId": "367e80a9-411b-4110-df7c-595eb8e1c7ce" }, "source": [ "import sympy\n", "\n", "x, a = sympy.symbols('x a')\n", "\n", "expresion = 12*x**2 - 5*a*x - 2*a**2\n", "\n", "expresion" ], "execution_count": 2, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "-2*a**2 - 5*a*x + 12*x**2" ], "text/latex": "$\\displaystyle - 2 a^{2} - 5 a x + 12 x^{2}$" }, "metadata": {}, "execution_count": 2 } ] }, { "cell_type": "markdown", "source": [ "Ahora empleamos la función factor de sympy para factorizar la expresión:" ], "metadata": { "id": "LGxTb3ugXlKy" } }, { "cell_type": "code", "source": [ "expresion_factorizada = sympy.factor(expresion)\n", "\n", "expresion_factorizada" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 38 }, "id": "OJBLm3iaWx1y", "outputId": "37e42543-7f37-420a-c10b-9473aa6c6d3f" }, "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(-2*a + 3*x)*(a + 4*x)" ], "text/latex": "$\\displaystyle \\left(- 2 a + 3 x\\right) \\left(a + 4 x\\right)$" }, "metadata": {}, "execution_count": 3 } ] }, { "cell_type": "markdown", "source": [], "metadata": { "id": "2Ix9ZXjntHv5" } } ] }