{ "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.6" ], "metadata": { "id": "amsqHHs0iEoX" } }, { "cell_type": "markdown", "source": [ "La función solveset de sympy recibe como parámetros una inecuación y la variable cuya solución debemos calcular." ], "metadata": { "id": "zTe03F3biR1S" } }, { "cell_type": "code", "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 38 }, "id": "417c34f6", "outputId": "8fa156d5-799f-477e-bcc4-7931ff90b501" }, "source": [ "import sympy\n", "\n", "x = sympy.Symbol('x')\n", "\n", "# Definimos la inecuación\n", "inecuacion = (x - 1) * (2 - 3*x) <= (2*x + 7) * (x - 2) - 4\n", "\n", "# Mostramos la inecuación\n", "inecuacion" ], "execution_count": 1, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "(2 - 3*x)*(x - 1) <= (x - 2)*(2*x + 7) - 4" ], "text/latex": "$\\displaystyle \\left(2 - 3 x\\right) \\left(x - 1\\right) \\leq \\left(x - 2\\right) \\left(2 x + 7\\right) - 4$" }, "metadata": {}, "execution_count": 1 } ] }, { "cell_type": "markdown", "source": [ "En este caso, también se incluye el parámetro del dominio para indicarle a sympy que buscamos soluciones Reales." ], "metadata": { "id": "pvo2fFn1jRw0" } }, { "cell_type": "code", "source": [ "# Resolvemos la inecuación\n", "solucion = sympy.solveset(inecuacion, x, domain=sympy.Reals)\n", "\n", "# Mostramos el conjunto solución\n", "solucion" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 58 }, "id": "ePgIpPNJiink", "outputId": "637d95e7-5bf1-4396-a691-d39baeff6a00" }, "execution_count": 2, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "Union(Interval(-oo, -8/5), Interval(2, oo))" ], "text/latex": "$\\displaystyle \\left(-\\infty, - \\frac{8}{5}\\right] \\cup \\left[2, \\infty\\right)$" }, "metadata": {}, "execution_count": 2 } ] } ] }