diff --git a/.ipynb_checkpoints/examples-checkpoint.ipynb b/.ipynb_checkpoints/examples-checkpoint.ipynb index b8a7d20..4e27353 100644 --- a/.ipynb_checkpoints/examples-checkpoint.ipynb +++ b/.ipynb_checkpoints/examples-checkpoint.ipynb @@ -4,7 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In this notebook there are presented examples of usage of shiroin, a python library for proving inequalities of multivariate polynomials." + "In this notebook there are presented examples of usage of shiroin, a python library for proving inequalities of multivariate polynomials.\n", + "\n", + "At the beginning we need to load the packages." ] }, { @@ -13,17 +15,20 @@ "metadata": {}, "outputs": [], "source": [ + "from sympy import *\n", "from shiroindev import *\n", - "sVars.seed=1\n", "from IPython.display import Latex\n", - "sVars.display=lambda x:display(Latex(x))" + "shiro.seed=1\n", + "shiro.display=lambda x:display(Latex(x))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The first line obviously loads this package. The second one sets a seed for proving functions. If you don't write it, you can get a slightly different proof each time you run a function. The next two lines provide a nicer display of proofs, i.e. formulas will be shown instead of LaTeX code of these formulas. Note that this works on Jupyter, but not on the git page.\n", + "`shiro.seed=1` sets a seed for proving functions. If you don't write it, you can get a slightly different proof each time you run a function. This line is here only for the sake of reproducibility. \n", + "\n", + "The next line provides a nicer display of proofs, i.e. formulas will be shown instead of LaTeX code of these formulas. Note that this works on Jupyter, but not on the git page.\n", "\n", "Now let's make some proofs. We will use problems from https://www.imomath.com/index.php?options=593&lmm=0." ] @@ -51,7 +56,7 @@ { "data": { "text/latex": [ - "numerator: $a^2-ab-ac+b^2-bc+c^2$" + "numerator: $a^{2} - a b - a c + b^{2} - b c + c^{2}$" ], "text/plain": [ "" @@ -111,7 +116,7 @@ { "data": { "text/latex": [ - "$$ ab+ac+bc \\le a^2+b^2+c^2 $$" + "$$ a b+a c+b c \\le a^{2}+b^{2}+c^{2} $$" ], "text/plain": [ "" @@ -139,7 +144,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Function prove prints several things. The first two gives us a formula after expanding it. To proceed, a **numerator** has to be a **polynomial with integer coefficients**. The next one is status, which is the return status of the first use of ```scipy.optimize.linprog```. Possible outputs and explanations are\n", + "Function prove prints several things. The first two gives us a formula after expanding it. The next one is status, which is the return status of the first use of ```scipy.optimize.linprog```. Possible outputs and explanations are\n", "\n", "* 0 - found a proof with real coefficients,\n", "* 1 - need more time, \n", @@ -157,7 +162,7 @@ { "data": { "text/latex": [ - "numerator: $2a^2-2ab-2ac+2b^2-2bc+2c^2$" + "numerator: $2 a^{2} - 2 a b - 2 a c + 2 b^{2} - 2 b c + 2 c^{2}$" ], "text/plain": [ "" @@ -205,7 +210,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 a b \\le a^{2}+b^{2}$$" ], "text/plain": [ "" @@ -217,7 +222,7 @@ { "data": { "text/latex": [ - "$$2ac \\le a^2+c^2$$" + "$$2 a c \\le a^{2}+c^{2}$$" ], "text/plain": [ "" @@ -229,7 +234,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 b c \\le b^{2}+c^{2}$$" ], "text/plain": [ "" @@ -300,7 +305,7 @@ { "data": { "text/latex": [ - "numerator: $a^2-ab-ac-ad+b^2+c^2+d^2$" + "numerator: $a^{2} - a b - a c - a d + b^{2} + c^{2} + d^{2}$" ], "text/plain": [ "" @@ -348,7 +353,7 @@ { "data": { "text/latex": [ - "$$ ab+ac+ad \\le a^2+b^2+c^2+d^2 $$" + "$$ a b+a c+a d \\le a^{2}+b^{2}+c^{2}+d^{2} $$" ], "text/plain": [ "" @@ -379,9 +384,10 @@ "This time `prove` didn't found the proof. But it doesn't mean that the inequality is not true! `prove` uses a list of $n$ positive values, where $n$ is a number of variables in the formula. List of values should correspond to the list of variables in alphabetical order. Here are a few tips how to choose the right values.\n", "\n", "1. Consider a function $pos(values)$ which is the sum of the positive addends in the formula after substitution of values to variables. Analogically, let $neg(values)$ be the sum of the negative addends. We should choose such values for which $quotient=pos(values)/|neg(values)|$ is small. \n", - "2. If the symmetry group of the formula is transitive (for example, the formula is cyclic or symmetric)\n", + "2. The symmetry group of the formula splits set of variables into orbits. Using the same values for variables in one orbit is recommended. In particular, if the symmetry group of the formula is transitive (for example, when the formula is cyclic), then all values (probably) should be the same.\n", + "3. If the formula is homogeneous, then $values=(a_1,a_2,...,a_n)$ provide a proof iff $values=(ka_1,ka_2,...,ka_n)$ provides a proof for any $k\\in Q_+$ (as long as you don't run into overflow error).\n", "\n", - "So let's try $a=2$ and $b=c=d=1$." + "In the formula above $b,c,d$ are in one orbit and the formula is homogenous, so let's try $a=2$ and $b=c=d=1$." ] }, { @@ -392,7 +398,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 2a$" + "Substitute $a\\to 2 e$" ], "text/plain": [ "" @@ -404,7 +410,7 @@ { "data": { "text/latex": [ - "numerator: $4a^2-2ab-2ac-2ad+b^2+c^2+d^2$" + "numerator: $b^{2} - 2 b e + c^{2} - 2 c e + d^{2} - 2 d e + 4 e^{2}$" ], "text/plain": [ "" @@ -452,7 +458,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 b e \\le b^{2}+e^{2}$$" ], "text/plain": [ "" @@ -464,7 +470,7 @@ { "data": { "text/latex": [ - "$$2ac \\le a^2+c^2$$" + "$$2 c e \\le c^{2}+e^{2}$$" ], "text/plain": [ "" @@ -476,7 +482,7 @@ { "data": { "text/latex": [ - "$$2ad \\le a^2+d^2$$" + "$$2 d e \\le d^{2}+e^{2}$$" ], "text/plain": [ "" @@ -488,7 +494,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le a^2 $$" + "$$ 0 \\le e^{2} $$" ], "text/plain": [ "" @@ -528,7 +534,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Function makes a substitution $a\\to 2a$ (which should be understood as $a=2a'$) and try to prove new inequality. This time it succeeded. Moreover, if starting formula is equal to 0, then all these inequalities have to be equalities, so $a'^2=0$ and eventually $a=0$. We can also try a little bit lower value for $a$." + "Function makes a substitution $a\\to 2e$ and try to prove new inequality. This time it succeeded. Moreover, if starting formula is equal to 0, then all these inequalities have to be equalities, so $e^2=0$ and eventually $a=0$. We can also try a little bit lower value for $a$." ] }, { @@ -539,7 +545,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 7a/4$" + "Substitute $a\\to \\frac{7 f}{4}$" ], "text/plain": [ "" @@ -551,7 +557,7 @@ { "data": { "text/latex": [ - "numerator: $49a^2-28ab-28ac-28ad+16b^2+16c^2+16d^2$" + "numerator: $16 b^{2} - 28 b f + 16 c^{2} - 28 c f + 16 d^{2} - 28 d f + 49 f^{2}$" ], "text/plain": [ "" @@ -599,7 +605,7 @@ { "data": { "text/latex": [ - "$$28ab \\le 14a^2+14b^2$$" + "$$28 b f \\le 14 b^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -611,7 +617,7 @@ { "data": { "text/latex": [ - "$$28ac \\le 14a^2+14c^2$$" + "$$28 c f \\le 14 c^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -623,7 +629,7 @@ { "data": { "text/latex": [ - "$$28ad \\le 14a^2+14d^2$$" + "$$28 d f \\le 14 d^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -635,7 +641,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 7a^2+2b^2+2c^2+2d^2 $$" + "$$ 0 \\le 2 b^{2}+2 c^{2}+2 d^{2}+7 f^{2} $$" ], "text/plain": [ "" @@ -675,24 +681,88 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now we can see that if $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $7a'^2+2b^2+2c^2+2d^2=0$ and eventually $a=b=c=d=0$. Note that inequality is proved only for positive numbers (which, by continuity, can be expanded to nonnegative numbers). But using similar argumentation to the one in previous problem, if $(a,b,c,d)=(x,y,z,t)$ is the solution of $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $(a,b,c,d)=(|x|,|y|,|z|,|t|)$ is a solution, too. Since the only nonnegative solution is $(0,0,0,0)$, it means that it is the only solution.\n", + "Now we can see that if $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $7f^2+2b^2+2c^2+2d^2=0$ and eventually $a=b=c=d=0$. Note that inequality is proved only for positive numbers (which, by continuity, can be expanded to nonnegative numbers). But using similar argumentation to the one in previous problem, if $(a,b,c,d)=(x,y,z,t)$ is the solution of $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $(a,b,c,d)=(|x|,|y|,|z|,|t|)$ is a solution, too. Since the only nonnegative solution is $(0,0,0,0)$, it means that it is the only solution.\n", "\n", - "Let's skip the problem 3 and look solve the problem 4 instead.\n", + "It is worth noting that this time function `prove` used $f$ as a new variable instead of $e$. If you want to start a new proof and you don't care about the collision of variables from previous proofs, you can use `newproof` function, which clears the set of used variables.\n", "\n", - "#### Problem 4\n", - "If $x$ and $y$ are two positive numbers less than 1, prove that\n", - "$$\\frac{1}{1-x^2}+\\frac{1}{1-y^2}\\ge \\frac{2}{1-xy}.$$" + "We can also use the `findvalues` function to find values for the proof more automatically. It looks for (local) minimum of the $quotient$ value defined above." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.154701\n", + " Iterations: 68\n", + " Function evaluations: 127\n" + ] + }, + { + "data": { + "text/plain": [ + "(1.4339109663193974,\n", + " 0.8278441585048405,\n", + " 0.8279027492686561,\n", + " 0.8278930696996669)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula=S('a^2+b^2+c^2+d^2-a*(b+c+d)')\n", + "numvalues=findvalues(formula)\n", + "numvalues" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If the $quotient$ value were less than 1, that would mean that the formula is negative for given values. If $quotient$ were equal to 1, then we have to choose exactly these values (or other values for which the $quotient$ is equal to 1. But here $quotient$ is greater than 1, so we can take a point near it and (probably) still have a proof. The values given to the `prove` function must not be floating point numbers, so we can rationalize them." + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $-x^3y+2x^2y^2-x^2-xy^3+2xy-y^2$" + "$\\displaystyle \\left( \\frac{10}{7}, \\ \\frac{5}{6}, \\ \\frac{5}{6}, \\ \\frac{5}{6}\\right)$" + ], + "text/plain": [ + "(10/7, 5/6, 5/6, 5/6)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "values=nsimplify(numvalues,tolerance=0.1,rational=True)\n", + "values" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $a\\to \\frac{10 e}{7}$" ], "text/plain": [ "" @@ -704,7 +774,197 @@ { "data": { "text/latex": [ - "denominator: $x^3y^3-x^3y-x^2y^2+x^2-xy^3+xy+y^2-1$" + "Substitute $b\\to \\frac{5 f}{6}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $c\\to \\frac{5 g}{6}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $d\\to \\frac{5 h}{6}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $3600 e^{2} - 2100 e f - 2100 e g - 2100 e h + 1225 f^{2} + 1225 g^{2} + 1225 h^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1764$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2100 e f \\le 1050 e^{2}+1050 f^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2100 e g \\le 1050 e^{2}+1050 g^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2100 e h \\le 1050 e^{2}+1050 h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 450 e^{2}+175 f^{2}+175 g^{2}+175 h^{2} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "newproof()\n", + "prove(formula,values)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you set the tolerance bigger, then the values will have smaller numerators and denominators, so coefficients in the proof will be smaller, too. But if the tolerance is too big, then proof will not be found.\n", + "\n", + "Let's skip the problem 3 and look solve the problem 4 instead.\n", + "\n", + "#### Problem 4\n", + "If $x$ and $y$ are two positive numbers less than 1, prove that\n", + "$$\\frac{1}{1-x^2}+\\frac{1}{1-y^2}\\ge \\frac{2}{1-xy}.$$" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "numerator: $- x^{3} y + 2 x^{2} y^{2} - x^{2} - x y^{3} + 2 x y - y^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $x^{3} y^{3} - x^{3} y - x^{2} y^{2} + x^{2} - x y^{3} + x y + y^{2} - 1$" ], "text/plain": [ "" @@ -740,7 +1000,7 @@ { "data": { "text/latex": [ - "$$ x^3y+x^2+xy^3+y^2 \\le 2x^2y^2+2xy $$" + "$$ x^{3} y+x^{2}+x y^{3}+y^{2} \\le 2 x^{2} y^{2}+2 x y $$" ], "text/plain": [ "" @@ -779,7 +1039,7 @@ "2" ] }, - "execution_count": 7, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -794,19 +1054,19 @@ "source": [ "`prove` assumes that formula is well-defined if all variables are positive, so it doesn't have to analyze the denominator (except of choosing the right sign). In this case it is not true, since if $x=1$, then $1-x^2=0$. Also denominator is equal to $(x^2-1)(y^2-1)(xy-1)$ which is negative for $x,y\\in (0,1)$. So we need to make some substitution after which new variables can have all positive values, not just these inside (0,1) interval.\n", "\n", - "We will use a function `makesubs` to generate these substitutions. It has three basic parameters: `formula`, `intervals` and `values`. `intervals` are current limitations of variables, `values` are values of variables for which `formula` is small. `values` should be inside corresponding `intervals`. This argument is optional but it's better to use it.\n", + "We will use a function `makesubs` to generate these substitutions. It has three basic parameters: `formula`, `intervals` and `values`. `intervals` are current limitations of variables, `values` are values of variables for which $quotient$ of `formula` is small. `values` should be inside corresponding `intervals`. This argument is optional but it's better to use it.\n", "Let's go back to our problem. If $x=y$, then $\\frac{1}{1-x^2}+\\frac{1}{1-y^2}\\ge \\frac{2}{1-xy}$, so it's the minimum value of the formula. So let `values=(1/2,1/2)` (**warning: do not use decimal point**, for example '0.5,0.5')." ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $x\\to 1-1/(x+1)$" + "Substitute $x\\to 1 - \\frac{1}{a + 1}$" ], "text/plain": [ "" @@ -818,7 +1078,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to 1-1/(y+1)$" + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" ], "text/plain": [ "" @@ -830,7 +1090,7 @@ { "data": { "text/latex": [ - "numerator: $6x^3y+3x^3-12x^2y^2-3x^2y+3x^2+6xy^3-3xy^2-6xy+3y^3+3y^2$" + "numerator: $6 a^{3} b + 3 a^{3} - 12 a^{2} b^{2} - 3 a^{2} b + 3 a^{2} + 6 a b^{3} - 3 a b^{2} - 6 a b + 3 b^{3} + 3 b^{2}$" ], "text/plain": [ "" @@ -842,7 +1102,7 @@ { "data": { "text/latex": [ - "denominator: $4x^2y+2x^2+4xy^2+8xy+3x+2y^2+3y+1$" + "denominator: $4 a^{2} b + 2 a^{2} + 4 a b^{2} + 8 a b + 3 a + 2 b^{2} + 3 b + 1$" ], "text/plain": [ "" @@ -878,7 +1138,7 @@ { "data": { "text/latex": [ - "$$12x^2y^2 \\le 6x^3y+6xy^3$$" + "$$12 a^{2} b^{2} \\le 6 a^{3} b+6 a b^{3}$$" ], "text/plain": [ "" @@ -890,7 +1150,7 @@ { "data": { "text/latex": [ - "$$3x^2y \\le 2x^3+y^3$$" + "$$3 a^{2} b \\le 2 a^{3}+b^{3}$$" ], "text/plain": [ "" @@ -902,7 +1162,7 @@ { "data": { "text/latex": [ - "$$3xy^2 \\le x^3+2y^3$$" + "$$3 a b^{2} \\le a^{3}+2 b^{3}$$" ], "text/plain": [ "" @@ -914,7 +1174,7 @@ { "data": { "text/latex": [ - "$$6xy \\le 3x^2+3y^2$$" + "$$6 a b \\le 3 a^{2}+3 b^{2}$$" ], "text/plain": [ "" @@ -953,12 +1213,13 @@ "0" ] }, - "execution_count": 8, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "newproof()\n", "newformula,newvalues=makesubs('1/(1-x^2)+1/(1-y^2)-2/(1-x*y)','[0,1],[0,1]','1/2,1/2')\n", "prove(newformula*3,newvalues)" ] @@ -978,411 +1239,7 @@ "* constraints for variables are written as intervals,\n", "* there are no \"backwards dependencies\", i.e. there is no $x$ in the interval of $y$.\n", "\n", - "If these two conditions hold, then you can use `makesubs` function.\n", - "**Warning:** at this moment `makesubs` **doesn't warn you if your list of intervals doesn't follow these rules!**\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "Substitute $x\\to -y+1+(y-1)/(x+1)$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $y\\to 1-1/(y+1)$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $y\\to y/2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "numerator: $x^4y^2+x^3y^2-2x^3y-4x^2y+4x^2+xy^2-2xy+y^2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $x^3y^2+2x^3y+2x^2y^2+4x^2y+xy^2+2xy$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "From weighted AM-GM inequality:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$2x^3y \\le x^4y^2+x^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$4x^2y \\le x^3y^2+2x^2+xy^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$2xy \\le x^2+y^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 0 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))\n", - "newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')\n", - "prove(newformula,values)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "The proof is found, so the assumption that 1 is the minimum of `xy/z+yz/x+zx/y` was good.\n", - "\n", - "Functions `S` and `Sm` creates a SymPy object from a string. The only difference is that `Sm` assumes that there are no multi-letter variables and adds a multiplication sign between every two terms which has no operator sign, so object `Sm(xy/z+yz/x+zx/y)` has 3 variables `x,y,z` and `S('xy/z+yz/x+zx/y')` has 6 variables `x,y,z,xy,yz,zx`. \n", - "\n", - "As you may have noticed, formulas are often cyclic or symmetric. Therefore you can use `cyclize` or `symmetrize` function to reduce the length of the written formula. Here are a few commands which will do the same as each other. " - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "numerator: $2a^2-2ab-2ac+2b^2-2bc+2c^2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "From weighted AM-GM inequality:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$2ab \\le a^2+b^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$2ac \\le a^2+c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$2bc \\le b^2+c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 0 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "prove('(a^2+b^2+c^2-a*b-a*c-b*c)*2')\n", - "#prove(S('(a^2+b^2+c^2-a*b-a*c-b*c)*2'))\n", - "#prove(Sm('2(a^2+b^2+c^2-ab-ac-bc)'))\n", - "#prove(cyclize('2*a^2-2*a*b'))\n", - "#prove(symmetrize('a^2-a*b'))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now look at formula $(x-1)^4$. It's quite obvious that it's nonnegative, but `prove` fails to show this!" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "numerator: $x^4-4x^3+6x^2-4x+1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 2" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Program couldn't find any proof." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 4x^3+4x \\le x^4+6x^2+1 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "2" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "prove('(x-1)^4')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "But there is a relatively simple method to generate a proof using this library. We will make to proofs: one for $x\\in (1,\\infty)$ and the second one for $(-\\infty,1)$." + "If these two conditions hold, then you can use `makesubs` function." ] }, { @@ -1393,7 +1250,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+1$" + "Substitute $x\\to - y + 1 + \\frac{y - 1}{a + 1}$" ], "text/plain": [ "" @@ -1405,7 +1262,7 @@ { "data": { "text/latex": [ - "numerator: $x^4$" + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" ], "text/plain": [ "" @@ -1417,7 +1274,31 @@ { "data": { "text/latex": [ - "denominator: $1$" + "Substitute $b\\to \\frac{c}{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $a^{4} c^{2} + a^{3} c^{2} - 2 a^{3} c - 4 a^{2} c + 4 a^{2} + a c^{2} - 2 a c + c^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $a^{3} c^{2} + 2 a^{3} c + 2 a^{2} c^{2} + 4 a^{2} c + a c^{2} + 2 a c$" ], "text/plain": [ "" @@ -1441,7 +1322,55 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a^{3} c \\le a^{4} c^{2}+a^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 a^{2} c \\le a^{3} c^{2}+2 a^{2}+a c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a c \\le a^{2}+c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" ], "text/plain": [ "" @@ -1474,32 +1403,32 @@ } ], "source": [ - "prove(makesubs('(x-1)^4','(1,oo)'))" + "newproof()\n", + "formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))\n", + "newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')\n", + "prove(newformula,values)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The proof is found, so the assumption that 1 is the minimum of `xy/z+yz/x+zx/y` was good.\n", + "\n", + "Functions `S` and `Sm` creates a SymPy object from a string. The only difference is that `Sm` assumes that there are no multi-letter variables and adds a multiplication sign between every two terms which has no operator sign, so object `Sm(xy/z+yz/x+zx/y)` has 3 variables `x,y,z` and `S('xy/z+yz/x+zx/y')` has 6 variables `x,y,z,xy,yz,zx`. \n", + "\n", + "As you may have noticed, formulas are often cyclic or symmetric. Therefore you can use `cyclize` or `symmetrize` function to reduce the length of the written formula. Here are a few commands which will do the same as each other. " ] }, { "cell_type": "code", "execution_count": 13, - "metadata": { - "scrolled": true - }, + "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $x\\to 1-x$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "numerator: $x^4$" + "numerator: $2 a^{2} - 2 a b - 2 a c + 2 b^{2} - 2 b c + 2 c^{2}$" ], "text/plain": [ "" @@ -1535,7 +1464,55 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a b \\le a^{2}+b^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a c \\le a^{2}+c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 b c \\le b^{2}+c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" ], "text/plain": [ "" @@ -1568,19 +1545,18 @@ } ], "source": [ - "prove(makesubs('(x-1)^4','(-oo,1)'))" + "prove('(a^2+b^2+c^2-a*b-a*c-b*c)*2')\n", + "#prove(S('(a^2+b^2+c^2-a*b-a*c-b*c)*2'))\n", + "#prove(Sm('2(a^2+b^2+c^2-ab-ac-bc)'))\n", + "#prove(cyclize('2*a^2-2*a*b'))\n", + "#prove(symmetrize('a^2-a*b'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now let's go to the problem 10\n", - "#### Problem 10\n", - "If $a,b,c,d>0$, prove that\n", - "$$\\frac a{b+c}+\\frac b{c+d}+ \\frac c{d+a}+ \\frac d{a+b}\\geq 2.$$\n", - "\n", - "Let's try a simple approach." + "Now look at formula $(x-1)^4$. It's quite obvious that it's nonnegative, but `prove` fails to show this!" ] }, { @@ -1591,31 +1567,7 @@ { "data": { "text/latex": [ - "$\\displaystyle \\frac{a}{b + c} + \\frac{b}{c + d} + \\frac{c}{a + d} + \\frac{d}{a + b} - 2$" - ], - "text/plain": [ - "a/(b + c) + b/(c + d) + c/(a + d) + d/(a + b) - 2" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "formula=cyclize('a/(b+c)',variables='a,b,c,d')-2\n", - "formula" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "numerator: $a^3c+a^3d+a^2b^2-a^2bd-2a^2c^2-a^2cd+a^2d^2+ab^3-ab^2c-ab^2d-abc^2+ac^3-acd^2+b^3d+b^2c^2-2b^2d^2+bc^3-bc^2d-bcd^2+bd^3+c^2d^2+cd^3$" + "numerator: $x^{4} - 4 x^{3} + 6 x^{2} - 4 x + 1$" ], "text/plain": [ "" @@ -1627,7 +1579,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+a^2cd+ab^2c+ab^2d+abc^2+2abcd+abd^2+ac^2d+acd^2+b^2cd+b^2d^2+bc^2d+bcd^2$" + "denominator: $1$" ], "text/plain": [ "" @@ -1663,7 +1615,7 @@ { "data": { "text/latex": [ - "$$ a^2bd+2a^2c^2+a^2cd+ab^2c+ab^2d+abc^2+acd^2+2b^2d^2+bc^2d+bcd^2 \\le a^3c+a^3d+a^2b^2+a^2d^2+ab^3+ac^3+b^3d+b^2c^2+bc^3+bd^3+c^2d^2+cd^3 $$" + "$$ 4 x^{3}+4 x \\le x^{4}+6 x^{2}+1 $$" ], "text/plain": [ "" @@ -1678,11 +1630,322 @@ "2" ] }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove('(x-1)^4')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "But there is a relatively simple method to generate a proof using this library. We will make to proofs: one for $x\\in (1,\\infty)$ and the second one for $(-\\infty,1)$." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $x\\to a + 1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $a^{4}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le a^{4} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], + "source": [ + "newproof()\n", + "prove(makesubs('(x-1)^4','(1,oo)'))" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $x\\to 1 - a$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $a^{4}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le a^{4} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "newproof()\n", + "prove(makesubs('(x-1)^4','(-oo,1)'))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's go to the problem 10\n", + "#### Problem 10\n", + "If $a,b,c,d>0$, prove that\n", + "$$\\frac a{b+c}+\\frac b{c+d}+ \\frac c{d+a}+ \\frac d{a+b}\\geq 2.$$\n", + "\n", + "Let's try a simple approach." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{a}{b + c} + \\frac{b}{c + d} + \\frac{c}{a + d} + \\frac{d}{a + b} - 2$" + ], + "text/plain": [ + "a/(b + c) + b/(c + d) + c/(a + d) + d/(a + b) - 2" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula=cyclize('a/(b+c)',variables='a,b,c,d')-2\n", + "formula" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "numerator: $a^{3} c + a^{3} d + a^{2} b^{2} - a^{2} b d - 2 a^{2} c^{2} - a^{2} c d + a^{2} d^{2} + a b^{3} - a b^{2} c - a b^{2} d - a b c^{2} + a c^{3} - a c d^{2} + b^{3} d + b^{2} c^{2} - 2 b^{2} d^{2} + b c^{3} - b c^{2} d - b c d^{2} + b d^{3} + c^{2} d^{2} + c d^{3}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $a^{2} b c + a^{2} b d + a^{2} c^{2} + a^{2} c d + a b^{2} c + a b^{2} d + a b c^{2} + 2 a b c d + a b d^{2} + a c^{2} d + a c d^{2} + b^{2} c d + b^{2} d^{2} + b c^{2} d + b c d^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 2" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Program couldn't find any proof." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ a^{2} b d+2 a^{2} c^{2}+a^{2} c d+a b^{2} c+a b^{2} d+a b c^{2}+a c d^{2}+2 b^{2} d^{2}+b c^{2} d+b c d^{2} \\le a^{3} c+a^{3} d+a^{2} b^{2}+a^{2} d^{2}+a b^{3}+a c^{3}+b^{3} d+b^{2} c^{2}+b c^{3}+b d^{3}+c^{2} d^{2}+c d^{3} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "prove(formula)" ] @@ -1696,13 +1959,13 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c + e$" ], "text/plain": [ "" @@ -1714,7 +1977,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+d$" + "Substitute $b\\to d + f$" ], "text/plain": [ "" @@ -1726,7 +1989,7 @@ { "data": { "text/latex": [ - "numerator: $a^3c+a^3d+a^2b^2+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^3+ab^2c+2ab^2d-abc^2+abd^2+b^3c+b^3d+b^2c^2+2b^2cd+b^2d^2$" + "numerator: $c^{2} e^{2} - c^{2} e f + c^{2} f^{2} + 2 c d e^{2} + 2 c d f^{2} + c e^{3} + c e f^{2} + c f^{3} + d^{2} e^{2} + d^{2} e f + d^{2} f^{2} + d e^{3} + d e^{2} f + 2 d e f^{2} + d f^{3} + e^{2} f^{2} + e f^{3}$" ], "text/plain": [ "" @@ -1738,7 +2001,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^2c+ab^2d+3abc^2+6abcd+3abd^2+2ac^3+6ac^2d+6acd^2+2ad^3+b^2c^2+2b^2cd+b^2d^2+2bc^3+6bc^2d+6bcd^2+2bd^3+c^4+4c^3d+6c^2d^2+4cd^3+d^4$" + "denominator: $c^{4} + 4 c^{3} d + 2 c^{3} e + 2 c^{3} f + 6 c^{2} d^{2} + 6 c^{2} d e + 6 c^{2} d f + c^{2} e^{2} + 3 c^{2} e f + c^{2} f^{2} + 4 c d^{3} + 6 c d^{2} e + 6 c d^{2} f + 2 c d e^{2} + 6 c d e f + 2 c d f^{2} + c e^{2} f + c e f^{2} + d^{4} + 2 d^{3} e + 2 d^{3} f + d^{2} e^{2} + 3 d^{2} e f + d^{2} f^{2} + d e^{2} f + d e f^{2}$" ], "text/plain": [ "" @@ -1786,7 +2049,7 @@ { "data": { "text/latex": [ - "$$ abc^2 \\le a^3c+a^3d+a^2b^2+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^3+ab^2c+2ab^2d+abd^2+b^3c+b^3d+b^2c^2+2b^2cd+b^2d^2 $$" + "$$ c^{2} e f \\le c^{2} e^{2}+c^{2} f^{2}+2 c d e^{2}+2 c d f^{2}+c e^{3}+c e f^{2}+c f^{3}+d^{2} e^{2}+d^{2} e f+d^{2} f^{2}+d e^{3}+d e^{2} f+2 d e f^{2}+d f^{3}+e^{2} f^{2}+e f^{3} $$" ], "text/plain": [ "" @@ -1801,24 +2064,25 @@ "0" ] }, - "execution_count": 16, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[c,oo],[d,oo]'))" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c + e$" ], "text/plain": [ "" @@ -1830,7 +2094,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+d$" + "Substitute $b\\to d + f$" ], "text/plain": [ "" @@ -1842,7 +2106,7 @@ { "data": { "text/latex": [ - "numerator: $2a^3c+2a^3d+2a^2b^2+2a^2bd+2a^2c^2+4a^2cd+2a^2d^2+2ab^3+2ab^2c+4ab^2d-2abc^2+2abd^2+2b^3c+2b^3d+2b^2c^2+4b^2cd+2b^2d^2$" + "numerator: $2 c^{2} e^{2} - 2 c^{2} e f + 2 c^{2} f^{2} + 4 c d e^{2} + 4 c d f^{2} + 2 c e^{3} + 2 c e f^{2} + 2 c f^{3} + 2 d^{2} e^{2} + 2 d^{2} e f + 2 d^{2} f^{2} + 2 d e^{3} + 2 d e^{2} f + 4 d e f^{2} + 2 d f^{3} + 2 e^{2} f^{2} + 2 e f^{3}$" ], "text/plain": [ "" @@ -1854,7 +2118,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^2c+ab^2d+3abc^2+6abcd+3abd^2+2ac^3+6ac^2d+6acd^2+2ad^3+b^2c^2+2b^2cd+b^2d^2+2bc^3+6bc^2d+6bcd^2+2bd^3+c^4+4c^3d+6c^2d^2+4cd^3+d^4$" + "denominator: $c^{4} + 4 c^{3} d + 2 c^{3} e + 2 c^{3} f + 6 c^{2} d^{2} + 6 c^{2} d e + 6 c^{2} d f + c^{2} e^{2} + 3 c^{2} e f + c^{2} f^{2} + 4 c d^{3} + 6 c d^{2} e + 6 c d^{2} f + 2 c d e^{2} + 6 c d e f + 2 c d f^{2} + c e^{2} f + c e f^{2} + d^{4} + 2 d^{3} e + 2 d^{3} f + d^{2} e^{2} + 3 d^{2} e f + d^{2} f^{2} + d e^{2} f + d e f^{2}$" ], "text/plain": [ "" @@ -1890,7 +2154,7 @@ { "data": { "text/latex": [ - "$$2abc^2 \\le a^2c^2+b^2c^2$$" + "$$2 c^{2} e f \\le c^{2} e^{2}+c^{2} f^{2}$$" ], "text/plain": [ "" @@ -1902,7 +2166,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 2a^3c+2a^3d+2a^2b^2+2a^2bd+a^2c^2+4a^2cd+2a^2d^2+2ab^3+2ab^2c+4ab^2d+2abd^2+2b^3c+2b^3d+b^2c^2+4b^2cd+2b^2d^2 $$" + "$$ 0 \\le c^{2} e^{2}+c^{2} f^{2}+4 c d e^{2}+4 c d f^{2}+2 c e^{3}+2 c e f^{2}+2 c f^{3}+2 d^{2} e^{2}+2 d^{2} e f+2 d^{2} f^{2}+2 d e^{3}+2 d e^{2} f+4 d e f^{2}+2 d f^{3}+2 e^{2} f^{2}+2 e f^{3} $$" ], "text/plain": [ "" @@ -1929,12 +2193,13 @@ "0" ] }, - "execution_count": 17, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[c,oo],[d,oo]')*2)" ] }, @@ -1947,13 +2212,13 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to c-c/(a+1)$" + "Substitute $a\\to c - \\frac{c}{e + 1}$" ], "text/plain": [ "" @@ -1965,7 +2230,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to d-d/(b+1)$" + "Substitute $b\\to d - \\frac{d}{f + 1}$" ], "text/plain": [ "" @@ -1977,7 +2242,7 @@ { "data": { "text/latex": [ - "numerator: $2a^3bc^2d^2+4a^3bcd^3+2a^3bd^4+2a^3c^2d^2+2a^3cd^3-2a^2b^2c^3d+2a^2b^2cd^3-4a^2bc^3d+4a^2bc^2d^2+12a^2bcd^3+6a^2bd^4-2a^2c^3d+4a^2c^2d^2+6a^2cd^3+2ab^3c^4+4ab^3c^3d+2ab^3c^2d^2+6ab^2c^4+8ab^2c^3d+4ab^2c^2d^2+4ab^2cd^3+6abc^4+4abc^3d+6abc^2d^2+12abcd^3+6abd^4+2ac^4+4ac^2d^2+6acd^3+2b^3c^3d+2b^3c^2d^2+4b^2c^3d+4b^2c^2d^2+2b^2cd^3+2bc^3d+4bc^2d^2+4bcd^3+2bd^4+2c^2d^2+2cd^3$" + "numerator: $2 c^{4} e f^{3} + 6 c^{4} e f^{2} + 6 c^{4} e f + 2 c^{4} e - 2 c^{3} d e^{2} f^{2} - 4 c^{3} d e^{2} f - 2 c^{3} d e^{2} + 4 c^{3} d e f^{3} + 8 c^{3} d e f^{2} + 4 c^{3} d e f + 2 c^{3} d f^{3} + 4 c^{3} d f^{2} + 2 c^{3} d f + 2 c^{2} d^{2} e^{3} f + 2 c^{2} d^{2} e^{3} + 4 c^{2} d^{2} e^{2} f + 4 c^{2} d^{2} e^{2} + 2 c^{2} d^{2} e f^{3} + 4 c^{2} d^{2} e f^{2} + 6 c^{2} d^{2} e f + 4 c^{2} d^{2} e + 2 c^{2} d^{2} f^{3} + 4 c^{2} d^{2} f^{2} + 4 c^{2} d^{2} f + 2 c^{2} d^{2} + 4 c d^{3} e^{3} f + 2 c d^{3} e^{3} + 2 c d^{3} e^{2} f^{2} + 12 c d^{3} e^{2} f + 6 c d^{3} e^{2} + 4 c d^{3} e f^{2} + 12 c d^{3} e f + 6 c d^{3} e + 2 c d^{3} f^{2} + 4 c d^{3} f + 2 c d^{3} + 2 d^{4} e^{3} f + 6 d^{4} e^{2} f + 6 d^{4} e f + 2 d^{4} f$" ], "text/plain": [ "" @@ -1989,7 +2254,7 @@ { "data": { "text/latex": [ - "denominator: $a^3b^3c^4+4a^3b^3c^3d+6a^3b^3c^2d^2+4a^3b^3cd^3+a^3b^3d^4+3a^3b^2c^4+10a^3b^2c^3d+12a^3b^2c^2d^2+6a^3b^2cd^3+a^3b^2d^4+3a^3bc^4+8a^3bc^3d+7a^3bc^2d^2+2a^3bcd^3+a^3c^4+2a^3c^3d+a^3c^2d^2+a^2b^3c^4+6a^2b^3c^3d+12a^2b^3c^2d^2+10a^2b^3cd^3+3a^2b^3d^4+3a^2b^2c^4+15a^2b^2c^3d+24a^2b^2c^2d^2+15a^2b^2cd^3+3a^2b^2d^4+3a^2bc^4+12a^2bc^3d+14a^2bc^2d^2+5a^2bcd^3+a^2c^4+3a^2c^3d+2a^2c^2d^2+2ab^3c^3d+7ab^3c^2d^2+8ab^3cd^3+3ab^3d^4+5ab^2c^3d+14ab^2c^2d^2+12ab^2cd^3+3ab^2d^4+4abc^3d+8abc^2d^2+4abcd^3+ac^3d+ac^2d^2+b^3c^2d^2+2b^3cd^3+b^3d^4+2b^2c^2d^2+3b^2cd^3+b^2d^4+bc^2d^2+bcd^3$" + "denominator: $c^{4} e^{3} f^{3} + 3 c^{4} e^{3} f^{2} + 3 c^{4} e^{3} f + c^{4} e^{3} + c^{4} e^{2} f^{3} + 3 c^{4} e^{2} f^{2} + 3 c^{4} e^{2} f + c^{4} e^{2} + 4 c^{3} d e^{3} f^{3} + 10 c^{3} d e^{3} f^{2} + 8 c^{3} d e^{3} f + 2 c^{3} d e^{3} + 6 c^{3} d e^{2} f^{3} + 15 c^{3} d e^{2} f^{2} + 12 c^{3} d e^{2} f + 3 c^{3} d e^{2} + 2 c^{3} d e f^{3} + 5 c^{3} d e f^{2} + 4 c^{3} d e f + c^{3} d e + 6 c^{2} d^{2} e^{3} f^{3} + 12 c^{2} d^{2} e^{3} f^{2} + 7 c^{2} d^{2} e^{3} f + c^{2} d^{2} e^{3} + 12 c^{2} d^{2} e^{2} f^{3} + 24 c^{2} d^{2} e^{2} f^{2} + 14 c^{2} d^{2} e^{2} f + 2 c^{2} d^{2} e^{2} + 7 c^{2} d^{2} e f^{3} + 14 c^{2} d^{2} e f^{2} + 8 c^{2} d^{2} e f + c^{2} d^{2} e + c^{2} d^{2} f^{3} + 2 c^{2} d^{2} f^{2} + c^{2} d^{2} f + 4 c d^{3} e^{3} f^{3} + 6 c d^{3} e^{3} f^{2} + 2 c d^{3} e^{3} f + 10 c d^{3} e^{2} f^{3} + 15 c d^{3} e^{2} f^{2} + 5 c d^{3} e^{2} f + 8 c d^{3} e f^{3} + 12 c d^{3} e f^{2} + 4 c d^{3} e f + 2 c d^{3} f^{3} + 3 c d^{3} f^{2} + c d^{3} f + d^{4} e^{3} f^{3} + d^{4} e^{3} f^{2} + 3 d^{4} e^{2} f^{3} + 3 d^{4} e^{2} f^{2} + 3 d^{4} e f^{3} + 3 d^{4} e f^{2} + d^{4} f^{3} + d^{4} f^{2}$" ], "text/plain": [ "" @@ -2025,7 +2290,7 @@ { "data": { "text/latex": [ - "$$2a^2b^2c^3d \\le a^3bc^2d^2+ab^3c^4$$" + "$$2 c^{3} d e^{2} f^{2} \\le c^{4} e f^{3}+c^{2} d^{2} e^{3} f$$" ], "text/plain": [ "" @@ -2037,7 +2302,7 @@ { "data": { "text/latex": [ - "$$2a^2c^3d \\le a^3c^2d^2+ac^4$$" + "$$2 c^{3} d e^{2} \\le c^{4} e+c^{2} d^{2} e^{3}$$" ], "text/plain": [ "" @@ -2049,7 +2314,7 @@ { "data": { "text/latex": [ - "$$4a^2bc^3d \\le a^3bc^2d^2+a^3c^2d^2+ab^3c^4+ac^4$$" + "$$4 c^{3} d e^{2} f \\le c^{4} e f^{3}+c^{4} e+c^{2} d^{2} e^{3} f+c^{2} d^{2} e^{3}$$" ], "text/plain": [ "" @@ -2061,7 +2326,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^3bcd^3+2a^3bd^4+2a^3cd^3+2a^2b^2cd^3+4a^2bc^2d^2+12a^2bcd^3+6a^2bd^4+4a^2c^2d^2+6a^2cd^3+4ab^3c^3d+2ab^3c^2d^2+6ab^2c^4+8ab^2c^3d+4ab^2c^2d^2+4ab^2cd^3+6abc^4+4abc^3d+6abc^2d^2+12abcd^3+6abd^4+4ac^2d^2+6acd^3+2b^3c^3d+2b^3c^2d^2+4b^2c^3d+4b^2c^2d^2+2b^2cd^3+2bc^3d+4bc^2d^2+4bcd^3+2bd^4+2c^2d^2+2cd^3 $$" + "$$ 0 \\le 6 c^{4} e f^{2}+6 c^{4} e f+4 c^{3} d e f^{3}+8 c^{3} d e f^{2}+4 c^{3} d e f+2 c^{3} d f^{3}+4 c^{3} d f^{2}+2 c^{3} d f+4 c^{2} d^{2} e^{2} f+4 c^{2} d^{2} e^{2}+2 c^{2} d^{2} e f^{3}+4 c^{2} d^{2} e f^{2}+6 c^{2} d^{2} e f+4 c^{2} d^{2} e+2 c^{2} d^{2} f^{3}+4 c^{2} d^{2} f^{2}+4 c^{2} d^{2} f+2 c^{2} d^{2}+4 c d^{3} e^{3} f+2 c d^{3} e^{3}+2 c d^{3} e^{2} f^{2}+12 c d^{3} e^{2} f+6 c d^{3} e^{2}+4 c d^{3} e f^{2}+12 c d^{3} e f+6 c d^{3} e+2 c d^{3} f^{2}+4 c d^{3} f+2 c d^{3}+2 d^{4} e^{3} f+6 d^{4} e^{2} f+6 d^{4} e f+2 d^{4} f $$" ], "text/plain": [ "" @@ -2088,12 +2353,13 @@ "0" ] }, - "execution_count": 18, + "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[0,c],[0,d]')*2)" ] }, @@ -2106,13 +2372,13 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $x^4-4x^3+6x^2-4x+1$" + "numerator: $x^{4} - 4 x^{3} + 6 x^{2} - 4 x + 1$" ], "text/plain": [ "" @@ -2136,8 +2402,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2149,7 +2414,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1+x$" + "Substitute $x\\to 1+a$" ], "text/plain": [ "" @@ -2161,7 +2426,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $x^4$" + "Numerator after substitutions: $a^{4}$" ], "text/plain": [ "" @@ -2185,7 +2450,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le a^{4} $$" ], "text/plain": [ "" @@ -2209,8 +2474,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2222,7 +2486,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1/(1+x)$" + "Substitute $x\\to 1/(1+b)$" ], "text/plain": [ "" @@ -2234,7 +2498,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $x^4$" + "Numerator after substitutions: $b^{4}$" ], "text/plain": [ "" @@ -2258,7 +2522,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le b^{4} $$" ], "text/plain": [ "" @@ -2278,21 +2542,32 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Counter({0: 2})" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ + "newproof()\n", "powerprove('(x-1)^4')" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $4a^5+4a^4b+4a^4c-6a^4-4a^3b-2a^3c+4ab^3-9ab^2+4ac^2-18ac+9a+4b^4+4b^3c-6b^3-3b^2c+4bc^2-12bc+10b+4c^3-6c^2+11c$" + "numerator: $4 a^{5} + 4 a^{4} b + 4 a^{4} c - 6 a^{4} - 4 a^{3} b - 2 a^{3} c + 4 a b^{3} - 9 a b^{2} + 4 a c^{2} - 18 a c + 9 a + 4 b^{4} + 4 b^{3} c - 6 b^{3} - 3 b^{2} c + 4 b c^{2} - 12 b c + 10 b + 4 c^{3} - 6 c^{2} + 11 c$" ], "text/plain": [ "" @@ -2316,8 +2591,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2329,7 +2603,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1+b,c\\to 1+c$" + "Substitute $a\\to 1+d,b\\to 1+e,c\\to 1+f$" ], "text/plain": [ "" @@ -2341,7 +2615,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5+4a^4b+4a^4c+22a^4+12a^3b+14a^3c+42a^3+12a^2b+18a^2c+34a^2+4ab^3+3ab^2-2ab+4ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 d^{5} + 4 d^{4} e + 4 d^{4} f + 22 d^{4} + 12 d^{3} e + 14 d^{3} f + 42 d^{3} + 12 d^{2} e + 18 d^{2} f + 34 d^{2} + 4 d e^{3} + 3 d e^{2} - 2 d e + 4 d f^{2} + 4 e^{4} + 4 e^{3} f + 18 e^{3} + 9 e^{2} f + 18 e^{2} + 4 e f^{2} + 2 e f + 4 f^{3} + 14 f^{2}$" ], "text/plain": [ "" @@ -2377,7 +2651,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 d e \\le d^{2}+e^{2}$$" ], "text/plain": [ "" @@ -2389,7 +2663,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5+4a^4b+4a^4c+22a^4+12a^3b+14a^3c+42a^3+12a^2b+18a^2c+33a^2+4ab^3+3ab^2+4ac^2+4b^4+4b^3c+18b^3+9b^2c+17b^2+4bc^2+2bc+4c^3+14c^2 $$" + "$$ 0 \\le 4 d^{5}+4 d^{4} e+4 d^{4} f+22 d^{4}+12 d^{3} e+14 d^{3} f+42 d^{3}+12 d^{2} e+18 d^{2} f+33 d^{2}+4 d e^{3}+3 d e^{2}+4 d f^{2}+4 e^{4}+4 e^{3} f+18 e^{3}+9 e^{2} f+17 e^{2}+4 e f^{2}+2 e f+4 f^{3}+14 f^{2} $$" ], "text/plain": [ "" @@ -2413,8 +2687,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2426,7 +2699,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1+b,c\\to 1+c$" + "Substitute $a\\to 1/(1+g),b\\to 1+h,c\\to 1+i$" ], "text/plain": [ "" @@ -2438,7 +2711,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4+4a^5b^3c+14a^5b^3+9a^5b^2c+15a^5b^2+4a^5bc^2+2a^5bc+6a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4+20a^4b^3c+74a^4b^3+45a^4b^2c+78a^4b^2+20a^4bc^2+10a^4bc+24a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4+40a^3b^3c+156a^3b^3+90a^3b^2c+162a^3b^2+40a^3bc^2+20a^3bc+36a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4+40a^2b^3c+164a^2b^3+90a^2b^2c+168a^2b^2+40a^2bc^2+20a^2bc+20a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4+20ab^3c+86ab^3+45ab^2c+87ab^2+20abc^2+10abc+2ab+20ac^3+66ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 g^{5} h^{4} + 4 g^{5} h^{3} i + 14 g^{5} h^{3} + 9 g^{5} h^{2} i + 15 g^{5} h^{2} + 4 g^{5} h i^{2} + 2 g^{5} h i + 6 g^{5} h + 4 g^{5} i^{3} + 10 g^{5} i^{2} + 8 g^{5} i + 10 g^{5} + 20 g^{4} h^{4} + 20 g^{4} h^{3} i + 74 g^{4} h^{3} + 45 g^{4} h^{2} i + 78 g^{4} h^{2} + 20 g^{4} h i^{2} + 10 g^{4} h i + 24 g^{4} h + 20 g^{4} i^{3} + 54 g^{4} i^{2} + 30 g^{4} i + 40 g^{4} + 40 g^{3} h^{4} + 40 g^{3} h^{3} i + 156 g^{3} h^{3} + 90 g^{3} h^{2} i + 162 g^{3} h^{2} + 40 g^{3} h i^{2} + 20 g^{3} h i + 36 g^{3} h + 40 g^{3} i^{3} + 116 g^{3} i^{2} + 40 g^{3} i + 60 g^{3} + 40 g^{2} h^{4} + 40 g^{2} h^{3} i + 164 g^{2} h^{3} + 90 g^{2} h^{2} i + 168 g^{2} h^{2} + 40 g^{2} h i^{2} + 20 g^{2} h i + 20 g^{2} h + 40 g^{2} i^{3} + 124 g^{2} i^{2} + 18 g^{2} i + 34 g^{2} + 20 g h^{4} + 20 g h^{3} i + 86 g h^{3} + 45 g h^{2} i + 87 g h^{2} + 20 g h i^{2} + 10 g h i + 2 g h + 20 g i^{3} + 66 g i^{2} + 4 h^{4} + 4 h^{3} i + 18 h^{3} + 9 h^{2} i + 18 h^{2} + 4 h i^{2} + 2 h i + 4 i^{3} + 14 i^{2}$" ], "text/plain": [ "" @@ -2462,7 +2735,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4+4a^5b^3c+14a^5b^3+9a^5b^2c+15a^5b^2+4a^5bc^2+2a^5bc+6a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4+20a^4b^3c+74a^4b^3+45a^4b^2c+78a^4b^2+20a^4bc^2+10a^4bc+24a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4+40a^3b^3c+156a^3b^3+90a^3b^2c+162a^3b^2+40a^3bc^2+20a^3bc+36a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4+40a^2b^3c+164a^2b^3+90a^2b^2c+168a^2b^2+40a^2bc^2+20a^2bc+20a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4+20ab^3c+86ab^3+45ab^2c+87ab^2+20abc^2+10abc+2ab+20ac^3+66ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2 $$" + "$$ 0 \\le 4 g^{5} h^{4}+4 g^{5} h^{3} i+14 g^{5} h^{3}+9 g^{5} h^{2} i+15 g^{5} h^{2}+4 g^{5} h i^{2}+2 g^{5} h i+6 g^{5} h+4 g^{5} i^{3}+10 g^{5} i^{2}+8 g^{5} i+10 g^{5}+20 g^{4} h^{4}+20 g^{4} h^{3} i+74 g^{4} h^{3}+45 g^{4} h^{2} i+78 g^{4} h^{2}+20 g^{4} h i^{2}+10 g^{4} h i+24 g^{4} h+20 g^{4} i^{3}+54 g^{4} i^{2}+30 g^{4} i+40 g^{4}+40 g^{3} h^{4}+40 g^{3} h^{3} i+156 g^{3} h^{3}+90 g^{3} h^{2} i+162 g^{3} h^{2}+40 g^{3} h i^{2}+20 g^{3} h i+36 g^{3} h+40 g^{3} i^{3}+116 g^{3} i^{2}+40 g^{3} i+60 g^{3}+40 g^{2} h^{4}+40 g^{2} h^{3} i+164 g^{2} h^{3}+90 g^{2} h^{2} i+168 g^{2} h^{2}+40 g^{2} h i^{2}+20 g^{2} h i+20 g^{2} h+40 g^{2} i^{3}+124 g^{2} i^{2}+18 g^{2} i+34 g^{2}+20 g h^{4}+20 g h^{3} i+86 g h^{3}+45 g h^{2} i+87 g h^{2}+20 g h i^{2}+10 g h i+2 g h+20 g i^{3}+66 g i^{2}+4 h^{4}+4 h^{3} i+18 h^{3}+9 h^{2} i+18 h^{2}+4 h i^{2}+2 h i+4 i^{3}+14 i^{2} $$" ], "text/plain": [ "" @@ -2486,8 +2759,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2499,7 +2771,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1/(1+b),c\\to 1+c$" + "Substitute $a\\to 1+j,b\\to 1/(1+k),c\\to 1+l$" ], "text/plain": [ "" @@ -2511,7 +2783,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4+16a^5b^3+24a^5b^2+16a^5b+4a^5+4a^4b^4c+18a^4b^4+16a^4b^3c+76a^4b^3+24a^4b^2c+120a^4b^2+16a^4bc+84a^4b+4a^4c+22a^4+14a^3b^4c+30a^3b^4+56a^3b^3c+132a^3b^3+84a^3b^2c+216a^3b^2+56a^3bc+156a^3b+14a^3c+42a^3+18a^2b^4c+22a^2b^4+72a^2b^3c+100a^2b^3+108a^2b^2c+168a^2b^2+72a^2bc+124a^2b+18a^2c+34a^2+4ab^4c^2+ab^4+16ab^3c^2+8ab^3+24ab^2c^2+9ab^2+16abc^2+2ab+4ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+18b^2+16bc^3+52bc^2-2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 j^{5} k^{4} + 16 j^{5} k^{3} + 24 j^{5} k^{2} + 16 j^{5} k + 4 j^{5} + 4 j^{4} k^{4} l + 18 j^{4} k^{4} + 16 j^{4} k^{3} l + 76 j^{4} k^{3} + 24 j^{4} k^{2} l + 120 j^{4} k^{2} + 16 j^{4} k l + 84 j^{4} k + 4 j^{4} l + 22 j^{4} + 14 j^{3} k^{4} l + 30 j^{3} k^{4} + 56 j^{3} k^{3} l + 132 j^{3} k^{3} + 84 j^{3} k^{2} l + 216 j^{3} k^{2} + 56 j^{3} k l + 156 j^{3} k + 14 j^{3} l + 42 j^{3} + 18 j^{2} k^{4} l + 22 j^{2} k^{4} + 72 j^{2} k^{3} l + 100 j^{2} k^{3} + 108 j^{2} k^{2} l + 168 j^{2} k^{2} + 72 j^{2} k l + 124 j^{2} k + 18 j^{2} l + 34 j^{2} + 4 j k^{4} l^{2} + j k^{4} + 16 j k^{3} l^{2} + 8 j k^{3} + 24 j k^{2} l^{2} + 9 j k^{2} + 16 j k l^{2} + 2 j k + 4 j l^{2} + 4 k^{4} l^{3} + 10 k^{4} l^{2} + 3 k^{4} l + 4 k^{4} + 16 k^{3} l^{3} + 44 k^{3} l^{2} + 8 k^{3} l + 18 k^{3} + 24 k^{2} l^{3} + 72 k^{2} l^{2} + 3 k^{2} l + 18 k^{2} + 16 k l^{3} + 52 k l^{2} - 2 k l + 4 l^{3} + 14 l^{2}$" ], "text/plain": [ "" @@ -2547,7 +2819,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 k l \\le k^{2}+l^{2}$$" ], "text/plain": [ "" @@ -2559,7 +2831,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4+16a^5b^3+24a^5b^2+16a^5b+4a^5+4a^4b^4c+18a^4b^4+16a^4b^3c+76a^4b^3+24a^4b^2c+120a^4b^2+16a^4bc+84a^4b+4a^4c+22a^4+14a^3b^4c+30a^3b^4+56a^3b^3c+132a^3b^3+84a^3b^2c+216a^3b^2+56a^3bc+156a^3b+14a^3c+42a^3+18a^2b^4c+22a^2b^4+72a^2b^3c+100a^2b^3+108a^2b^2c+168a^2b^2+72a^2bc+124a^2b+18a^2c+34a^2+4ab^4c^2+ab^4+16ab^3c^2+8ab^3+24ab^2c^2+9ab^2+16abc^2+2ab+4ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+17b^2+16bc^3+52bc^2+4c^3+13c^2 $$" + "$$ 0 \\le 4 j^{5} k^{4}+16 j^{5} k^{3}+24 j^{5} k^{2}+16 j^{5} k+4 j^{5}+4 j^{4} k^{4} l+18 j^{4} k^{4}+16 j^{4} k^{3} l+76 j^{4} k^{3}+24 j^{4} k^{2} l+120 j^{4} k^{2}+16 j^{4} k l+84 j^{4} k+4 j^{4} l+22 j^{4}+14 j^{3} k^{4} l+30 j^{3} k^{4}+56 j^{3} k^{3} l+132 j^{3} k^{3}+84 j^{3} k^{2} l+216 j^{3} k^{2}+56 j^{3} k l+156 j^{3} k+14 j^{3} l+42 j^{3}+18 j^{2} k^{4} l+22 j^{2} k^{4}+72 j^{2} k^{3} l+100 j^{2} k^{3}+108 j^{2} k^{2} l+168 j^{2} k^{2}+72 j^{2} k l+124 j^{2} k+18 j^{2} l+34 j^{2}+4 j k^{4} l^{2}+j k^{4}+16 j k^{3} l^{2}+8 j k^{3}+24 j k^{2} l^{2}+9 j k^{2}+16 j k l^{2}+2 j k+4 j l^{2}+4 k^{4} l^{3}+10 k^{4} l^{2}+3 k^{4} l+4 k^{4}+16 k^{3} l^{3}+44 k^{3} l^{2}+8 k^{3} l+18 k^{3}+24 k^{2} l^{3}+72 k^{2} l^{2}+3 k^{2} l+17 k^{2}+16 k l^{3}+52 k l^{2}+4 l^{3}+13 l^{2} $$" ], "text/plain": [ "" @@ -2583,8 +2855,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2596,7 +2867,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1/(1+b),c\\to 1+c$" + "Substitute $a\\to 1/(1+m),b\\to 1/(1+n),c\\to 1+o$" ], "text/plain": [ "" @@ -2608,7 +2879,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+6a^5b^4c^2+11a^5b^4c+9a^5b^4+16a^5b^3c^3+28a^5b^3c^2+40a^5b^3c+38a^5b^3+24a^5b^2c^3+48a^5b^2c^2+51a^5b^2c+57a^5b^2+16a^5bc^3+36a^5bc^2+30a^5bc+34a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4c^3+34a^4b^4c^2+45a^4b^4c+40a^4b^4+80a^4b^3c^3+156a^4b^3c^2+160a^4b^3c+170a^4b^3+120a^4b^2c^3+264a^4b^2c^2+195a^4b^2c+246a^4b^2+80a^4bc^3+196a^4bc^2+110a^4bc+136a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4c^3+76a^3b^4c^2+70a^3b^4c+70a^3b^4+160a^3b^3c^3+344a^3b^3c^2+240a^3b^3c+300a^3b^3+240a^3b^2c^3+576a^3b^2c^2+270a^3b^2c+414a^3b^2+160a^3bc^3+424a^3bc^2+140a^3bc+204a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4c^3+84a^2b^4c^2+48a^2b^4c+58a^2b^4+160a^2b^3c^3+376a^2b^3c^2+152a^2b^3c+248a^2b^3+240a^2b^2c^3+624a^2b^2c^2+138a^2b^2c+312a^2b^2+160a^2bc^3+456a^2bc^2+52a^2bc+116a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4c^3+46ab^4c^2+15ab^4c+19ab^4+80ab^3c^3+204ab^3c^2+40ab^3c+82ab^3+120ab^2c^3+336ab^2c^2+15ab^2c+81ab^2+80abc^3+244abc^2-10abc-2ab+20ac^3+66ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+18b^2+16bc^3+52bc^2-2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 m^{5} n^{4} o^{3} + 6 m^{5} n^{4} o^{2} + 11 m^{5} n^{4} o + 9 m^{5} n^{4} + 16 m^{5} n^{3} o^{3} + 28 m^{5} n^{3} o^{2} + 40 m^{5} n^{3} o + 38 m^{5} n^{3} + 24 m^{5} n^{2} o^{3} + 48 m^{5} n^{2} o^{2} + 51 m^{5} n^{2} o + 57 m^{5} n^{2} + 16 m^{5} n o^{3} + 36 m^{5} n o^{2} + 30 m^{5} n o + 34 m^{5} n + 4 m^{5} o^{3} + 10 m^{5} o^{2} + 8 m^{5} o + 10 m^{5} + 20 m^{4} n^{4} o^{3} + 34 m^{4} n^{4} o^{2} + 45 m^{4} n^{4} o + 40 m^{4} n^{4} + 80 m^{4} n^{3} o^{3} + 156 m^{4} n^{3} o^{2} + 160 m^{4} n^{3} o + 170 m^{4} n^{3} + 120 m^{4} n^{2} o^{3} + 264 m^{4} n^{2} o^{2} + 195 m^{4} n^{2} o + 246 m^{4} n^{2} + 80 m^{4} n o^{3} + 196 m^{4} n o^{2} + 110 m^{4} n o + 136 m^{4} n + 20 m^{4} o^{3} + 54 m^{4} o^{2} + 30 m^{4} o + 40 m^{4} + 40 m^{3} n^{4} o^{3} + 76 m^{3} n^{4} o^{2} + 70 m^{3} n^{4} o + 70 m^{3} n^{4} + 160 m^{3} n^{3} o^{3} + 344 m^{3} n^{3} o^{2} + 240 m^{3} n^{3} o + 300 m^{3} n^{3} + 240 m^{3} n^{2} o^{3} + 576 m^{3} n^{2} o^{2} + 270 m^{3} n^{2} o + 414 m^{3} n^{2} + 160 m^{3} n o^{3} + 424 m^{3} n o^{2} + 140 m^{3} n o + 204 m^{3} n + 40 m^{3} o^{3} + 116 m^{3} o^{2} + 40 m^{3} o + 60 m^{3} + 40 m^{2} n^{4} o^{3} + 84 m^{2} n^{4} o^{2} + 48 m^{2} n^{4} o + 58 m^{2} n^{4} + 160 m^{2} n^{3} o^{3} + 376 m^{2} n^{3} o^{2} + 152 m^{2} n^{3} o + 248 m^{2} n^{3} + 240 m^{2} n^{2} o^{3} + 624 m^{2} n^{2} o^{2} + 138 m^{2} n^{2} o + 312 m^{2} n^{2} + 160 m^{2} n o^{3} + 456 m^{2} n o^{2} + 52 m^{2} n o + 116 m^{2} n + 40 m^{2} o^{3} + 124 m^{2} o^{2} + 18 m^{2} o + 34 m^{2} + 20 m n^{4} o^{3} + 46 m n^{4} o^{2} + 15 m n^{4} o + 19 m n^{4} + 80 m n^{3} o^{3} + 204 m n^{3} o^{2} + 40 m n^{3} o + 82 m n^{3} + 120 m n^{2} o^{3} + 336 m n^{2} o^{2} + 15 m n^{2} o + 81 m n^{2} + 80 m n o^{3} + 244 m n o^{2} - 10 m n o - 2 m n + 20 m o^{3} + 66 m o^{2} + 4 n^{4} o^{3} + 10 n^{4} o^{2} + 3 n^{4} o + 4 n^{4} + 16 n^{3} o^{3} + 44 n^{3} o^{2} + 8 n^{3} o + 18 n^{3} + 24 n^{2} o^{3} + 72 n^{2} o^{2} + 3 n^{2} o + 18 n^{2} + 16 n o^{3} + 52 n o^{2} - 2 n o + 4 o^{3} + 14 o^{2}$" ], "text/plain": [ "" @@ -2644,7 +2915,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 m n \\le m^{2}+n^{2}$$" ], "text/plain": [ "" @@ -2656,7 +2927,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 n o \\le n^{2}+o^{2}$$" ], "text/plain": [ "" @@ -2668,7 +2939,7 @@ { "data": { "text/latex": [ - "$$10abc \\le 2a^2+2ab^2c+4ac^2+2b^3$$" + "$$10 m n o \\le 2 m^{2}+2 m n^{2} o+4 m o^{2}+2 n^{3}$$" ], "text/plain": [ "" @@ -2680,7 +2951,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+6a^5b^4c^2+11a^5b^4c+9a^5b^4+16a^5b^3c^3+28a^5b^3c^2+40a^5b^3c+38a^5b^3+24a^5b^2c^3+48a^5b^2c^2+51a^5b^2c+57a^5b^2+16a^5bc^3+36a^5bc^2+30a^5bc+34a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4c^3+34a^4b^4c^2+45a^4b^4c+40a^4b^4+80a^4b^3c^3+156a^4b^3c^2+160a^4b^3c+170a^4b^3+120a^4b^2c^3+264a^4b^2c^2+195a^4b^2c+246a^4b^2+80a^4bc^3+196a^4bc^2+110a^4bc+136a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4c^3+76a^3b^4c^2+70a^3b^4c+70a^3b^4+160a^3b^3c^3+344a^3b^3c^2+240a^3b^3c+300a^3b^3+240a^3b^2c^3+576a^3b^2c^2+270a^3b^2c+414a^3b^2+160a^3bc^3+424a^3bc^2+140a^3bc+204a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4c^3+84a^2b^4c^2+48a^2b^4c+58a^2b^4+160a^2b^3c^3+376a^2b^3c^2+152a^2b^3c+248a^2b^3+240a^2b^2c^3+624a^2b^2c^2+138a^2b^2c+312a^2b^2+160a^2bc^3+456a^2bc^2+52a^2bc+116a^2b+40a^2c^3+124a^2c^2+18a^2c+31a^2+20ab^4c^3+46ab^4c^2+15ab^4c+19ab^4+80ab^3c^3+204ab^3c^2+40ab^3c+82ab^3+120ab^2c^3+336ab^2c^2+13ab^2c+81ab^2+80abc^3+244abc^2+20ac^3+62ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+16b^3+24b^2c^3+72b^2c^2+3b^2c+16b^2+16bc^3+52bc^2+4c^3+13c^2 $$" + "$$ 0 \\le 4 m^{5} n^{4} o^{3}+6 m^{5} n^{4} o^{2}+11 m^{5} n^{4} o+9 m^{5} n^{4}+16 m^{5} n^{3} o^{3}+28 m^{5} n^{3} o^{2}+40 m^{5} n^{3} o+38 m^{5} n^{3}+24 m^{5} n^{2} o^{3}+48 m^{5} n^{2} o^{2}+51 m^{5} n^{2} o+57 m^{5} n^{2}+16 m^{5} n o^{3}+36 m^{5} n o^{2}+30 m^{5} n o+34 m^{5} n+4 m^{5} o^{3}+10 m^{5} o^{2}+8 m^{5} o+10 m^{5}+20 m^{4} n^{4} o^{3}+34 m^{4} n^{4} o^{2}+45 m^{4} n^{4} o+40 m^{4} n^{4}+80 m^{4} n^{3} o^{3}+156 m^{4} n^{3} o^{2}+160 m^{4} n^{3} o+170 m^{4} n^{3}+120 m^{4} n^{2} o^{3}+264 m^{4} n^{2} o^{2}+195 m^{4} n^{2} o+246 m^{4} n^{2}+80 m^{4} n o^{3}+196 m^{4} n o^{2}+110 m^{4} n o+136 m^{4} n+20 m^{4} o^{3}+54 m^{4} o^{2}+30 m^{4} o+40 m^{4}+40 m^{3} n^{4} o^{3}+76 m^{3} n^{4} o^{2}+70 m^{3} n^{4} o+70 m^{3} n^{4}+160 m^{3} n^{3} o^{3}+344 m^{3} n^{3} o^{2}+240 m^{3} n^{3} o+300 m^{3} n^{3}+240 m^{3} n^{2} o^{3}+576 m^{3} n^{2} o^{2}+270 m^{3} n^{2} o+414 m^{3} n^{2}+160 m^{3} n o^{3}+424 m^{3} n o^{2}+140 m^{3} n o+204 m^{3} n+40 m^{3} o^{3}+116 m^{3} o^{2}+40 m^{3} o+60 m^{3}+40 m^{2} n^{4} o^{3}+84 m^{2} n^{4} o^{2}+48 m^{2} n^{4} o+58 m^{2} n^{4}+160 m^{2} n^{3} o^{3}+376 m^{2} n^{3} o^{2}+152 m^{2} n^{3} o+248 m^{2} n^{3}+240 m^{2} n^{2} o^{3}+624 m^{2} n^{2} o^{2}+138 m^{2} n^{2} o+312 m^{2} n^{2}+160 m^{2} n o^{3}+456 m^{2} n o^{2}+52 m^{2} n o+116 m^{2} n+40 m^{2} o^{3}+124 m^{2} o^{2}+18 m^{2} o+31 m^{2}+20 m n^{4} o^{3}+46 m n^{4} o^{2}+15 m n^{4} o+19 m n^{4}+80 m n^{3} o^{3}+204 m n^{3} o^{2}+40 m n^{3} o+82 m n^{3}+120 m n^{2} o^{3}+336 m n^{2} o^{2}+13 m n^{2} o+81 m n^{2}+80 m n o^{3}+244 m n o^{2}+20 m o^{3}+62 m o^{2}+4 n^{4} o^{3}+10 n^{4} o^{2}+3 n^{4} o+4 n^{4}+16 n^{3} o^{3}+44 n^{3} o^{2}+8 n^{3} o+16 n^{3}+24 n^{2} o^{3}+72 n^{2} o^{2}+3 n^{2} o+16 n^{2}+16 n o^{3}+52 n o^{2}+4 o^{3}+13 o^{2} $$" ], "text/plain": [ "" @@ -2704,8 +2975,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2717,7 +2987,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1+b,c\\to 1/(1+c)$" + "Substitute $a\\to 1+p,b\\to 1+q,c\\to 1/(1+r)$" ], "text/plain": [ "" @@ -2729,7 +2999,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5c^3+12a^5c^2+12a^5c+4a^5+4a^4bc^3+12a^4bc^2+12a^4bc+4a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+12a^3bc^3+36a^3bc^2+36a^3bc+12a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+12a^2bc^3+36a^2bc^2+36a^2bc+12a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+4ab^3c^3+12ab^3c^2+12ab^3c+4ab^3+3ab^2c^3+9ab^2c^2+9ab^2c+3ab^2-2abc^3-6abc^2-6abc-2ab+4ac^3+4ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+18b^2+2bc^3-2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 p^{5} r^{3} + 12 p^{5} r^{2} + 12 p^{5} r + 4 p^{5} + 4 p^{4} q r^{3} + 12 p^{4} q r^{2} + 12 p^{4} q r + 4 p^{4} q + 18 p^{4} r^{3} + 58 p^{4} r^{2} + 62 p^{4} r + 22 p^{4} + 12 p^{3} q r^{3} + 36 p^{3} q r^{2} + 36 p^{3} q r + 12 p^{3} q + 28 p^{3} r^{3} + 98 p^{3} r^{2} + 112 p^{3} r + 42 p^{3} + 12 p^{2} q r^{3} + 36 p^{2} q r^{2} + 36 p^{2} q r + 12 p^{2} q + 16 p^{2} r^{3} + 66 p^{2} r^{2} + 84 p^{2} r + 34 p^{2} + 4 p q^{3} r^{3} + 12 p q^{3} r^{2} + 12 p q^{3} r + 4 p q^{3} + 3 p q^{2} r^{3} + 9 p q^{2} r^{2} + 9 p q^{2} r + 3 p q^{2} - 2 p q r^{3} - 6 p q r^{2} - 6 p q r - 2 p q + 4 p r^{3} + 4 p r^{2} + 4 q^{4} r^{3} + 12 q^{4} r^{2} + 12 q^{4} r + 4 q^{4} + 14 q^{3} r^{3} + 46 q^{3} r^{2} + 50 q^{3} r + 18 q^{3} + 9 q^{2} r^{3} + 36 q^{2} r^{2} + 45 q^{2} r + 18 q^{2} + 2 q r^{3} - 2 q r + 10 r^{3} + 14 r^{2}$" ], "text/plain": [ "" @@ -2765,7 +3035,7 @@ { "data": { "text/latex": [ - "$$2abc^3 \\le a^2bc^3+bc^3$$" + "$$2 p q r^{3} \\le p^{2} q r^{3}+q r^{3}$$" ], "text/plain": [ "" @@ -2777,7 +3047,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 p q \\le p^{2}+q^{2}$$" ], "text/plain": [ "" @@ -2789,7 +3059,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 q r \\le q^{2}+r^{2}$$" ], "text/plain": [ "" @@ -2801,7 +3071,7 @@ { "data": { "text/latex": [ - "$$6abc \\le 2a^3b+2b^2c+2c^2$$" + "$$6 p q r \\le 2 p^{3} q+2 q^{2} r+2 r^{2}$$" ], "text/plain": [ "" @@ -2813,7 +3083,7 @@ { "data": { "text/latex": [ - "$$6abc^2 \\le 2ab^2c^3+ab^2+3ac^2$$" + "$$6 p q r^{2} \\le 2 p q^{2} r^{3}+p q^{2}+3 p r^{2}$$" ], "text/plain": [ "" @@ -2825,7 +3095,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5c^3+12a^5c^2+12a^5c+4a^5+4a^4bc^3+12a^4bc^2+12a^4bc+4a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+12a^3bc^3+36a^3bc^2+36a^3bc+10a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+11a^2bc^3+36a^2bc^2+36a^2bc+12a^2b+16a^2c^3+66a^2c^2+84a^2c+33a^2+4ab^3c^3+12ab^3c^2+12ab^3c+4ab^3+ab^2c^3+9ab^2c^2+9ab^2c+2ab^2+4ac^3+ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+43b^2c+16b^2+bc^3+10c^3+11c^2 $$" + "$$ 0 \\le 4 p^{5} r^{3}+12 p^{5} r^{2}+12 p^{5} r+4 p^{5}+4 p^{4} q r^{3}+12 p^{4} q r^{2}+12 p^{4} q r+4 p^{4} q+18 p^{4} r^{3}+58 p^{4} r^{2}+62 p^{4} r+22 p^{4}+12 p^{3} q r^{3}+36 p^{3} q r^{2}+36 p^{3} q r+10 p^{3} q+28 p^{3} r^{3}+98 p^{3} r^{2}+112 p^{3} r+42 p^{3}+11 p^{2} q r^{3}+36 p^{2} q r^{2}+36 p^{2} q r+12 p^{2} q+16 p^{2} r^{3}+66 p^{2} r^{2}+84 p^{2} r+33 p^{2}+4 p q^{3} r^{3}+12 p q^{3} r^{2}+12 p q^{3} r+4 p q^{3}+p q^{2} r^{3}+9 p q^{2} r^{2}+9 p q^{2} r+2 p q^{2}+4 p r^{3}+p r^{2}+4 q^{4} r^{3}+12 q^{4} r^{2}+12 q^{4} r+4 q^{4}+14 q^{3} r^{3}+46 q^{3} r^{2}+50 q^{3} r+18 q^{3}+9 q^{2} r^{3}+36 q^{2} r^{2}+43 q^{2} r+16 q^{2}+q r^{3}+10 r^{3}+11 r^{2} $$" ], "text/plain": [ "" @@ -2849,8 +3119,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2862,7 +3131,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1+b,c\\to 1/(1+c)$" + "Substitute $a\\to 1/(1+s),b\\to 1+t,c\\to 1/(1+u)$" ], "text/plain": [ "" @@ -2874,7 +3143,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+10a^5b^3c^3+34a^5b^3c^2+38a^5b^3c+14a^5b^3+6a^5b^2c^3+27a^5b^2c^2+36a^5b^2c+15a^5b^2+8a^5bc^3+18a^5bc^2+16a^5bc+6a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+20a^4b^4c^3+60a^4b^4c^2+60a^4b^4c+20a^4b^4+54a^4b^3c^3+182a^4b^3c^2+202a^4b^3c+74a^4b^3+33a^4b^2c^3+144a^4b^2c^2+189a^4b^2c+78a^4b^2+34a^4bc^3+72a^4bc^2+62a^4bc+24a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+40a^3b^4c^3+120a^3b^4c^2+120a^3b^4c+40a^3b^4+116a^3b^3c^3+388a^3b^3c^2+428a^3b^3c+156a^3b^3+72a^3b^2c^3+306a^3b^2c^2+396a^3b^2c+162a^3b^2+56a^3bc^3+108a^3bc^2+88a^3bc+36a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+40a^2b^4c^3+120a^2b^4c^2+120a^2b^4c+40a^2b^4+124a^2b^3c^3+412a^2b^3c^2+452a^2b^3c+164a^2b^3+78a^2b^2c^3+324a^2b^2c^2+414a^2b^2c+168a^2b^2+40a^2bc^3+60a^2bc^2+40a^2bc+20a^2b+100a^2c^3+190a^2c^2+84a^2c+34a^2+20ab^4c^3+60ab^4c^2+60ab^4c+20ab^4+66ab^3c^3+218ab^3c^2+238ab^3c+86ab^3+42ab^2c^3+171ab^2c^2+216ab^2c+87ab^2+12abc^3+6abc^2-4abc+2ab+46ac^3+66ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+18b^2+2bc^3-2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 s^{5} t^{4} u^{3} + 12 s^{5} t^{4} u^{2} + 12 s^{5} t^{4} u + 4 s^{5} t^{4} + 10 s^{5} t^{3} u^{3} + 34 s^{5} t^{3} u^{2} + 38 s^{5} t^{3} u + 14 s^{5} t^{3} + 6 s^{5} t^{2} u^{3} + 27 s^{5} t^{2} u^{2} + 36 s^{5} t^{2} u + 15 s^{5} t^{2} + 8 s^{5} t u^{3} + 18 s^{5} t u^{2} + 16 s^{5} t u + 6 s^{5} t + 8 s^{5} u^{3} + 24 s^{5} u^{2} + 22 s^{5} u + 10 s^{5} + 20 s^{4} t^{4} u^{3} + 60 s^{4} t^{4} u^{2} + 60 s^{4} t^{4} u + 20 s^{4} t^{4} + 54 s^{4} t^{3} u^{3} + 182 s^{4} t^{3} u^{2} + 202 s^{4} t^{3} u + 74 s^{4} t^{3} + 33 s^{4} t^{2} u^{3} + 144 s^{4} t^{2} u^{2} + 189 s^{4} t^{2} u + 78 s^{4} t^{2} + 34 s^{4} t u^{3} + 72 s^{4} t u^{2} + 62 s^{4} t u + 24 s^{4} t + 44 s^{4} u^{3} + 114 s^{4} u^{2} + 90 s^{4} u + 40 s^{4} + 40 s^{3} t^{4} u^{3} + 120 s^{3} t^{4} u^{2} + 120 s^{3} t^{4} u + 40 s^{3} t^{4} + 116 s^{3} t^{3} u^{3} + 388 s^{3} t^{3} u^{2} + 428 s^{3} t^{3} u + 156 s^{3} t^{3} + 72 s^{3} t^{2} u^{3} + 306 s^{3} t^{2} u^{2} + 396 s^{3} t^{2} u + 162 s^{3} t^{2} + 56 s^{3} t u^{3} + 108 s^{3} t u^{2} + 88 s^{3} t u + 36 s^{3} t + 96 s^{3} u^{3} + 216 s^{3} u^{2} + 140 s^{3} u + 60 s^{3} + 40 s^{2} t^{4} u^{3} + 120 s^{2} t^{4} u^{2} + 120 s^{2} t^{4} u + 40 s^{2} t^{4} + 124 s^{2} t^{3} u^{3} + 412 s^{2} t^{3} u^{2} + 452 s^{2} t^{3} u + 164 s^{2} t^{3} + 78 s^{2} t^{2} u^{3} + 324 s^{2} t^{2} u^{2} + 414 s^{2} t^{2} u + 168 s^{2} t^{2} + 40 s^{2} t u^{3} + 60 s^{2} t u^{2} + 40 s^{2} t u + 20 s^{2} t + 100 s^{2} u^{3} + 190 s^{2} u^{2} + 84 s^{2} u + 34 s^{2} + 20 s t^{4} u^{3} + 60 s t^{4} u^{2} + 60 s t^{4} u + 20 s t^{4} + 66 s t^{3} u^{3} + 218 s t^{3} u^{2} + 238 s t^{3} u + 86 s t^{3} + 42 s t^{2} u^{3} + 171 s t^{2} u^{2} + 216 s t^{2} u + 87 s t^{2} + 12 s t u^{3} + 6 s t u^{2} - 4 s t u + 2 s t + 46 s u^{3} + 66 s u^{2} + 4 t^{4} u^{3} + 12 t^{4} u^{2} + 12 t^{4} u + 4 t^{4} + 14 t^{3} u^{3} + 46 t^{3} u^{2} + 50 t^{3} u + 18 t^{3} + 9 t^{2} u^{3} + 36 t^{2} u^{2} + 45 t^{2} u + 18 t^{2} + 2 t u^{3} - 2 t u + 10 u^{3} + 14 u^{2}$" ], "text/plain": [ "" @@ -2910,7 +3179,7 @@ { "data": { "text/latex": [ - "$$4abc \\le a^2c^2+2ab^2+c^2$$" + "$$4 s t u \\le s^{2} u^{2}+2 s t^{2}+u^{2}$$" ], "text/plain": [ "" @@ -2922,7 +3191,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 t u \\le t^{2}+u^{2}$$" ], "text/plain": [ "" @@ -2934,7 +3203,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+10a^5b^3c^3+34a^5b^3c^2+38a^5b^3c+14a^5b^3+6a^5b^2c^3+27a^5b^2c^2+36a^5b^2c+15a^5b^2+8a^5bc^3+18a^5bc^2+16a^5bc+6a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+20a^4b^4c^3+60a^4b^4c^2+60a^4b^4c+20a^4b^4+54a^4b^3c^3+182a^4b^3c^2+202a^4b^3c+74a^4b^3+33a^4b^2c^3+144a^4b^2c^2+189a^4b^2c+78a^4b^2+34a^4bc^3+72a^4bc^2+62a^4bc+24a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+40a^3b^4c^3+120a^3b^4c^2+120a^3b^4c+40a^3b^4+116a^3b^3c^3+388a^3b^3c^2+428a^3b^3c+156a^3b^3+72a^3b^2c^3+306a^3b^2c^2+396a^3b^2c+162a^3b^2+56a^3bc^3+108a^3bc^2+88a^3bc+36a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+40a^2b^4c^3+120a^2b^4c^2+120a^2b^4c+40a^2b^4+124a^2b^3c^3+412a^2b^3c^2+452a^2b^3c+164a^2b^3+78a^2b^2c^3+324a^2b^2c^2+414a^2b^2c+168a^2b^2+40a^2bc^3+60a^2bc^2+40a^2bc+20a^2b+100a^2c^3+189a^2c^2+84a^2c+34a^2+20ab^4c^3+60ab^4c^2+60ab^4c+20ab^4+66ab^3c^3+218ab^3c^2+238ab^3c+86ab^3+42ab^2c^3+171ab^2c^2+216ab^2c+85ab^2+12abc^3+6abc^2+2ab+46ac^3+66ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+17b^2+2bc^3+10c^3+12c^2 $$" + "$$ 0 \\le 4 s^{5} t^{4} u^{3}+12 s^{5} t^{4} u^{2}+12 s^{5} t^{4} u+4 s^{5} t^{4}+10 s^{5} t^{3} u^{3}+34 s^{5} t^{3} u^{2}+38 s^{5} t^{3} u+14 s^{5} t^{3}+6 s^{5} t^{2} u^{3}+27 s^{5} t^{2} u^{2}+36 s^{5} t^{2} u+15 s^{5} t^{2}+8 s^{5} t u^{3}+18 s^{5} t u^{2}+16 s^{5} t u+6 s^{5} t+8 s^{5} u^{3}+24 s^{5} u^{2}+22 s^{5} u+10 s^{5}+20 s^{4} t^{4} u^{3}+60 s^{4} t^{4} u^{2}+60 s^{4} t^{4} u+20 s^{4} t^{4}+54 s^{4} t^{3} u^{3}+182 s^{4} t^{3} u^{2}+202 s^{4} t^{3} u+74 s^{4} t^{3}+33 s^{4} t^{2} u^{3}+144 s^{4} t^{2} u^{2}+189 s^{4} t^{2} u+78 s^{4} t^{2}+34 s^{4} t u^{3}+72 s^{4} t u^{2}+62 s^{4} t u+24 s^{4} t+44 s^{4} u^{3}+114 s^{4} u^{2}+90 s^{4} u+40 s^{4}+40 s^{3} t^{4} u^{3}+120 s^{3} t^{4} u^{2}+120 s^{3} t^{4} u+40 s^{3} t^{4}+116 s^{3} t^{3} u^{3}+388 s^{3} t^{3} u^{2}+428 s^{3} t^{3} u+156 s^{3} t^{3}+72 s^{3} t^{2} u^{3}+306 s^{3} t^{2} u^{2}+396 s^{3} t^{2} u+162 s^{3} t^{2}+56 s^{3} t u^{3}+108 s^{3} t u^{2}+88 s^{3} t u+36 s^{3} t+96 s^{3} u^{3}+216 s^{3} u^{2}+140 s^{3} u+60 s^{3}+40 s^{2} t^{4} u^{3}+120 s^{2} t^{4} u^{2}+120 s^{2} t^{4} u+40 s^{2} t^{4}+124 s^{2} t^{3} u^{3}+412 s^{2} t^{3} u^{2}+452 s^{2} t^{3} u+164 s^{2} t^{3}+78 s^{2} t^{2} u^{3}+324 s^{2} t^{2} u^{2}+414 s^{2} t^{2} u+168 s^{2} t^{2}+40 s^{2} t u^{3}+60 s^{2} t u^{2}+40 s^{2} t u+20 s^{2} t+100 s^{2} u^{3}+189 s^{2} u^{2}+84 s^{2} u+34 s^{2}+20 s t^{4} u^{3}+60 s t^{4} u^{2}+60 s t^{4} u+20 s t^{4}+66 s t^{3} u^{3}+218 s t^{3} u^{2}+238 s t^{3} u+86 s t^{3}+42 s t^{2} u^{3}+171 s t^{2} u^{2}+216 s t^{2} u+85 s t^{2}+12 s t u^{3}+6 s t u^{2}+2 s t+46 s u^{3}+66 s u^{2}+4 t^{4} u^{3}+12 t^{4} u^{2}+12 t^{4} u+4 t^{4}+14 t^{3} u^{3}+46 t^{3} u^{2}+50 t^{3} u+18 t^{3}+9 t^{2} u^{3}+36 t^{2} u^{2}+45 t^{2} u+17 t^{2}+2 t u^{3}+10 u^{3}+12 u^{2} $$" ], "text/plain": [ "" @@ -2958,8 +3227,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2971,7 +3239,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1/(1+b),c\\to 1/(1+c)$" + "Substitute $a\\to 1+v,b\\to 1/(1+w),c\\to 1/(1+x)$" ], "text/plain": [ "" @@ -2983,7 +3251,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+16a^5b^3c^3+48a^5b^3c^2+48a^5b^3c+16a^5b^3+24a^5b^2c^3+72a^5b^2c^2+72a^5b^2c+24a^5b^2+16a^5bc^3+48a^5bc^2+48a^5bc+16a^5b+4a^5c^3+12a^5c^2+12a^5c+4a^5+14a^4b^4c^3+46a^4b^4c^2+50a^4b^4c+18a^4b^4+60a^4b^3c^3+196a^4b^3c^2+212a^4b^3c+76a^4b^3+96a^4b^2c^3+312a^4b^2c^2+336a^4b^2c+120a^4b^2+68a^4bc^3+220a^4bc^2+236a^4bc+84a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+16a^3b^4c^3+62a^3b^4c^2+76a^3b^4c+30a^3b^4+76a^3b^3c^3+284a^3b^3c^2+340a^3b^3c+132a^3b^3+132a^3b^2c^3+480a^3b^2c^2+564a^3b^2c+216a^3b^2+100a^3bc^3+356a^3bc^2+412a^3bc+156a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+4a^2b^4c^3+30a^2b^4c^2+48a^2b^4c+22a^2b^4+28a^2b^3c^3+156a^2b^3c^2+228a^2b^3c+100a^2b^3+60a^2b^2c^3+288a^2b^2c^2+396a^2b^2c+168a^2b^2+52a^2bc^3+228a^2bc^2+300a^2bc+124a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+5ab^4c^3+7ab^4c^2+3ab^4c+ab^4+24ab^3c^3+40ab^3c^2+24ab^3c+8ab^3+33ab^2c^3+51ab^2c^2+27ab^2c+9ab^2+18abc^3+22abc^2+6abc+2ab+4ac^3+4ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 v^{5} w^{4} x^{3} + 12 v^{5} w^{4} x^{2} + 12 v^{5} w^{4} x + 4 v^{5} w^{4} + 16 v^{5} w^{3} x^{3} + 48 v^{5} w^{3} x^{2} + 48 v^{5} w^{3} x + 16 v^{5} w^{3} + 24 v^{5} w^{2} x^{3} + 72 v^{5} w^{2} x^{2} + 72 v^{5} w^{2} x + 24 v^{5} w^{2} + 16 v^{5} w x^{3} + 48 v^{5} w x^{2} + 48 v^{5} w x + 16 v^{5} w + 4 v^{5} x^{3} + 12 v^{5} x^{2} + 12 v^{5} x + 4 v^{5} + 14 v^{4} w^{4} x^{3} + 46 v^{4} w^{4} x^{2} + 50 v^{4} w^{4} x + 18 v^{4} w^{4} + 60 v^{4} w^{3} x^{3} + 196 v^{4} w^{3} x^{2} + 212 v^{4} w^{3} x + 76 v^{4} w^{3} + 96 v^{4} w^{2} x^{3} + 312 v^{4} w^{2} x^{2} + 336 v^{4} w^{2} x + 120 v^{4} w^{2} + 68 v^{4} w x^{3} + 220 v^{4} w x^{2} + 236 v^{4} w x + 84 v^{4} w + 18 v^{4} x^{3} + 58 v^{4} x^{2} + 62 v^{4} x + 22 v^{4} + 16 v^{3} w^{4} x^{3} + 62 v^{3} w^{4} x^{2} + 76 v^{3} w^{4} x + 30 v^{3} w^{4} + 76 v^{3} w^{3} x^{3} + 284 v^{3} w^{3} x^{2} + 340 v^{3} w^{3} x + 132 v^{3} w^{3} + 132 v^{3} w^{2} x^{3} + 480 v^{3} w^{2} x^{2} + 564 v^{3} w^{2} x + 216 v^{3} w^{2} + 100 v^{3} w x^{3} + 356 v^{3} w x^{2} + 412 v^{3} w x + 156 v^{3} w + 28 v^{3} x^{3} + 98 v^{3} x^{2} + 112 v^{3} x + 42 v^{3} + 4 v^{2} w^{4} x^{3} + 30 v^{2} w^{4} x^{2} + 48 v^{2} w^{4} x + 22 v^{2} w^{4} + 28 v^{2} w^{3} x^{3} + 156 v^{2} w^{3} x^{2} + 228 v^{2} w^{3} x + 100 v^{2} w^{3} + 60 v^{2} w^{2} x^{3} + 288 v^{2} w^{2} x^{2} + 396 v^{2} w^{2} x + 168 v^{2} w^{2} + 52 v^{2} w x^{3} + 228 v^{2} w x^{2} + 300 v^{2} w x + 124 v^{2} w + 16 v^{2} x^{3} + 66 v^{2} x^{2} + 84 v^{2} x + 34 v^{2} + 5 v w^{4} x^{3} + 7 v w^{4} x^{2} + 3 v w^{4} x + v w^{4} + 24 v w^{3} x^{3} + 40 v w^{3} x^{2} + 24 v w^{3} x + 8 v w^{3} + 33 v w^{2} x^{3} + 51 v w^{2} x^{2} + 27 v w^{2} x + 9 v w^{2} + 18 v w x^{3} + 22 v w x^{2} + 6 v w x + 2 v w + 4 v x^{3} + 4 v x^{2} + 7 w^{4} x^{3} + 16 w^{4} x^{2} + 9 w^{4} x + 4 w^{4} + 38 w^{3} x^{3} + 82 w^{3} x^{2} + 46 w^{3} x + 18 w^{3} + 63 w^{2} x^{3} + 120 w^{2} x^{2} + 51 w^{2} x + 18 w^{2} + 38 w x^{3} + 56 w x^{2} + 2 w x + 10 x^{3} + 14 x^{2}$" ], "text/plain": [ "" @@ -3007,7 +3275,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+16a^5b^3c^3+48a^5b^3c^2+48a^5b^3c+16a^5b^3+24a^5b^2c^3+72a^5b^2c^2+72a^5b^2c+24a^5b^2+16a^5bc^3+48a^5bc^2+48a^5bc+16a^5b+4a^5c^3+12a^5c^2+12a^5c+4a^5+14a^4b^4c^3+46a^4b^4c^2+50a^4b^4c+18a^4b^4+60a^4b^3c^3+196a^4b^3c^2+212a^4b^3c+76a^4b^3+96a^4b^2c^3+312a^4b^2c^2+336a^4b^2c+120a^4b^2+68a^4bc^3+220a^4bc^2+236a^4bc+84a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+16a^3b^4c^3+62a^3b^4c^2+76a^3b^4c+30a^3b^4+76a^3b^3c^3+284a^3b^3c^2+340a^3b^3c+132a^3b^3+132a^3b^2c^3+480a^3b^2c^2+564a^3b^2c+216a^3b^2+100a^3bc^3+356a^3bc^2+412a^3bc+156a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+4a^2b^4c^3+30a^2b^4c^2+48a^2b^4c+22a^2b^4+28a^2b^3c^3+156a^2b^3c^2+228a^2b^3c+100a^2b^3+60a^2b^2c^3+288a^2b^2c^2+396a^2b^2c+168a^2b^2+52a^2bc^3+228a^2bc^2+300a^2bc+124a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+5ab^4c^3+7ab^4c^2+3ab^4c+ab^4+24ab^3c^3+40ab^3c^2+24ab^3c+8ab^3+33ab^2c^3+51ab^2c^2+27ab^2c+9ab^2+18abc^3+22abc^2+6abc+2ab+4ac^3+4ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2 $$" + "$$ 0 \\le 4 v^{5} w^{4} x^{3}+16 v^{5} w^{3} x^{3}+24 v^{5} w^{2} x^{3}+16 v^{5} w x^{3}+4 v^{5} x^{3}+14 v^{4} w^{4} x^{3}+60 v^{4} w^{3} x^{3}+96 v^{4} w^{2} x^{3}+68 v^{4} w x^{3}+18 v^{4} x^{3}+16 v^{3} w^{4} x^{3}+76 v^{3} w^{3} x^{3}+132 v^{3} w^{2} x^{3}+100 v^{3} w x^{3}+28 v^{3} x^{3}+4 v^{2} w^{4} x^{3}+28 v^{2} w^{3} x^{3}+60 v^{2} w^{2} x^{3}+52 v^{2} w x^{3}+16 v^{2} x^{3}+5 v w^{4} x^{3}+24 v w^{3} x^{3}+33 v w^{2} x^{3}+18 v w x^{3}+4 v x^{3}+7 w^{4} x^{3}+38 w^{3} x^{3}+63 w^{2} x^{3}+38 w x^{3}+10 x^{3}+12 v^{5} w^{4} x^{2}+48 v^{5} w^{3} x^{2}+72 v^{5} w^{2} x^{2}+48 v^{5} w x^{2}+12 v^{5} x^{2}+46 v^{4} w^{4} x^{2}+196 v^{4} w^{3} x^{2}+312 v^{4} w^{2} x^{2}+220 v^{4} w x^{2}+58 v^{4} x^{2}+62 v^{3} w^{4} x^{2}+284 v^{3} w^{3} x^{2}+480 v^{3} w^{2} x^{2}+356 v^{3} w x^{2}+98 v^{3} x^{2}+30 v^{2} w^{4} x^{2}+156 v^{2} w^{3} x^{2}+288 v^{2} w^{2} x^{2}+228 v^{2} w x^{2}+66 v^{2} x^{2}+7 v w^{4} x^{2}+40 v w^{3} x^{2}+51 v w^{2} x^{2}+22 v w x^{2}+4 v x^{2}+16 w^{4} x^{2}+82 w^{3} x^{2}+120 w^{2} x^{2}+56 w x^{2}+14 x^{2}+12 v^{5} w^{4} x+48 v^{5} w^{3} x+72 v^{5} w^{2} x+48 v^{5} w x+12 v^{5} x+50 v^{4} w^{4} x+212 v^{4} w^{3} x+336 v^{4} w^{2} x+236 v^{4} w x+62 v^{4} x+76 v^{3} w^{4} x+340 v^{3} w^{3} x+564 v^{3} w^{2} x+412 v^{3} w x+112 v^{3} x+48 v^{2} w^{4} x+228 v^{2} w^{3} x+396 v^{2} w^{2} x+300 v^{2} w x+84 v^{2} x+3 v w^{4} x+24 v w^{3} x+27 v w^{2} x+6 v w x+9 w^{4} x+46 w^{3} x+51 w^{2} x+2 w x+4 v^{5} w^{4}+16 v^{5} w^{3}+24 v^{5} w^{2}+16 v^{5} w+4 v^{5}+18 v^{4} w^{4}+76 v^{4} w^{3}+120 v^{4} w^{2}+84 v^{4} w+22 v^{4}+30 v^{3} w^{4}+132 v^{3} w^{3}+216 v^{3} w^{2}+156 v^{3} w+42 v^{3}+22 v^{2} w^{4}+100 v^{2} w^{3}+168 v^{2} w^{2}+124 v^{2} w+34 v^{2}+v w^{4}+8 v w^{3}+9 v w^{2}+2 v w+4 w^{4}+18 w^{3}+18 w^{2} $$" ], "text/plain": [ "" @@ -3031,8 +3299,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -3044,7 +3311,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1/(1+b),c\\to 1/(1+c)$" + "Substitute $a\\to 1/(1+y),b\\to 1/(1+z),c\\to 1/(1+a_{1})$" ], "text/plain": [ "" @@ -3056,7 +3323,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $11a^5b^4c^2+16a^5b^4c+9a^5b^4+10a^5b^3c^3+62a^5b^3c^2+74a^5b^3c+38a^5b^3+30a^5b^2c^3+117a^5b^2c^2+120a^5b^2c+57a^5b^2+24a^5bc^3+78a^5bc^2+72a^5bc+34a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+9a^4b^4c^3+64a^4b^4c^2+75a^4b^4c+40a^4b^4+86a^4b^3c^3+346a^4b^3c^2+350a^4b^3c+170a^4b^3+195a^4b^2c^3+612a^4b^2c^2+543a^4b^2c+246a^4b^2+142a^4bc^3+384a^4bc^2+298a^4bc+136a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+36a^3b^4c^3+146a^3b^4c^2+140a^3b^4c+70a^3b^4+244a^3b^3c^3+764a^3b^3c^2+660a^3b^3c+300a^3b^3+480a^3b^2c^3+1278a^3b^2c^2+972a^3b^2c+414a^3b^2+328a^3bc^3+756a^3bc^2+472a^3bc+204a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+54a^2b^4c^3+162a^2b^4c^2+126a^2b^4c+58a^2b^4+312a^2b^3c^3+816a^2b^3c^2+592a^2b^3c+248a^2b^3+558a^2b^2c^3+1284a^2b^2c^2+798a^2b^2c+312a^2b^2+360a^2bc^3+700a^2bc^2+296a^2bc+116a^2b+100a^2c^3+190a^2c^2+84a^2c+34a^2+30ab^4c^3+73ab^4c^2+42ab^4c+19ab^4+166ab^3c^3+370ab^3c^2+206ab^3c+82ab^3+282ab^2c^3+549ab^2c^2+228ab^2c+81ab^2+172abc^3+258abc^2+4abc-2ab+46ac^3+66ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2$" + "Numerator after substitutions: $10 a_{1}^{3} y^{5} z^{3} + 30 a_{1}^{3} y^{5} z^{2} + 24 a_{1}^{3} y^{5} z + 8 a_{1}^{3} y^{5} + 9 a_{1}^{3} y^{4} z^{4} + 86 a_{1}^{3} y^{4} z^{3} + 195 a_{1}^{3} y^{4} z^{2} + 142 a_{1}^{3} y^{4} z + 44 a_{1}^{3} y^{4} + 36 a_{1}^{3} y^{3} z^{4} + 244 a_{1}^{3} y^{3} z^{3} + 480 a_{1}^{3} y^{3} z^{2} + 328 a_{1}^{3} y^{3} z + 96 a_{1}^{3} y^{3} + 54 a_{1}^{3} y^{2} z^{4} + 312 a_{1}^{3} y^{2} z^{3} + 558 a_{1}^{3} y^{2} z^{2} + 360 a_{1}^{3} y^{2} z + 100 a_{1}^{3} y^{2} + 30 a_{1}^{3} y z^{4} + 166 a_{1}^{3} y z^{3} + 282 a_{1}^{3} y z^{2} + 172 a_{1}^{3} y z + 46 a_{1}^{3} y + 7 a_{1}^{3} z^{4} + 38 a_{1}^{3} z^{3} + 63 a_{1}^{3} z^{2} + 38 a_{1}^{3} z + 10 a_{1}^{3} + 11 a_{1}^{2} y^{5} z^{4} + 62 a_{1}^{2} y^{5} z^{3} + 117 a_{1}^{2} y^{5} z^{2} + 78 a_{1}^{2} y^{5} z + 24 a_{1}^{2} y^{5} + 64 a_{1}^{2} y^{4} z^{4} + 346 a_{1}^{2} y^{4} z^{3} + 612 a_{1}^{2} y^{4} z^{2} + 384 a_{1}^{2} y^{4} z + 114 a_{1}^{2} y^{4} + 146 a_{1}^{2} y^{3} z^{4} + 764 a_{1}^{2} y^{3} z^{3} + 1278 a_{1}^{2} y^{3} z^{2} + 756 a_{1}^{2} y^{3} z + 216 a_{1}^{2} y^{3} + 162 a_{1}^{2} y^{2} z^{4} + 816 a_{1}^{2} y^{2} z^{3} + 1284 a_{1}^{2} y^{2} z^{2} + 700 a_{1}^{2} y^{2} z + 190 a_{1}^{2} y^{2} + 73 a_{1}^{2} y z^{4} + 370 a_{1}^{2} y z^{3} + 549 a_{1}^{2} y z^{2} + 258 a_{1}^{2} y z + 66 a_{1}^{2} y + 16 a_{1}^{2} z^{4} + 82 a_{1}^{2} z^{3} + 120 a_{1}^{2} z^{2} + 56 a_{1}^{2} z + 14 a_{1}^{2} + 16 a_{1} y^{5} z^{4} + 74 a_{1} y^{5} z^{3} + 120 a_{1} y^{5} z^{2} + 72 a_{1} y^{5} z + 22 a_{1} y^{5} + 75 a_{1} y^{4} z^{4} + 350 a_{1} y^{4} z^{3} + 543 a_{1} y^{4} z^{2} + 298 a_{1} y^{4} z + 90 a_{1} y^{4} + 140 a_{1} y^{3} z^{4} + 660 a_{1} y^{3} z^{3} + 972 a_{1} y^{3} z^{2} + 472 a_{1} y^{3} z + 140 a_{1} y^{3} + 126 a_{1} y^{2} z^{4} + 592 a_{1} y^{2} z^{3} + 798 a_{1} y^{2} z^{2} + 296 a_{1} y^{2} z + 84 a_{1} y^{2} + 42 a_{1} y z^{4} + 206 a_{1} y z^{3} + 228 a_{1} y z^{2} + 4 a_{1} y z + 9 a_{1} z^{4} + 46 a_{1} z^{3} + 51 a_{1} z^{2} + 2 a_{1} z + 9 y^{5} z^{4} + 38 y^{5} z^{3} + 57 y^{5} z^{2} + 34 y^{5} z + 10 y^{5} + 40 y^{4} z^{4} + 170 y^{4} z^{3} + 246 y^{4} z^{2} + 136 y^{4} z + 40 y^{4} + 70 y^{3} z^{4} + 300 y^{3} z^{3} + 414 y^{3} z^{2} + 204 y^{3} z + 60 y^{3} + 58 y^{2} z^{4} + 248 y^{2} z^{3} + 312 y^{2} z^{2} + 116 y^{2} z + 34 y^{2} + 19 y z^{4} + 82 y z^{3} + 81 y z^{2} - 2 y z + 4 z^{4} + 18 z^{3} + 18 z^{2}$" ], "text/plain": [ "" @@ -3092,7 +3359,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 y z \\le y^{2}+z^{2}$$" ], "text/plain": [ "" @@ -3104,7 +3371,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 11a^5b^4c^2+16a^5b^4c+9a^5b^4+10a^5b^3c^3+62a^5b^3c^2+74a^5b^3c+38a^5b^3+30a^5b^2c^3+117a^5b^2c^2+120a^5b^2c+57a^5b^2+24a^5bc^3+78a^5bc^2+72a^5bc+34a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+9a^4b^4c^3+64a^4b^4c^2+75a^4b^4c+40a^4b^4+86a^4b^3c^3+346a^4b^3c^2+350a^4b^3c+170a^4b^3+195a^4b^2c^3+612a^4b^2c^2+543a^4b^2c+246a^4b^2+142a^4bc^3+384a^4bc^2+298a^4bc+136a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+36a^3b^4c^3+146a^3b^4c^2+140a^3b^4c+70a^3b^4+244a^3b^3c^3+764a^3b^3c^2+660a^3b^3c+300a^3b^3+480a^3b^2c^3+1278a^3b^2c^2+972a^3b^2c+414a^3b^2+328a^3bc^3+756a^3bc^2+472a^3bc+204a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+54a^2b^4c^3+162a^2b^4c^2+126a^2b^4c+58a^2b^4+312a^2b^3c^3+816a^2b^3c^2+592a^2b^3c+248a^2b^3+558a^2b^2c^3+1284a^2b^2c^2+798a^2b^2c+312a^2b^2+360a^2bc^3+700a^2bc^2+296a^2bc+116a^2b+100a^2c^3+190a^2c^2+84a^2c+33a^2+30ab^4c^3+73ab^4c^2+42ab^4c+19ab^4+166ab^3c^3+370ab^3c^2+206ab^3c+82ab^3+282ab^2c^3+549ab^2c^2+228ab^2c+81ab^2+172abc^3+258abc^2+4abc+46ac^3+66ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+17b^2+38bc^3+56bc^2+2bc+10c^3+14c^2 $$" + "$$ 0 \\le 11 a_{1}^{2} y^{5} z^{4}+16 a_{1} y^{5} z^{4}+9 y^{5} z^{4}+10 a_{1}^{3} y^{5} z^{3}+62 a_{1}^{2} y^{5} z^{3}+74 a_{1} y^{5} z^{3}+38 y^{5} z^{3}+30 a_{1}^{3} y^{5} z^{2}+117 a_{1}^{2} y^{5} z^{2}+120 a_{1} y^{5} z^{2}+57 y^{5} z^{2}+24 a_{1}^{3} y^{5} z+78 a_{1}^{2} y^{5} z+72 a_{1} y^{5} z+34 y^{5} z+8 a_{1}^{3} y^{5}+24 a_{1}^{2} y^{5}+22 a_{1} y^{5}+10 y^{5}+9 a_{1}^{3} y^{4} z^{4}+64 a_{1}^{2} y^{4} z^{4}+75 a_{1} y^{4} z^{4}+40 y^{4} z^{4}+86 a_{1}^{3} y^{4} z^{3}+346 a_{1}^{2} y^{4} z^{3}+350 a_{1} y^{4} z^{3}+170 y^{4} z^{3}+195 a_{1}^{3} y^{4} z^{2}+612 a_{1}^{2} y^{4} z^{2}+543 a_{1} y^{4} z^{2}+246 y^{4} z^{2}+142 a_{1}^{3} y^{4} z+384 a_{1}^{2} y^{4} z+298 a_{1} y^{4} z+136 y^{4} z+44 a_{1}^{3} y^{4}+114 a_{1}^{2} y^{4}+90 a_{1} y^{4}+40 y^{4}+36 a_{1}^{3} y^{3} z^{4}+146 a_{1}^{2} y^{3} z^{4}+140 a_{1} y^{3} z^{4}+70 y^{3} z^{4}+244 a_{1}^{3} y^{3} z^{3}+764 a_{1}^{2} y^{3} z^{3}+660 a_{1} y^{3} z^{3}+300 y^{3} z^{3}+480 a_{1}^{3} y^{3} z^{2}+1278 a_{1}^{2} y^{3} z^{2}+972 a_{1} y^{3} z^{2}+414 y^{3} z^{2}+328 a_{1}^{3} y^{3} z+756 a_{1}^{2} y^{3} z+472 a_{1} y^{3} z+204 y^{3} z+96 a_{1}^{3} y^{3}+216 a_{1}^{2} y^{3}+140 a_{1} y^{3}+60 y^{3}+54 a_{1}^{3} y^{2} z^{4}+162 a_{1}^{2} y^{2} z^{4}+126 a_{1} y^{2} z^{4}+58 y^{2} z^{4}+312 a_{1}^{3} y^{2} z^{3}+816 a_{1}^{2} y^{2} z^{3}+592 a_{1} y^{2} z^{3}+248 y^{2} z^{3}+558 a_{1}^{3} y^{2} z^{2}+1284 a_{1}^{2} y^{2} z^{2}+798 a_{1} y^{2} z^{2}+312 y^{2} z^{2}+360 a_{1}^{3} y^{2} z+700 a_{1}^{2} y^{2} z+296 a_{1} y^{2} z+116 y^{2} z+100 a_{1}^{3} y^{2}+190 a_{1}^{2} y^{2}+84 a_{1} y^{2}+33 y^{2}+30 a_{1}^{3} y z^{4}+73 a_{1}^{2} y z^{4}+42 a_{1} y z^{4}+19 y z^{4}+166 a_{1}^{3} y z^{3}+370 a_{1}^{2} y z^{3}+206 a_{1} y z^{3}+82 y z^{3}+282 a_{1}^{3} y z^{2}+549 a_{1}^{2} y z^{2}+228 a_{1} y z^{2}+81 y z^{2}+172 a_{1}^{3} y z+258 a_{1}^{2} y z+4 a_{1} y z+46 a_{1}^{3} y+66 a_{1}^{2} y+7 a_{1}^{3} z^{4}+16 a_{1}^{2} z^{4}+9 a_{1} z^{4}+4 z^{4}+38 a_{1}^{3} z^{3}+82 a_{1}^{2} z^{3}+46 a_{1} z^{3}+18 z^{3}+63 a_{1}^{3} z^{2}+120 a_{1}^{2} z^{2}+51 a_{1} z^{2}+17 z^{2}+38 a_{1}^{3} z+56 a_{1}^{2} z+2 a_{1} z+10 a_{1}^{3}+14 a_{1}^{2} $$" ], "text/plain": [ "" @@ -3124,9 +3391,20 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Counter({0: 8})" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ + "newproof()\n", "formula=Sm('-(3a + 2b + c)(2a^3 + 3b^2 + 6c + 1) + (4a + 4b + 4c)(a^4 + b^3 + c^2 + 3)')\n", "powerprove(formula)" ] @@ -3145,13 +3423,13 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $21f(-1,4,3)-21f(1,2,3)-21f(2,3,1)+21f(3,-1,4)-21f(3,1,2)+21f(4,3,-1)$" + "numerator: $21 f{\\left(-1,4,3 \\right)} - 21 f{\\left(1,2,3 \\right)} - 21 f{\\left(2,3,1 \\right)} + 21 f{\\left(3,-1,4 \\right)} - 21 f{\\left(3,1,2 \\right)} + 21 f{\\left(4,3,-1 \\right)}$" ], "text/plain": [ "" @@ -3255,18 +3533,575 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ "provef('(-f(1,2,3)-f(2,3,1)-f(3,1,2)+f(4,3,-1)+f(3,-1,4)+f(-1,4,3))*21')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's try to solve problem 6 from the finals of LXIII Polish Mathematical Olympiad. It was one of the hardest inequality in the history of this contest, solved only by 3 finalists.\n", + "\n", + "#### Problem\n", + "Prove the inequality\n", + "$$\\left(\\frac{a - b}{c}\\right)^2 + \\left(\\frac{b - c}{a}\\right)^2 + \\left(\\frac{c - a}{b}\\right)^2\\ge 2 \\sqrt{2} \\left(\\frac{a - b}{c} + \\frac{b - c}{a}+ \\frac{c-a}{b}\\right)$$\n", + "for any positive numbers $a,b,c$.\n", + "\n", + "The first observation is that the formula is cyclic, so without loss of generality we may assume that $a\\ge b,c$. We can go a step further and divide it into two cases: $a\\ge b\\ge c$ and $a\\ge c\\ge b$." + ] + }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "shiro.display=lambda x:None #turn off printing of proofs\n", + "newproof()\n", + "formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula1=makesubs(formula,'[b,oo],[c,oo]',variables='a,b') #a>=b>=c\n", + "prove(formula1) " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula2=makesubs(formula,'[c,oo],[b,oo]',variables='a,c') #a>=c>=b\n", + "prove(formula2) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So the case $a\\ge c\\ge b$ is done, but $a\\ge b\\ge c$ is not. But maybe we can adjust values." + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.000000\n", + " Iterations: 137\n", + " Function evaluations: 249\n" + ] + }, + { + "data": { + "text/plain": [ + "(1.7908873553542452e-10, 2.5326984818340415e-10, 7.129450063690368)" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "values=findvalues(formula1)\n", + "values" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "First and second value is approximately equal to 0, so we can try to replace 0 with 1." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove(formula1,values='1,1,7')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The key observation is that the `formula1` is homogenous, so we can scale values." + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1, 1.4142142855953455, 39809595184.05965)" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "newvalues=(1,values[1]/values[0],values[2]/values[0])\n", + "newvalues" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2.000002045581953" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "newvalues[1]**2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now the third value is very big. Technically we could use it, but it would run into overflow error, so we will use 1 instead of it. Second value is very close to $\\sqrt{2}$, so this value will be our next try." + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove(formula1,values='1,sqrt(2),1')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "So after getting the code all together we have got the following proof." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Case $a\\ge c\\ge b$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $a\\to c + d$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $c\\to b + e$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $2 b^{4} d^{2} + 2 b^{4} d e + 2 b^{4} e^{2} + 4 b^{3} d^{3} + 2 \\sqrt{2} b^{3} d^{2} e + 10 b^{3} d^{2} e + 2 \\sqrt{2} b^{3} d e^{2} + 6 b^{3} d e^{2} + 4 b^{3} e^{3} + 2 b^{2} d^{4} + 2 \\sqrt{2} b^{2} d^{3} e + 10 b^{2} d^{3} e + 6 \\sqrt{2} b^{2} d^{2} e^{2} + 12 b^{2} d^{2} e^{2} + 4 b^{2} d e^{3} + 4 \\sqrt{2} b^{2} d e^{3} + 2 b^{2} e^{4} + 2 b d^{4} e + 2 \\sqrt{2} b d^{3} e^{2} + 6 b d^{3} e^{2} + 4 b d^{2} e^{3} + 4 \\sqrt{2} b d^{2} e^{3} + 2 \\sqrt{2} b d e^{4} + d^{4} e^{2} + 2 d^{3} e^{3} + d^{2} e^{4}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $b^{6} + 2 b^{5} d + 4 b^{5} e + b^{4} d^{2} + 6 b^{4} d e + 6 b^{4} e^{2} + 2 b^{3} d^{2} e + 6 b^{3} d e^{2} + 4 b^{3} e^{3} + b^{2} d^{2} e^{2} + 2 b^{2} d e^{3} + b^{2} e^{4}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 2 b^{4} d^{2}+2 b^{4} d e+2 b^{4} e^{2}+4 b^{3} d^{3}+2 \\sqrt{2} b^{3} d^{2} e+10 b^{3} d^{2} e+2 \\sqrt{2} b^{3} d e^{2}+6 b^{3} d e^{2}+4 b^{3} e^{3}+2 b^{2} d^{4}+2 \\sqrt{2} b^{2} d^{3} e+10 b^{2} d^{3} e+6 \\sqrt{2} b^{2} d^{2} e^{2}+12 b^{2} d^{2} e^{2}+4 \\sqrt{2} b^{2} d e^{3}+4 b^{2} d e^{3}+2 b^{2} e^{4}+2 b d^{4} e+2 \\sqrt{2} b d^{3} e^{2}+6 b d^{3} e^{2}+4 \\sqrt{2} b d^{2} e^{3}+4 b d^{2} e^{3}+2 \\sqrt{2} b d e^{4}+d^{4} e^{2}+2 d^{3} e^{3}+d^{2} e^{4} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Case $a\\ge b\\ge c$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $a\\to b + f$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $b\\to c + g$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $f\\to \\sqrt{2} h$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $2 c^{4} g^{2} + 2 \\sqrt{2} c^{4} g h + 4 c^{4} h^{2} + 4 c^{3} g^{3} - 4 c^{3} g^{2} h + 6 \\sqrt{2} c^{3} g^{2} h - 4 \\sqrt{2} c^{3} g h^{2} + 20 c^{3} g h^{2} + 8 \\sqrt{2} c^{3} h^{3} + 2 c^{2} g^{4} - 8 c^{2} g^{3} h + 4 \\sqrt{2} c^{2} g^{3} h - 12 \\sqrt{2} c^{2} g^{2} h^{2} + 24 c^{2} g^{2} h^{2} - 8 c^{2} g h^{3} + 20 \\sqrt{2} c^{2} g h^{3} + 8 c^{2} h^{4} - 4 c g^{4} h - 8 \\sqrt{2} c g^{3} h^{2} + 8 c g^{3} h^{2} - 8 c g^{2} h^{3} + 12 \\sqrt{2} c g^{2} h^{3} + 8 c g h^{4} + 2 g^{4} h^{2} + 4 \\sqrt{2} g^{3} h^{3} + 4 g^{2} h^{4}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $c^{6} + 4 c^{5} g + 2 \\sqrt{2} c^{5} h + 6 c^{4} g^{2} + 6 \\sqrt{2} c^{4} g h + 2 c^{4} h^{2} + 4 c^{3} g^{3} + 6 \\sqrt{2} c^{3} g^{2} h + 4 c^{3} g h^{2} + c^{2} g^{4} + 2 \\sqrt{2} c^{2} g^{3} h + 2 c^{2} g^{2} h^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 c^{3} g^{2} h \\le 2 c^{4} g^{2}+2 c^{2} g^{2} h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 \\sqrt{2} c^{3} g h^{2} \\le 2 \\sqrt{2} c^{4} g h+\\sqrt{2} c^{3} h^{3}+\\sqrt{2} c g^{2} h^{3}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$8 c^{2} g^{3} h \\le 4 c^{3} g^{3}+4 c g^{3} h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$12 \\sqrt{2} c^{2} g^{2} h^{2} \\le 6 \\sqrt{2} c^{3} g^{2} h+6 \\sqrt{2} c g^{2} h^{3}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$8 c^{2} g h^{3} \\le 4 c^{3} g h^{2}+2 c^{2} h^{4}+2 g^{2} h^{4}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 c g^{4} h \\le 2 c^{2} g^{4}+2 g^{4} h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$8 \\sqrt{2} c g^{3} h^{2} \\le 4 \\sqrt{2} c^{2} g^{3} h+4 \\sqrt{2} g^{3} h^{3}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$8 c g^{2} h^{3} \\le 4 c g^{3} h^{2}+4 c g h^{4}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 4 c^{4} h^{2}+16 c^{3} g h^{2}+7 \\sqrt{2} c^{3} h^{3}+22 c^{2} g^{2} h^{2}+20 \\sqrt{2} c^{2} g h^{3}+6 c^{2} h^{4}+5 \\sqrt{2} c g^{2} h^{3}+4 c g h^{4}+2 g^{2} h^{4} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "newproof()\n", + "shiro.display=lambda x:display(Latex(x)) #turn on printing proofs \n", + "formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')\n", + "display(Latex('Case $a\\ge c\\ge b$'))\n", + "formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')\n", + "prove(formula1)\n", + "display(Latex('Case $a\\ge b\\ge c$'))\n", + "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", + "prove(formula2,values='1,2**(1/2),1')" + ] } ], "metadata": { diff --git a/.ipynb_checkpoints/sandbox-checkpoint.ipynb b/.ipynb_checkpoints/sandbox-checkpoint.ipynb index 8b7f55a..3e2ac3a 100644 --- a/.ipynb_checkpoints/sandbox-checkpoint.ipynb +++ b/.ipynb_checkpoints/sandbox-checkpoint.ipynb @@ -16,145 +16,39 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "from shiroindev import *\n", "from sympy import *\n", "from itertools import permutations, combinations\n", - "sVars.seed=1\n", + "shiro.seed=1\n", "from IPython.display import Latex\n", - "sVars.display=lambda x:display(Latex(x))" + "shiro.display=lambda x:display(Latex(x))" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $12a^3-18a^2b+6a^2c+6ab^2-18ac^2+12b^3-18b^2c+6bc^2+12c^3$" + "__________________________" ], "text/plain": [ "" ] }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $4a^2b+2a^2c+2ab^2+9abc+4ac^2+4b^2c+2bc^2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "From weighted AM-GM inequality:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18a^2b \\le 10a^3+6ab^2+2b^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18ac^2 \\le 2a^3+6a^2c+10c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18b^2c \\le 10b^3+6bc^2+2c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 0 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 3, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "formula=cyclize('(a+b)/(2*b+c)')-2\n", - "prove(formula*6)" + "Latex(r'__________________________')" ] }, { @@ -165,7 +59,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to s-s/(a+1)$" + "Substitute $a\\to s-\\frac{s}{d+1}$" ], "text/plain": [ "" @@ -177,7 +71,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to s-s/(b+1)$" + "Substitute $b\\to s-\\frac{s}{e+1}$" ], "text/plain": [ "" @@ -189,7 +83,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to s-s/(c+1)$" + "Substitute $c\\to s-\\frac{s}{f+1}$" ], "text/plain": [ "" @@ -201,7 +95,7 @@ { "data": { "text/latex": [ - "numerator: $abcs^2+s^2$" + "numerator: $defs^2+s^2$" ], "text/plain": [ "" @@ -213,7 +107,7 @@ { "data": { "text/latex": [ - "denominator: $abc+ab+ac+a+bc+b+c+1$" + "denominator: $def+de+df+d+ef+e+f+1$" ], "text/plain": [ "" @@ -237,7 +131,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le abcs^2+s^2 $$" + "$$ 0 \\le defs^2+s^2 $$" ], "text/plain": [ "" @@ -317,7 +211,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $x\\to g+y$" ], "text/plain": [ "" @@ -329,7 +223,7 @@ { "data": { "text/latex": [ - "$$y^{2}$$" + "$$g^{2}$$" ], "text/plain": [ "" @@ -372,7 +266,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to h+x$" ], "text/plain": [ "" @@ -384,7 +278,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} - x y y^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y^{t} z - x z z^{t} + x z \\left(x + z\\right)^{t} + y^{2} y^{t} - 2 y y^{t} z + y^{t} z^{2}$$" + "4 $$h^{2} \\left(h + x\\right)^{t} - h x x^{t} + h x z^{t} + h x \\left(h + x\\right)^{t} + h x^{t} z - h z z^{t} - h z \\left(h + x\\right)^{t} + x^{2} z^{t} - 2 x z z^{t} + z^{2} z^{t}$$" ], "text/plain": [ "" @@ -396,7 +290,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to i+x$" ], "text/plain": [ "" @@ -408,7 +302,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} x^{t} - x x^{t} y - 2 x x^{t} z + x y z^{t} - x y \\left(y + z\\right)^{t} + x^{t} y z + x^{t} z^{2} + y^{2} \\left(y + z\\right)^{t} - y z z^{t} + y z \\left(y + z\\right)^{t}$$" + "4 $$i^{2} \\left(i + x\\right)^{t} - i x x^{t} + i x y^{t} + i x \\left(i + x\\right)^{t} + i x^{t} y - i y y^{t} - i y \\left(i + x\\right)^{t} + x^{2} y^{t} - 2 x y y^{t} + y^{2} y^{t}$$" ], "text/plain": [ "" @@ -420,7 +314,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $z\\to j+y$" ], "text/plain": [ "" @@ -432,7 +326,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} z^{t} - x x^{t} y + x y z^{t} + x y \\left(x + y\\right)^{t} - 2 x z z^{t} + x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z z^{t} - y z \\left(x + y\\right)^{t} + z^{2} z^{t}$$" + "4 $$j^{2} \\left(j + y\\right)^{t} - j x x^{t} + j x y^{t} - j x \\left(j + y\\right)^{t} + j x^{t} y - j y y^{t} + j y \\left(j + y\\right)^{t} + x^{2} x^{t} - 2 x x^{t} y + x^{t} y^{2}$$" ], "text/plain": [ "" @@ -444,7 +338,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to k+x$" ], "text/plain": [ "" @@ -456,7 +350,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to l+x$" ], "text/plain": [ "" @@ -468,7 +362,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} - x y \\left(y + z\\right)^{t} + y^{2} \\left(y + z\\right)^{t}$$" + "4 $$k^{2} \\left(k + x\\right)^{t} + k l x^{t} - k l \\left(k + x\\right)^{t} - k l \\left(l + x\\right)^{t} + l^{2} \\left(l + x\\right)^{t}$$" ], "text/plain": [ "" @@ -480,7 +374,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $l\\to k+m$" ], "text/plain": [ "" @@ -492,7 +386,7 @@ { "data": { "text/latex": [ - "3 $$x^{2} z^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y \\left(x + y + z\\right)^{t} + y^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$k^{2} x^{t} + k m x^{t} - k m \\left(k + x\\right)^{t} + k m \\left(k + m + x\\right)^{t} + m^{2} \\left(k + m + x\\right)^{t}$$" ], "text/plain": [ "" @@ -504,7 +398,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to n+x$" ], "text/plain": [ "" @@ -516,7 +410,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to o+x$" ], "text/plain": [ "" @@ -528,7 +422,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} - x y \\left(y + z\\right)^{t} + y^{2} \\left(y + z\\right)^{t}$$" + "4 $$n^{2} \\left(n + x\\right)^{t} + n o x^{t} - n o \\left(n + x\\right)^{t} - n o \\left(o + x\\right)^{t} + o^{2} \\left(o + x\\right)^{t}$$" ], "text/plain": [ "" @@ -540,7 +434,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $o\\to n+p$" ], "text/plain": [ "" @@ -552,7 +446,7 @@ { "data": { "text/latex": [ - "3 $$x^{2} z^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y \\left(x + y + z\\right)^{t} + y^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$n^{2} x^{t} + n p x^{t} - n p \\left(n + x\\right)^{t} + n p \\left(n + p + x\\right)^{t} + p^{2} \\left(n + p + x\\right)^{t}$$" ], "text/plain": [ "" @@ -574,7 +468,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+y$" + "Substitute $x\\to q+y$" ], "text/plain": [ "" @@ -586,10 +480,10 @@ { "data": { "text/latex": [ - "$\\displaystyle x^{2} \\left(x + y\\right)^{t} - x y y^{t} + x y z^{t} + x y \\left(x + y\\right)^{t} + x y^{t} z - x z z^{t} - x z \\left(x + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" + "$\\displaystyle q^{2} \\left(q + y\\right)^{t} - q y y^{t} + q y z^{t} + q y \\left(q + y\\right)^{t} + q y^{t} z - q z z^{t} - q z \\left(q + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" ], "text/plain": [ - "x**2*(x + y)**t - x*y*y**t + x*y*z**t + x*y*(x + y)**t + x*y**t*z - x*z*z**t - x*z*(x + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" + "q**2*(q + y)**t - q*y*y**t + q*y*z**t + q*y*(q + y)**t + q*y**t*z - q*z*z**t - q*z*(q + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" ] }, "execution_count": 10, @@ -609,7 +503,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+y$" + "Substitute $x\\to r+y$" ], "text/plain": [ "" @@ -621,10 +515,10 @@ { "data": { "text/latex": [ - "$\\displaystyle x^{2} \\left(x + y\\right)^{t} - x y y^{t} + x y z^{t} + x y \\left(x + y\\right)^{t} + x y^{t} z - x z z^{t} - x z \\left(x + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" + "$\\displaystyle r^{2} \\left(r + y\\right)^{t} - r y y^{t} + r y z^{t} + r y \\left(r + y\\right)^{t} + r y^{t} z - r z z^{t} - r z \\left(r + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" ], "text/plain": [ - "x**2*(x + y)**t - x*y*y**t + x*y*z**t + x*y*(x + y)**t + x*y**t*z - x*z*z**t - x*z*(x + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" + "r**2*(r + y)**t - r*y*y**t + r*y*z**t + r*y*(r + y)**t + r*y**t*z - r*z*z**t - r*z*(r + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" ] }, "execution_count": 11, @@ -644,7 +538,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to u+x$" ], "text/plain": [ "" @@ -656,7 +550,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} - x y y^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y^{t} z - x z z^{t} + x z \\left(x + z\\right)^{t} + y^{2} y^{t} - 2 y y^{t} z + y^{t} z^{2}$$" + "4 $$u^{2} \\left(u + x\\right)^{t} - u x x^{t} + u x z^{t} + u x \\left(u + x\\right)^{t} + u x^{t} z - u z z^{t} - u z \\left(u + x\\right)^{t} + x^{2} z^{t} - 2 x z z^{t} + z^{2} z^{t}$$" ], "text/plain": [ "" @@ -668,7 +562,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to v+x$" ], "text/plain": [ "" @@ -680,7 +574,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} x^{t} - x x^{t} y - 2 x x^{t} z + x y z^{t} - x y \\left(y + z\\right)^{t} + x^{t} y z + x^{t} z^{2} + y^{2} \\left(y + z\\right)^{t} - y z z^{t} + y z \\left(y + z\\right)^{t}$$" + "4 $$v^{2} \\left(v + x\\right)^{t} - v x x^{t} + v x y^{t} + v x \\left(v + x\\right)^{t} + v x^{t} y - v y y^{t} - v y \\left(v + x\\right)^{t} + x^{2} y^{t} - 2 x y y^{t} + y^{2} y^{t}$$" ], "text/plain": [ "" @@ -692,7 +586,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $z\\to w+y$" ], "text/plain": [ "" @@ -704,7 +598,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} z^{t} - x x^{t} y + x y z^{t} + x y \\left(x + y\\right)^{t} - 2 x z z^{t} + x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z z^{t} - y z \\left(x + y\\right)^{t} + z^{2} z^{t}$$" + "4 $$w^{2} \\left(w + y\\right)^{t} - w x x^{t} + w x y^{t} - w x \\left(w + y\\right)^{t} + w x^{t} y - w y y^{t} + w y \\left(w + y\\right)^{t} + x^{2} x^{t} - 2 x x^{t} y + x^{t} y^{2}$$" ], "text/plain": [ "" @@ -716,7 +610,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to a_{1}+x$" ], "text/plain": [ "" @@ -728,7 +622,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to b_{1}+x$" ], "text/plain": [ "" @@ -740,7 +634,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} - x y \\left(y + z\\right)^{t} + y^{2} \\left(y + z\\right)^{t}$$" + "4 $$a_{1}^{2} \\left(a_{1} + x\\right)^{t} + a_{1} b_{1} x^{t} - a_{1} b_{1} \\left(a_{1} + x\\right)^{t} - a_{1} b_{1} \\left(b_{1} + x\\right)^{t} + b_{1}^{2} \\left(b_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -752,7 +646,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $b_{1}\\to a_{1}+c_{1}$" ], "text/plain": [ "" @@ -764,7 +658,7 @@ { "data": { "text/latex": [ - "3 $$x^{2} z^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y \\left(x + y + z\\right)^{t} + y^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$a_{1}^{2} x^{t} + a_{1} c_{1} x^{t} - a_{1} c_{1} \\left(a_{1} + x\\right)^{t} + a_{1} c_{1} \\left(a_{1} + c_{1} + x\\right)^{t} + c_{1}^{2} \\left(a_{1} + c_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -776,7 +670,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y+z$" + "Substitute $z\\to d_{1}+x$" ], "text/plain": [ "" @@ -788,7 +682,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+z$" + "Substitute $y\\to e_{1}+x$" ], "text/plain": [ "" @@ -800,7 +694,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} \\left(x + z\\right)^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} - x y \\left(y + z\\right)^{t} + y^{2} \\left(y + z\\right)^{t}$$" + "4 $$d_{1}^{2} \\left(d_{1} + x\\right)^{t} + d_{1} e_{1} x^{t} - d_{1} e_{1} \\left(d_{1} + x\\right)^{t} - d_{1} e_{1} \\left(e_{1} + x\\right)^{t} + e_{1}^{2} \\left(e_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -812,7 +706,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $e_{1}\\to d_{1}+f_{1}$" ], "text/plain": [ "" @@ -824,7 +718,7 @@ { "data": { "text/latex": [ - "3 $$x^{2} z^{t} + x y z^{t} - x y \\left(x + z\\right)^{t} + x y \\left(x + y + z\\right)^{t} + y^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$d_{1}^{2} x^{t} + d_{1} f_{1} x^{t} - d_{1} f_{1} \\left(d_{1} + x\\right)^{t} + d_{1} f_{1} \\left(d_{1} + f_{1} + x\\right)^{t} + f_{1}^{2} \\left(d_{1} + f_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -953,7 +847,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 11a/8$" + "Substitute $a\\to 11g_{1}/8$" ], "text/plain": [ "" @@ -965,7 +859,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to 4b/5$" + "Substitute $b\\to 4h_{1}/5$" ], "text/plain": [ "" @@ -977,7 +871,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to 4c/5$" + "Substitute $c\\to 4i_{1}/5$" ], "text/plain": [ "" @@ -989,7 +883,7 @@ { "data": { "text/latex": [ - "Substitute $d\\to 4d/5$" + "Substitute $d\\to 4j_{1}/5$" ], "text/plain": [ "" @@ -1001,7 +895,7 @@ { "data": { "text/latex": [ - "numerator: $3025a^2-1760ab-1760ac-1760ad+1024b^2+1024c^2+1024d^2$" + "numerator: $3025g_{1}^2-1760g_{1}h_{1}-1760g_{1}i_{1}-1760g_{1}j_{1}+1024h_{1}^2+1024i_{1}^2+1024j_{1}^2$" ], "text/plain": [ "" @@ -1049,7 +943,7 @@ { "data": { "text/latex": [ - "$$1760ab \\le 880a^2+880b^2$$" + "$$1760g_{1}h_{1} \\le 880g_{1}^2+880h_{1}^2$$" ], "text/plain": [ "" @@ -1061,7 +955,7 @@ { "data": { "text/latex": [ - "$$1760ac \\le 880a^2+880c^2$$" + "$$1760g_{1}i_{1} \\le 880g_{1}^2+880i_{1}^2$$" ], "text/plain": [ "" @@ -1073,7 +967,7 @@ { "data": { "text/latex": [ - "$$1760ad \\le 880a^2+880d^2$$" + "$$1760g_{1}j_{1} \\le 880g_{1}^2+880j_{1}^2$$" ], "text/plain": [ "" @@ -1085,7 +979,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 385a^2+144b^2+144c^2+144d^2 $$" + "$$ 0 \\le 385g_{1}^2+144h_{1}^2+144i_{1}^2+144j_{1}^2 $$" ], "text/plain": [ "" @@ -1148,76 +1042,29 @@ "outputs": [ { "data": { - "text/latex": [ - "$\\displaystyle - \\frac{2 \\sqrt{2} \\left(a - b\\right)}{c} + \\frac{\\left(a - b\\right)^{2}}{c^{2}} - \\frac{2 \\sqrt{2} \\left(- a + c\\right)}{b} + \\frac{\\left(- a + c\\right)^{2}}{b^{2}} - \\frac{2 \\sqrt{2} \\left(b - c\\right)}{a} + \\frac{\\left(b - c\\right)^{2}}{a^{2}}$" - ], "text/plain": [ - "-2*sqrt(2)*(a - b)/c + (a - b)**2/c**2 - 2*sqrt(2)*(-a + c)/b + (-a + c)**2/b**2 - 2*sqrt(2)*(b - c)/a + (b - c)**2/a**2" + "\"formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\\ndisplay(formula)\\nfrom scipy.optimize import fmin\\nimport numpy as np\\ndef f(x):\\n num,den=fraction(cancel(newformula))\\n fs=sorted(newformula.free_symbols,key=str)\\n return float(num.subs(list(zip(fs,x))))\\nnewformula=(makesubs(formula,'[b,oo],[c,oo]'))\\nprint(f([2,1,1]))\\nfmin(f,[2,1,1])\\nprint(fmin(f,np.array([2,1,1])))\\ndisplay(simplify(newformula))\"" ] }, + "execution_count": 20, "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $a\\to a+b$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $b\\to b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Optimization terminated successfully.\n", - " Current function value: 0.000000\n", - " Iterations: 51\n", - " Function evaluations: 97\n", - "[1.17092486 1.170961 1.17093843]\n" - ] - }, - { - "data": { - "text/latex": [ - "$\\displaystyle \\frac{a^{4} b^{2} + 2 a^{4} b c + 2 a^{4} c^{2} + 2 a^{3} b^{3} - 2 \\sqrt{2} a^{3} b^{2} c + 6 a^{3} b^{2} c - 2 \\sqrt{2} a^{3} b c^{2} + 10 a^{3} b c^{2} + 4 a^{3} c^{3} + a^{2} b^{4} - 4 \\sqrt{2} a^{2} b^{3} c + 4 a^{2} b^{3} c - 6 \\sqrt{2} a^{2} b^{2} c^{2} + 12 a^{2} b^{2} c^{2} - 2 \\sqrt{2} a^{2} b c^{3} + 10 a^{2} b c^{3} + 2 a^{2} c^{4} - 2 \\sqrt{2} a b^{4} c - 4 \\sqrt{2} a b^{3} c^{2} + 4 a b^{3} c^{2} - 2 \\sqrt{2} a b^{2} c^{3} + 6 a b^{2} c^{3} + 2 a b c^{4} + 2 b^{4} c^{2} + 4 b^{3} c^{3} + 2 b^{2} c^{4}}{c^{2} \\left(a^{2} b^{2} + 2 a^{2} b c + a^{2} c^{2} + 2 a b^{3} + 6 a b^{2} c + 6 a b c^{2} + 2 a c^{3} + b^{4} + 4 b^{3} c + 6 b^{2} c^{2} + 4 b c^{3} + c^{4}\\right)}$" - ], - "text/plain": [ - "(a**4*b**2 + 2*a**4*b*c + 2*a**4*c**2 + 2*a**3*b**3 - 2*sqrt(2)*a**3*b**2*c + 6*a**3*b**2*c - 2*sqrt(2)*a**3*b*c**2 + 10*a**3*b*c**2 + 4*a**3*c**3 + a**2*b**4 - 4*sqrt(2)*a**2*b**3*c + 4*a**2*b**3*c - 6*sqrt(2)*a**2*b**2*c**2 + 12*a**2*b**2*c**2 - 2*sqrt(2)*a**2*b*c**3 + 10*a**2*b*c**3 + 2*a**2*c**4 - 2*sqrt(2)*a*b**4*c - 4*sqrt(2)*a*b**3*c**2 + 4*a*b**3*c**2 - 2*sqrt(2)*a*b**2*c**3 + 6*a*b**2*c**3 + 2*a*b*c**4 + 2*b**4*c**2 + 4*b**3*c**3 + 2*b**2*c**4)/(c**2*(a**2*b**2 + 2*a**2*b*c + a**2*c**2 + 2*a*b**3 + 6*a*b**2*c + 6*a*b*c**2 + 2*a*c**3 + b**4 + 4*b**3*c + 6*b**2*c**2 + 4*b*c**3 + c**4))" - ] - }, - "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ - "formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", + "\"\"\"formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", "display(formula)\n", "from scipy.optimize import fmin\n", "import numpy as np\n", "def f(x):\n", - " num,den=fraction(cancel(formula))\n", + " num,den=fraction(cancel(newformula))\n", " fs=sorted(newformula.free_symbols,key=str)\n", - " return num.subs(zip(fs,x))\n", + " return float(num.subs(list(zip(fs,x))))\n", "newformula=(makesubs(formula,'[b,oo],[c,oo]'))\n", + "print(f([2,1,1]))\n", + "fmin(f,[2,1,1])\n", "print(fmin(f,np.array([2,1,1])))\n", - "display(simplify(newformula))\n", + "display(simplify(newformula))\"\"\"\n", "#prove(newformula)\n", "#prove(makesubs(formula,'[b,oo],[a,oo]',variables='c,b,a'))" ] @@ -1326,13 +1173,13 @@ }, { "cell_type": "code", - "execution_count": 107, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+k_{1}$" ], "text/plain": [ "" @@ -1344,7 +1191,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+l_{1}$" ], "text/plain": [ "" @@ -1354,68 +1201,15 @@ "output_type": "display_data" }, { - "data": { - "text/latex": [ - "$\\displaystyle a^{8} b^{4} + 2 a^{8} b^{2} c^{2} + 2 a^{8} c^{4} + 2 a^{6} b^{6} - 2 \\sqrt{2} a^{6} b^{4} c^{2} + 6 a^{6} b^{4} c^{2} - 2 \\sqrt{2} a^{6} b^{2} c^{4} + 10 a^{6} b^{2} c^{4} + 4 a^{6} c^{6} + a^{4} b^{8} - 4 \\sqrt{2} a^{4} b^{6} c^{2} + 4 a^{4} b^{6} c^{2} - 6 \\sqrt{2} a^{4} b^{4} c^{4} + 12 a^{4} b^{4} c^{4} - 2 \\sqrt{2} a^{4} b^{2} c^{6} + 10 a^{4} b^{2} c^{6} + 2 a^{4} c^{8} - 2 \\sqrt{2} a^{2} b^{8} c^{2} - 4 \\sqrt{2} a^{2} b^{6} c^{4} + 4 a^{2} b^{6} c^{4} - 2 \\sqrt{2} a^{2} b^{4} c^{6} + 6 a^{2} b^{4} c^{6} + 2 a^{2} b^{2} c^{8} + 2 b^{8} c^{4} + 4 b^{6} c^{6} + 2 b^{4} c^{8}$" - ], - "text/plain": [ - "a**8*b**4 + 2*a**8*b**2*c**2 + 2*a**8*c**4 + 2*a**6*b**6 - 2*sqrt(2)*a**6*b**4*c**2 + 6*a**6*b**4*c**2 - 2*sqrt(2)*a**6*b**2*c**4 + 10*a**6*b**2*c**4 + 4*a**6*c**6 + a**4*b**8 - 4*sqrt(2)*a**4*b**6*c**2 + 4*a**4*b**6*c**2 - 6*sqrt(2)*a**4*b**4*c**4 + 12*a**4*b**4*c**4 - 2*sqrt(2)*a**4*b**2*c**6 + 10*a**4*b**2*c**6 + 2*a**4*c**8 - 2*sqrt(2)*a**2*b**8*c**2 - 4*sqrt(2)*a**2*b**6*c**4 + 4*a**2*b**6*c**4 - 2*sqrt(2)*a**2*b**4*c**6 + 6*a**2*b**4*c**6 + 2*a**2*b**2*c**8 + 2*b**8*c**4 + 4*b**6*c**6 + 2*b**4*c**8" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{a: 2, b: 2, c: 2}\n" + "ename": "NameError", + "evalue": "name 'fs' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mformula\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmakesubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'[b,oo],[c,oo]'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mnum\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mden\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfraction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcancel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mnum\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnum\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mfs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mdisplay\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnum\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mnumm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'fs' is not defined" ] - }, - { - "data": { - "text/latex": [ - "$\\displaystyle \\frac{19 \\sqrt{2}}{12}$" - ], - "text/plain": [ - "19*sqrt(2)/12" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x\n", - "Optimization terminated successfully.\n", - " Current function value: 1.000000\n", - " Iterations: 147\n", - " Function evaluations: 267\n" - ] - }, - { - "data": { - "text/plain": [ - "(4.4110810020775736e-12, 28.52020821072961, 3.1191098416324057e-12)" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$\\displaystyle \\left( 0, \\ \\frac{57}{2}, \\ 0\\right)$" - ], - "text/plain": [ - "(0, 57/2, 0)" - ] - }, - "execution_count": 107, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ @@ -1470,7 +1264,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -1479,7 +1273,7 @@ "1.414211498165453" ] }, - "execution_count": 65, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -1490,7 +1284,7 @@ }, { "cell_type": "code", - "execution_count": 111, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -1508,7 +1302,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c+r_{1}$" ], "text/plain": [ "" @@ -1520,7 +1314,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to b+c$" + "Substitute $c\\to b+s_{1}$" ], "text/plain": [ "" @@ -1532,7 +1326,7 @@ { "data": { "text/latex": [ - "numerator: $2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4a^2bc^3+4\\sqrt{2}a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4ab^2c^3+4\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $2b^4r_{1}^2+2b^4r_{1}s_{1}+2b^4s_{1}^2+4b^3r_{1}^3+2\\sqrt{2}b^3r_{1}^2s_{1}+10b^3r_{1}^2s_{1}+2\\sqrt{2}b^3r_{1}s_{1}^2+6b^3r_{1}s_{1}^2+4b^3s_{1}^3+2b^2r_{1}^4+2\\sqrt{2}b^2r_{1}^3s_{1}+10b^2r_{1}^3s_{1}+6\\sqrt{2}b^2r_{1}^2s_{1}^2+12b^2r_{1}^2s_{1}^2+4b^2r_{1}s_{1}^3+4\\sqrt{2}b^2r_{1}s_{1}^3+2b^2s_{1}^4+2br_{1}^4s_{1}+2\\sqrt{2}br_{1}^3s_{1}^2+6br_{1}^3s_{1}^2+4br_{1}^2s_{1}^3+4\\sqrt{2}br_{1}^2s_{1}^3+2\\sqrt{2}br_{1}s_{1}^4+r_{1}^4s_{1}^2+2r_{1}^3s_{1}^3+r_{1}^2s_{1}^4$" ], "text/plain": [ "" @@ -1544,7 +1338,7 @@ { "data": { "text/latex": [ - "denominator: $a^2b^4+2a^2b^3c+a^2b^2c^2+2ab^5+6ab^4c+6ab^3c^2+2ab^2c^3+b^6+4b^5c+6b^4c^2+4b^3c^3+b^2c^4$" + "denominator: $b^6+2b^5r_{1}+4b^5s_{1}+b^4r_{1}^2+6b^4r_{1}s_{1}+6b^4s_{1}^2+2b^3r_{1}^2s_{1}+6b^3r_{1}s_{1}^2+4b^3s_{1}^3+b^2r_{1}^2s_{1}^2+2b^2r_{1}s_{1}^3+b^2s_{1}^4$" ], "text/plain": [ "" @@ -1568,7 +1362,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4\\sqrt{2}a^2bc^3+4a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4\\sqrt{2}ab^2c^3+4ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4 $$" + "$$ 0 \\le r_{1}^4s_{1}^2+2br_{1}^4s_{1}+2b^2r_{1}^4+2r_{1}^3s_{1}^3+2\\sqrt{2}br_{1}^3s_{1}^2+6br_{1}^3s_{1}^2+2\\sqrt{2}b^2r_{1}^3s_{1}+10b^2r_{1}^3s_{1}+4b^3r_{1}^3+r_{1}^2s_{1}^4+4\\sqrt{2}br_{1}^2s_{1}^3+4br_{1}^2s_{1}^3+6\\sqrt{2}b^2r_{1}^2s_{1}^2+12b^2r_{1}^2s_{1}^2+2\\sqrt{2}b^3r_{1}^2s_{1}+10b^3r_{1}^2s_{1}+2b^4r_{1}^2+2\\sqrt{2}br_{1}s_{1}^4+4\\sqrt{2}b^2r_{1}s_{1}^3+4b^2r_{1}s_{1}^3+2\\sqrt{2}b^3r_{1}s_{1}^2+6b^3r_{1}s_{1}^2+2b^4r_{1}s_{1}+2b^2s_{1}^4+4b^3s_{1}^3+2b^4s_{1}^2 $$" ], "text/plain": [ "" @@ -1604,7 +1398,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+t_{1}$" ], "text/plain": [ "" @@ -1616,7 +1410,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+u_{1}$" ], "text/plain": [ "" @@ -1628,7 +1422,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to \\sqrt{2}a$" + "Substitute $t_{1}\\to \\sqrt{2}v_{1}$" ], "text/plain": [ "" @@ -1640,7 +1434,7 @@ { "data": { "text/latex": [ - "numerator: $16a^4b^2+32a^4bc+32a^4c^2+16\\sqrt{2}a^3b^3-32a^3b^2c+48\\sqrt{2}a^3b^2c-32a^3bc^2+80\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+8a^2b^4-32\\sqrt{2}a^2b^3c+32a^2b^3c-48\\sqrt{2}a^2b^2c^2+96a^2b^2c^2-16\\sqrt{2}a^2bc^3+80a^2bc^3+16a^2c^4-16ab^4c-32ab^3c^2+16\\sqrt{2}ab^3c^2-16ab^2c^3+24\\sqrt{2}ab^2c^3+8\\sqrt{2}abc^4+8b^4c^2+16b^3c^3+8b^2c^4$" + "numerator: $8c^4u_{1}^2+8\\sqrt{2}c^4u_{1}v_{1}+16c^4v_{1}^2+16c^3u_{1}^3-16c^3u_{1}^2v_{1}+24\\sqrt{2}c^3u_{1}^2v_{1}-16\\sqrt{2}c^3u_{1}v_{1}^2+80c^3u_{1}v_{1}^2+32\\sqrt{2}c^3v_{1}^3+8c^2u_{1}^4-32c^2u_{1}^3v_{1}+16\\sqrt{2}c^2u_{1}^3v_{1}-48\\sqrt{2}c^2u_{1}^2v_{1}^2+96c^2u_{1}^2v_{1}^2-32c^2u_{1}v_{1}^3+80\\sqrt{2}c^2u_{1}v_{1}^3+32c^2v_{1}^4-16cu_{1}^4v_{1}-32\\sqrt{2}cu_{1}^3v_{1}^2+32cu_{1}^3v_{1}^2-32cu_{1}^2v_{1}^3+48\\sqrt{2}cu_{1}^2v_{1}^3+32cu_{1}v_{1}^4+8u_{1}^4v_{1}^2+16\\sqrt{2}u_{1}^3v_{1}^3+16u_{1}^2v_{1}^4$" ], "text/plain": [ "" @@ -1652,7 +1446,7 @@ { "data": { "text/latex": [ - "denominator: $2a^2b^2c^2+4a^2bc^3+2a^2c^4+2\\sqrt{2}ab^3c^2+6\\sqrt{2}ab^2c^3+6\\sqrt{2}abc^4+2\\sqrt{2}ac^5+b^4c^2+4b^3c^3+6b^2c^4+4bc^5+c^6$" + "denominator: $c^6+4c^5u_{1}+2\\sqrt{2}c^5v_{1}+6c^4u_{1}^2+6\\sqrt{2}c^4u_{1}v_{1}+2c^4v_{1}^2+4c^3u_{1}^3+6\\sqrt{2}c^3u_{1}^2v_{1}+4c^3u_{1}v_{1}^2+c^2u_{1}^4+2\\sqrt{2}c^2u_{1}^3v_{1}+2c^2u_{1}^2v_{1}^2$" ], "text/plain": [ "" @@ -1688,7 +1482,7 @@ { "data": { "text/latex": [ - "$$32a^3b^2c \\le 16a^4b^2+16a^2b^2c^2$$" + "$$16cu_{1}^4v_{1} \\le 8u_{1}^4v_{1}^2+8c^2u_{1}^4$$" ], "text/plain": [ "" @@ -1700,7 +1494,7 @@ { "data": { "text/latex": [ - "$$32\\sqrt{2}a^2b^3c \\le 16\\sqrt{2}a^3b^3+16\\sqrt{2}ab^3c^2$$" + "$$32\\sqrt{2}cu_{1}^3v_{1}^2 \\le 16\\sqrt{2}u_{1}^3v_{1}^3+16\\sqrt{2}c^2u_{1}^3v_{1}$$" ], "text/plain": [ "" @@ -1712,7 +1506,7 @@ { "data": { "text/latex": [ - "$$48\\sqrt{2}a^2b^2c^2 \\le 24\\sqrt{2}a^3b^2c+24\\sqrt{2}ab^2c^3$$" + "$$32c^2u_{1}^3v_{1} \\le 16cu_{1}^3v_{1}^2+16c^3u_{1}^3$$" ], "text/plain": [ "" @@ -1724,7 +1518,7 @@ { "data": { "text/latex": [ - "$$16\\sqrt{2}a^2bc^3 \\le 8\\sqrt{2}a^3bc^2+8\\sqrt{2}abc^4$$" + "$$32cu_{1}^2v_{1}^3 \\le 16cu_{1}^3v_{1}^2+16cu_{1}v_{1}^4$$" ], "text/plain": [ "" @@ -1736,7 +1530,7 @@ { "data": { "text/latex": [ - "$$16ab^4c \\le 8a^2b^4+8b^4c^2$$" + "$$48\\sqrt{2}c^2u_{1}^2v_{1}^2 \\le 24\\sqrt{2}cu_{1}^2v_{1}^3+24\\sqrt{2}c^3u_{1}^2v_{1}$$" ], "text/plain": [ "" @@ -1748,7 +1542,7 @@ { "data": { "text/latex": [ - "$$32ab^3c^2 \\le 16a^2b^3c+16b^3c^3$$" + "$$16c^3u_{1}^2v_{1} \\le 8c^2u_{1}^2v_{1}^2+8c^4u_{1}^2$$" ], "text/plain": [ "" @@ -1760,7 +1554,7 @@ { "data": { "text/latex": [ - "$$32a^3bc^2 \\le 16a^4bc+16a^2bc^3$$" + "$$32c^2u_{1}v_{1}^3 \\le 16u_{1}^2v_{1}^4+16c^4v_{1}^2$$" ], "text/plain": [ "" @@ -1772,7 +1566,7 @@ { "data": { "text/latex": [ - "$$16ab^2c^3 \\le 8a^2b^2c^2+8b^2c^4$$" + "$$16\\sqrt{2}c^3u_{1}v_{1}^2 \\le 8\\sqrt{2}c^2u_{1}v_{1}^3+8\\sqrt{2}c^4u_{1}v_{1}$$" ], "text/plain": [ "" @@ -1784,7 +1578,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 16a^4bc+32a^4c^2+24\\sqrt{2}a^3b^2c+72\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+16a^2b^3c+72a^2b^2c^2+64a^2bc^3+16a^2c^4 $$" + "$$ 0 \\le 24\\sqrt{2}cu_{1}^2v_{1}^3+88c^2u_{1}^2v_{1}^2+16cu_{1}v_{1}^4+72\\sqrt{2}c^2u_{1}v_{1}^3+80c^3u_{1}v_{1}^2+32c^2v_{1}^4+32\\sqrt{2}c^3v_{1}^3 $$" ], "text/plain": [ "" @@ -1807,11 +1601,14 @@ }, { "data": { + "text/latex": [ + "$\\displaystyle - \\frac{2 \\sqrt{2} \\left(a - b\\right)}{c} + \\frac{\\left(a - b\\right)^{2}}{c^{2}} - \\frac{2 \\sqrt{2} \\left(- a + c\\right)}{b} + \\frac{\\left(- a + c\\right)^{2}}{b^{2}} - \\frac{2 \\sqrt{2} \\left(b - c\\right)}{a} + \\frac{\\left(b - c\\right)^{2}}{a^{2}}$" + ], "text/plain": [ - "0" + "-2*sqrt(2)*(a - b)/c + (a - b)**2/c**2 - 2*sqrt(2)*(-a + c)/b + (-a + c)**2/b**2 - 2*sqrt(2)*(b - c)/a + (b - c)**2/a**2" ] }, - "execution_count": 111, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -1823,18 +1620,19 @@ "prove(formula1)\n", "display(Latex('Case $a\\ge b\\ge c$'))\n", "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", - "prove(formula2*4,values='2**(1/2),1,1')" + "prove(formula2*4,values='1,sqrt(2),1')\n", + "formula" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+w_{1}$" ], "text/plain": [ "" @@ -1846,7 +1644,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+x_{1}$" ], "text/plain": [ "" @@ -1870,7 +1668,7 @@ { "data": { "text/latex": [ - "numerator: $4a^4b^2+8a^4bc+8a^4c^2+4\\sqrt{2}a^3b^3-8a^3b^2c+12\\sqrt{2}a^3b^2c-8a^3bc^2+20\\sqrt{2}a^3bc^2+8\\sqrt{2}a^3c^3+2a^2b^4-8\\sqrt{2}a^2b^3c+8a^2b^3c-12\\sqrt{2}a^2b^2c^2+24a^2b^2c^2-4\\sqrt{2}a^2bc^3+20a^2bc^3+4a^2c^4-4ab^4c-8ab^3c^2+4\\sqrt{2}ab^3c^2-4ab^2c^3+6\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $2c^4w_{1}^2+2c^4w_{1}x_{1}+2c^4x_{1}^2+4c^3w_{1}^3-2\\sqrt{2}c^3w_{1}^2x_{1}+10c^3w_{1}^2x_{1}-2\\sqrt{2}c^3w_{1}x_{1}^2+6c^3w_{1}x_{1}^2+4c^3x_{1}^3+2c^2w_{1}^4-2\\sqrt{2}c^2w_{1}^3x_{1}+10c^2w_{1}^3x_{1}-6\\sqrt{2}c^2w_{1}^2x_{1}^2+12c^2w_{1}^2x_{1}^2-4\\sqrt{2}c^2w_{1}x_{1}^3+4c^2w_{1}x_{1}^3+2c^2x_{1}^4+2cw_{1}^4x_{1}-2\\sqrt{2}cw_{1}^3x_{1}^2+6cw_{1}^3x_{1}^2-4\\sqrt{2}cw_{1}^2x_{1}^3+4cw_{1}^2x_{1}^3-2\\sqrt{2}cw_{1}x_{1}^4+w_{1}^4x_{1}^2+2w_{1}^3x_{1}^3+w_{1}^2x_{1}^4$" ], "text/plain": [ "" @@ -1894,7 +1692,7 @@ { "data": { "text/latex": [ - "status: 0" + "status: 2" ], "text/plain": [ "" @@ -1906,7 +1704,7 @@ { "data": { "text/latex": [ - "From weighted AM-GM inequality:" + "Program couldn't find any proof." ], "text/plain": [ "" @@ -1918,115 +1716,7 @@ { "data": { "text/latex": [ - "$$8a^3b^2c \\le 4a^4b^2+4a^2b^2c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$8\\sqrt{2}a^2b^3c \\le 4\\sqrt{2}a^3b^3+4\\sqrt{2}ab^3c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$12\\sqrt{2}a^2b^2c^2 \\le 6\\sqrt{2}a^3b^2c+6\\sqrt{2}ab^2c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$4\\sqrt{2}a^2bc^3 \\le 2\\sqrt{2}a^3bc^2+2\\sqrt{2}abc^4$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$4ab^4c \\le 2a^2b^4+2b^4c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$8ab^3c^2 \\le 4a^2b^3c+4b^3c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$8a^3bc^2 \\le 4a^4bc+4a^2bc^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$4ab^2c^3 \\le 2a^2b^2c^2+2b^2c^4$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 4a^4bc+8a^4c^2+6\\sqrt{2}a^3b^2c+18\\sqrt{2}a^3bc^2+8\\sqrt{2}a^3c^3+4a^2b^3c+18a^2b^2c^2+16a^2bc^3+4a^2c^4 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." + "$$ 2\\sqrt{2}cw_{1}x_{1}^4+4\\sqrt{2}cw_{1}^2x_{1}^3+4\\sqrt{2}c^2w_{1}x_{1}^3+2\\sqrt{2}cw_{1}^3x_{1}^2+6\\sqrt{2}c^2w_{1}^2x_{1}^2+2\\sqrt{2}c^3w_{1}x_{1}^2+2\\sqrt{2}c^2w_{1}^3x_{1}+2\\sqrt{2}c^3w_{1}^2x_{1} \\le w_{1}^2x_{1}^4+2c^2x_{1}^4+2w_{1}^3x_{1}^3+4cw_{1}^2x_{1}^3+4c^2w_{1}x_{1}^3+4c^3x_{1}^3+w_{1}^4x_{1}^2+6cw_{1}^3x_{1}^2+12c^2w_{1}^2x_{1}^2+6c^3w_{1}x_{1}^2+2c^4x_{1}^2+2cw_{1}^4x_{1}+10c^2w_{1}^3x_{1}+10c^3w_{1}^2x_{1}+2c^4w_{1}x_{1}+2c^2w_{1}^4+4c^3w_{1}^3+2c^4w_{1}^2 $$" ], "text/plain": [ "" @@ -2038,10 +1728,10 @@ { "data": { "text/plain": [ - "0" + "2" ] }, - "execution_count": 27, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -2057,7 +1747,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -2066,7 +1756,7 @@ "(1, (x, y, sqrt(2)))" ] }, - "execution_count": 28, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -2077,7 +1767,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -2086,7 +1776,7 @@ "(1, (x, y, sqrt(2)))" ] }, - "execution_count": 29, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -2097,7 +1787,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -2106,7 +1796,7 @@ "[(1, 1, 1), (0, 0, 0)]" ] }, - "execution_count": 30, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -2117,7 +1807,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -2126,7 +1816,7 @@ "[1, 58]" ] }, - "execution_count": 31, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -2137,7 +1827,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -2146,7 +1836,7 @@ "(x, y, sqrt(2), sqrt(3), sqrt(6))" ] }, - "execution_count": 32, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -2157,7 +1847,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -2166,7 +1856,7 @@ "([0], [(0, 0)], [1, 7], [(2, 0), (0, 1)], (x, y))" ] }, - "execution_count": 33, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -2188,7 +1878,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -2281,7 +1971,7 @@ "0" ] }, - "execution_count": 34, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -2292,7 +1982,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -2301,7 +1991,7 @@ "[[(1, 0), (0, 2), (0, 1), (0, 0)], [1, 1, 1, 1]]" ] }, - "execution_count": 35, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -2312,7 +2002,7 @@ }, { "cell_type": "code", - "execution_count": 168, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -2324,7 +2014,7 @@ "Poly(x + (sqrt(x)), x, sqrt(x), domain='ZZ')" ] }, - "execution_count": 168, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -2336,7 +2026,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -2345,7 +2035,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 40, "metadata": {}, "outputs": [ { @@ -2357,7 +2047,7 @@ "Poly(x**2 + 1, x, domain='ZZ')" ] }, - "execution_count": 42, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -2368,7 +2058,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -2380,7 +2070,7 @@ "Poly(x*(1/(x + y)), x, 1/(x + y), domain='ZZ')" ] }, - "execution_count": 43, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -2391,7 +2081,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -2403,7 +2093,7 @@ "Poly(x + (sqrt(x)) + (x**(1/3))**2 + (x**(1/3)) + (x**(1/4)) + sqrt(2), x, sqrt(x), x**(1/3), x**(1/4), domain='QQ')" ] }, - "execution_count": 44, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -2414,7 +2104,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -2423,7 +2113,7 @@ "[1, sqrt(6)]" ] }, - "execution_count": 45, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -2434,7 +2124,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -2443,7 +2133,7 @@ "[1, x]" ] }, - "execution_count": 47, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -2454,9 +2144,22 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 45, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py:38: SymPyDeprecationWarning: \n", + "\n", + "source has been deprecated since SymPy 1.3. Use ?? in IPython/Jupyter\n", + "or inspect.getsource instead. See\n", + "https://github.com/sympy/sympy/issues/14905 for more info.\n", + "\n", + " _warn_deprecation(wrapped, 3)\n" + ] + }, { "name": "stdout", "output_type": "stream", @@ -6569,19 +6272,6 @@ " return isinstance(g, f.__class__) and f.gens == g.gens and f.rep.eq(g.rep, strict=True)\n", "\n" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py:38: SymPyDeprecationWarning: \n", - "\n", - "source has been deprecated since SymPy 1.3. Use ?? in IPython/Jupyter\n", - "or inspect.getsource instead. See\n", - "https://github.com/sympy/sympy/issues/14905 for more info.\n", - "\n", - " _warn_deprecation(wrapped, 3)\n" - ] } ], "source": [ @@ -6590,7 +6280,7 @@ }, { "cell_type": "code", - "execution_count": 126, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -6602,7 +6292,7 @@ "Poly((sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')" ] }, - "execution_count": 126, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -6613,7 +6303,7 @@ }, { "cell_type": "code", - "execution_count": 115, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -6625,7 +6315,7 @@ "-x + sqrt(x**2)" ] }, - "execution_count": 115, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -6637,7 +6327,7 @@ }, { "cell_type": "code", - "execution_count": 130, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -6646,7 +6336,7 @@ "\"Poly((sqrt(x))**4 + (sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')\"" ] }, - "execution_count": 130, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -6657,7 +6347,7 @@ }, { "cell_type": "code", - "execution_count": 131, + "execution_count": 49, "metadata": {}, "outputs": [ { @@ -6666,7 +6356,7 @@ "\"Poly(x**2 + x + (sqrt(x)), x, sqrt(x), domain='ZZ')\"" ] }, - "execution_count": 131, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -6677,13 +6367,13 @@ }, { "cell_type": "code", - "execution_count": 164, + "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+y_{1}$" ], "text/plain": [ "" @@ -6695,7 +6385,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+z_{1}$" ], "text/plain": [ "" @@ -6717,7 +6407,7 @@ { "data": { "text/plain": [ - "(2.5326984818340415e-10, 7.129450063690368, 1.7908873553542452e-10)" + "(1.7908873553542452e-10, 2.5326984818340415e-10, 7.129450063690368)" ] }, "metadata": {}, @@ -6726,20 +6416,21 @@ { "data": { "text/plain": [ - "1.4142142855953455" + "2.5119572187973787e-11" ] }, - "execution_count": 164, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def findvalues(formula,values=None,variables=None):\n", + " formula=S(formula)\n", " num,den=fractioncancel(formula)\n", " if variables==None:\n", " variables=sorted(num.free_symbols,key=str)\n", - " num=num.subs(zip(variables,list(map(lambda x:x**2,fs))))\n", + " num=num.subs(zip(variables,list(map(lambda x:x**2,variables))))\n", " num=Poly(num)\n", " newformula=S((num.abs()+num)/(num.abs()-num))\n", " f=lambdify(variables,newformula)\n", @@ -6758,13 +6449,13 @@ }, { "cell_type": "code", - "execution_count": 156, + "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+e_{2}$" ], "text/plain": [ "" @@ -6776,7 +6467,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+f_{2}$" ], "text/plain": [ "" @@ -6790,29 +6481,19 @@ "output_type": "stream", "text": [ "ok\n", - "100 loops, best of 5: 9.06 ms per loop\n" + "100 loops, best of 5: 8.66 ms per loop\n", + "1000 loops, best of 5: 1.31 ms per loop\n" ] }, { - "ename": "TypeError", - "evalue": "int() argument must be a string, a bytes-like object or a number, not 'dict'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ok'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmagic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'timeit evaluate((random(),random(),random()))'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmagic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'timeit evaluate2((random(),random(),random()))'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 19\u001b[0m \u001b[0mPoly\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'x^2+sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0meval\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mmagic\u001b[0;34m(self, arg_s)\u001b[0m\n\u001b[1;32m 2158\u001b[0m \u001b[0mmagic_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmagic_arg_s\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0marg_s\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpartition\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m' '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2159\u001b[0m \u001b[0mmagic_name\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmagic_name\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlstrip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mprefilter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mESC_MAGIC\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2160\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_line_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmagic_name\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmagic_arg_s\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2161\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2162\u001b[0m \u001b[0;31m#-------------------------------------------------------------------------\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_line_magic\u001b[0;34m(self, magic_name, line)\u001b[0m\n\u001b[1;32m 2079\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'local_ns'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_getframe\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf_locals\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2080\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2081\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2082\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2083\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, line, cell)\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 188\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, line, cell)\u001b[0m\n\u001b[1;32m 1055\u001b[0m \u001b[0mnumber\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1056\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0m_\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1057\u001b[0;31m \u001b[0mtime_number\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtimer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimeit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnumber\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1058\u001b[0m \u001b[0mworst_tuning\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mworst_tuning\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime_number\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mnumber\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1059\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtime_number\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m0.2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, number)\u001b[0m\n\u001b[1;32m 137\u001b[0m \u001b[0mgc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 139\u001b[0;31m \u001b[0mtiming\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minner\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mit\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 140\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 141\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mgcold\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36minner\u001b[0;34m(_it, _timer)\u001b[0m\n", - "\u001b[0;32m\u001b[0m in \u001b[0;36mevaluate2\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnewformula\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msubs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mevaluate2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mnum1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mnum2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mevalf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mzip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0;31m#display(num2.eval(dict(zip(fs,(1,1,1)))))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ok'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/evalf.py\u001b[0m in \u001b[0;36mevalf\u001b[0;34m(self, n, subs, maxn, chop, strict, quad, verbose)\u001b[0m\n\u001b[1;32m 1432\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mevalf_table\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1433\u001b[0m \u001b[0m_create_evalf_table\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1434\u001b[0;31m \u001b[0mprec\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdps_to_prec\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1435\u001b[0m options = {'maxprec': max(prec, int(maxn*LG10)), 'chop': chop,\n\u001b[1;32m 1436\u001b[0m 'strict': strict, 'verbose': verbose}\n", - "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/mpmath/libmp/libmpf.py\u001b[0m in \u001b[0;36mdps_to_prec\u001b[0;34m(n)\u001b[0m\n\u001b[1;32m 65\u001b[0m \"\"\"Return the number of bits required to represent n decimals\n\u001b[1;32m 66\u001b[0m accurately.\"\"\"\n\u001b[0;32m---> 67\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mround\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;36m3.3219280948873626\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 68\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 69\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mrepr_dps\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mTypeError\u001b[0m: int() argument must be a string, a bytes-like object or a number, not 'dict'" - ] + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -6829,7 +6510,7 @@ "def evaluate(x):\n", " return newformula.evalf(subs=dict(zip(fs,(1,1,1))))\n", "def evaluate2(x):\n", - " return num1.evalf(dict(zip(fs,x)))/num2.eval(dict(zip(fs,x)))\n", + " return num1.eval(dict(zip(fs,x)))/num2.eval(dict(zip(fs,x)))\n", "#display(num2.eval(dict(zip(fs,(1,1,1)))))\n", "print('ok')\n", "%timeit evaluate((random(),random(),random()))\n", @@ -6839,18 +6520,9 @@ }, { "cell_type": "code", - "execution_count": 162, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "100000 loops, best of 5: 6.56 µs per loop\n", - "100000 loops, best of 5: 6.39 µs per loop\n" - ] - } - ], + "outputs": [], "source": [ "evaluate4=lambdify(fs,newformula)\n", "evaluate5=lambda x:evaluate4(*x)\n", @@ -6860,19 +6532,9 @@ }, { "cell_type": "code", - "execution_count": 172, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "first attempt: Poly(x**2 + x + (sqrt(x)), x, sqrt(x), domain='ZZ')\n", - "second attempt: Poly(x**2 + x + (sqrt(x)), x, sqrt(x), domain='ZZ')\n", - "third attempt: Poly((sqrt(x))**4 + (sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')\n" - ] - } - ], + "outputs": [], "source": [ "from sympy import *\n", "print('first attempt:',Poly('x^2+x+sqrt(x)'))\n", @@ -6883,7 +6545,7 @@ }, { "cell_type": "code", - "execution_count": 176, + "execution_count": 52, "metadata": {}, "outputs": [ { @@ -6895,7 +6557,7 @@ "sqrt(x) + x" ] }, - "execution_count": 176, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -6906,7 +6568,7 @@ }, { "cell_type": "code", - "execution_count": 178, + "execution_count": 55, "metadata": {}, "outputs": [ { @@ -6915,7 +6577,7 @@ "(x*(1 - x), [])" ] }, - "execution_count": 178, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -6927,7 +6589,7 @@ }, { "cell_type": "code", - "execution_count": 206, + "execution_count": 56, "metadata": {}, "outputs": [ { @@ -6936,7 +6598,7 @@ "True" ] }, - "execution_count": 206, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -6948,7 +6610,7 @@ }, { "cell_type": "code", - "execution_count": 223, + "execution_count": 57, "metadata": {}, "outputs": [ { @@ -6957,7 +6619,7 @@ "(x, 1/2)" ] }, - "execution_count": 223, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -6968,21 +6630,16 @@ }, { "cell_type": "code", - "execution_count": 222, + "execution_count": 58, "metadata": {}, "outputs": [ { - "data": { - "text/latex": [ - "$\\displaystyle \\operatorname{Poly}{\\left( x^{2} + y^{2} + \\sqrt{x + y} + \\sqrt{x} + \\sqrt[3]{x_{12}}, x, y, \\sqrt{x + y}, \\sqrt{x}, \\sqrt[3]{x_{12}}, domain=\\mathbb{Z} \\right)}$" - ], - "text/plain": [ - "Poly(x**2 + y**2 + (sqrt(x + y)) + (sqrt(x)) + (x12**(1/3)), x, y, sqrt(x + y), sqrt(x), x12**(1/3), domain='ZZ')" - ] - }, - "execution_count": 222, - "metadata": {}, - "output_type": "execute_result" + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 12)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m12\u001b[0m\n\u001b[0;31m newgens[gen[0]]=\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] } ], "source": [ @@ -6992,11 +6649,11 @@ "\telse:\n", "\t\treturn [formula,S('1')]\n", "pol=Poly('x**2+y**2+sqrt(x+y)+x**(1/2)+x**(1/3)')\n", - "genes=pol.gens\n", "newgens={}\n", - "for gen in genes:\n", - " gen=_powr(gen):\n", - " if gen[0] in newgens:\n", + "for gen in pol.gens:\n", + " base,pw=_powr(gen)\n", + " num,den=fraction(pw)\n", + " if (gen[0],num) in newgens:\n", " newgens[gen[0]]=\n", " else:\n", " newgens[gen[0]]=gen[1]" @@ -7004,27 +6661,27 @@ }, { "cell_type": "code", - "execution_count": 227, + "execution_count": 59, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "sympy.core.add.Add" + "True" ] }, - "execution_count": 227, + "execution_count": 59, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "S('x+y*6').func==" + "isinstance(S('1'),Rational)" ] }, { "cell_type": "code", - "execution_count": 229, + "execution_count": 60, "metadata": {}, "outputs": [ { @@ -7033,7 +6690,7 @@ "False" ] }, - "execution_count": 229, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } @@ -7042,6 +6699,1925 @@ "6 in {3:4,5:6}" ] }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 1$" + ], + "text/plain": [ + "1" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from math import *\n", + "from sympy import *\n", + "gcd(S('a/b'),S('c/d'))" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x^{2 \\pi}, x^{\\pi}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((x**pi)**2, x**pi, domain='ZZ')" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x^(2*pi)')" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{1}{8}$" + ], + "text/plain": [ + "1/8" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gcd(S('1/8'),S('1/4'))" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, (x, sqrt(2)))" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "S('sqrt(2)*3*x').as_coeff_mul()" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Poly((sqrt(x))**4 + (sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')\n", + "Poly((x**(1/6))**12 + (x**(1/6))**3 + (x**(1/6))**2 + y**2, x**(1/6), y, domain='ZZ')\n", + "Poly((sqrt(x)) + (sqrt(x*z)) + (sqrt(z)), sqrt(x), sqrt(x*z), sqrt(z), domain='ZZ')\n", + "Poly((sqrt(x))*(sqrt(z)) + (sqrt(x)) + (sqrt(z)), sqrt(x), sqrt(z), domain='ZZ')\n", + "Poly((sqrt(t + z)) + (sqrt(t*x + t*y + x*z + y*z)) + (sqrt(x + y)), sqrt(t + z), sqrt(t*x + t*y + x*z + y*z), sqrt(x + y), domain='ZZ')\n", + "Poly((sqrt(2)) + (sqrt(3)) + (sqrt(6)), sqrt(2), sqrt(3), sqrt(6), domain='ZZ')\n" + ] + } + ], + "source": [ + "def _powr(formula):\n", + "\tif formula.func==Pow:\n", + "\t\treturn formula.args\n", + "\telse:\n", + "\t\treturn [formula,S('1')]\n", + "def reducegens(formula):\n", + "\tpol=Poly(formula)\n", + "\tnewgens={}\n", + "\tind={}\n", + "\tfor gen in pol.gens:\n", + "\t\tbase,pw=_powr(gen)\n", + "\t\tcoef,_=pw.as_coeff_mul()\n", + "\t\tml=pw/coef\n", + "\t\tif base**ml in newgens:\n", + "\t\t\tnewgens[base**ml]=gcd(newgens[base**ml],coef)\n", + "\t\telse:\n", + "\t\t\tnewgens[base**ml]=coef\n", + "\t\t\tind[base**ml]=S('tmp'+str(len(ind)))\n", + "\tfor gen in pol.gens:\n", + "\t\tbase,pw=_powr(gen)\n", + "\t\tcoef,_=pw.as_coeff_mul()\n", + "\t\tml=pw/coef\n", + "\t\tpol=pol.replace(gen,ind[base**ml]**(coef/newgens[base**ml]))\n", + "\tnewpol=Poly(pol.as_expr())\n", + "\tfor gen in newgens:\n", + "\t\tnewpol=newpol.replace(ind[gen],gen**newgens[gen])\n", + "\treturn newpol\n", + "print(reducegens(S('x^2+x+sqrt(x)')))\n", + "print(reducegens(S('x**2+y**2+x**(1/2)+x**(1/3)')))\n", + "print(reducegens(S('sqrt(x)+sqrt(z)+sqrt(x*z)')))\n", + "print(reducegens(S('sqrt(x)+sqrt(z)+sqrt(x)*sqrt(z)')))\n", + "print(reducegens(S('sqrt(x+y)+sqrt(z+t)+sqrt((x+y)*(z+t))')))\n", + "print(reducegens(S('sqrt(2)+sqrt(3)+sqrt(6)')))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "S('-2').as_coeff_mul()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x=Symbol('x', positive=True)\n", + "y=Symbol('y', positive=True)\n", + "Poly(sqrt(x)+sqrt(y)+sqrt(x*y))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sqrt(x*y)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "simplify(S('sqrt(x*y)-sqrt(x)*sqrt(y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x=symbols('x',positive=True)\n", + "ask(Q.positive(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly('x^2+x')+Poly('-x+7')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(reducegens(S('sqrt(8)')))\n", + "sqrt(-1*-1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly('sqrt(2*x)+sqrt(3*x)+sqrt(6*x)')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly('sqrt(2*pi)+sqrt(3*pi)')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "solve(S('sqrt(6*x)')-S('sqrt(2*y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly('sqrt(6)+sqrt(10)+sqrt(14)+sqrt(15)+sqrt(21)+sqrt(35)+sqrt()')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from shiroindev import *\n", + "formula=S('(a+b-c)^2')\n", + "prove(makesubs(formula,'[c,oo]'))\n", + "prove(makesubs(formula,'[a,oo]',variables='c'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=S('(a+b-d)^2+(a+b-c)^2')\n", + "prove(makesubs(formula,'[a+b,oo],[a+b,oo]',variables='c,d'))\n", + "prove(makesubs(formula,'[0,a+b],[a+b,oo]',variables='c,d'))\n", + "prove(makesubs(formula,'[0,a+b],[0,a+b]',variables='c,d'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "findvalues(formula)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "display(cyclize('((a-b)/c)^2'))\n", + "display(S('sqrt(8)')*cyclize('(a-b)/c'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", + "display(Latex('Case $a\\ge c\\ge b$'))\n", + "formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')\n", + "prove(formula1)\n", + "display(Latex('Case $a\\ge b\\ge c$'))\n", + "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", + "prove(formula2*4,values='2**(1/2),1,1')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", + "formula2=makesubs(formula,'[c,oo],[c,oo]')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "findvalues(formula2,values=[5,2,7])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x,y=symbols('x,y')\n", + "ask(Q.positive(x**2+1),Q.real(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=Sm('(a^2+b^2+c^2)^2- 3(a^3b+b^3c+c^3a)')\n", + "formula1=makesubs(formula,'[b,oo],[c,oo]',variables='a,b')\n", + "formula2=makesubs(formula,'[c,oo],[b,oo]',variables='a,c')\n", + "prove(formula2)\n", + "print(findvalues(formula1))\n", + "#prove(formula1,values='4*b*(1-b)-1,4*c*(1-c)-1,1')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "makesubs(Sm('a^2-2ab+bc-c^2+ca'),'[c,oo],[a,oo]',variables='b,c')" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle - \\sqrt{x} \\sqrt{y} + \\sqrt{x y}$" + ], + "text/plain": [ + "-sqrt(x)*sqrt(y) + sqrt(x*y)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 0$" + ], + "text/plain": [ + "0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "\n", + "formula=S('sqrt(x*y)-sqrt(x)*sqrt(y)')\n", + "display(formula)\n", + "def assumeall(formula,**kwargs):\n", + " formula=S(formula)\n", + " fs=formula.free_symbols\n", + " for x in fs:\n", + " y=Symbol(str(x),**kwargs)\n", + " formula=formula.subs(x,y)\n", + " return formula\n", + "display(assumeall(formula,positive=True))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly(assumeall('x+sqrt(x)',positive=True))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "str(type(S('f1(x,y,z)')))=='f1'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ReprPrinter?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "srepr(S('x^2+f(x)+f(x,y)+f()+sqrt(y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sympy import Function,srepr,S\n", + "import re\n", + "f=Function('f')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def allsymbols(formula):\n", + " formula=S(formula)\n", + " funcsymbols=[x[10:-2] for x in re.findall(r\"Function\\(\\'.*?\\'\\)\",srepr(formula))]\n", + " return set(funcsymbols)|set(map(str,formula.free_symbols))\n", + "def vargen(n):\n", + " x='abcdefghijklmnopqrstuvwxyz'[n%26]\n", + " if n>=26:\n", + " x+=str(n//26)\n", + " return x\n", + "allsymbols(S('f(5,7)+f(5)+g(8)+sqrt(x*y)'))\n", + "vargen(36)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sympy import *\n", + "from sympy.printing.repr import *\n", + "ReprPrinter??" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "{5,7} | {8,7}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "[x[10:-2] for x in re.findall(r\"Function\\(\\'.*?\\'\\)\",srepr(S('x^2')))]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "S('f(5,7)+f(5)+g(8)+sqrt(x*y)')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "srepr(S('f(5,7)+f(5)+g(8)+sqrt(x*y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "display(Latex('$'+str(S('z12345'))+'$'))" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: ''", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;34m'xyz'\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m''\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: ''" + ] + } + ], + "source": [ + "'xyz'[-2::]" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [], + "source": [ + "def sortkey(x):\n", + " x=str(x)\n", + " i=len(x)-1\n", + " while i>=0:\n", + " if x[i] not in '0123456789':\n", + " break\n", + " i-=1\n", + " if i==len(x)-1:\n", + " return (-1,x)\n", + " return (int(x[i+1:]),x[:i+1])" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[x, y, x0, qq1, z1, t2]" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sorted(S('x,y,z1,t2,qq1,x0'),key=sortkey)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.154701\n", + " Iterations: 85\n", + " Function evaluations: 152\n" + ] + }, + { + "data": { + "text/plain": [ + "[1.0,\n", + " 3.000209557356011,\n", + " 3.9998018341331227,\n", + " 2.9997236704279775,\n", + " 0.999903278712487]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2')\n", + "formula=S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2- (x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')\n", + "values=findvalues(formula)\n", + "values=[value/values[0] for value in values]\n", + "[value**2 for value in values]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{2 \\sqrt{3}}{3}$" + ], + "text/plain": [ + "2*sqrt(3)/3" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula1=S('(x_1^2+x_2^2+x_3^2+x_4^2+x_5^2)/(x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')\n", + "formula1.subs(S('[[x_1,1],[x_2,sqrt(3)],[x_3,2],[x_4,sqrt(3)],[x_5,1]]'))" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "formula2=S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2- (2/sqrt(3))*(x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $x_{2}\\to \\sqrt{3} g$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $x_{3}\\to 2 h$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $x_{4}\\to \\sqrt{3} i$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $3 g^{2} - 4 g h - 2 g x_{1} + 4 h^{2} - 4 h i + 3 i^{2} - 2 i x_{5} + x_{1}^{2} + x_{5}^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 g h \\le 2 g^{2}+2 h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 g x_{1} \\le g^{2}+x_{1}^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 h i \\le 2 h^{2}+2 i^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 i x_{5} \\le i^{2}+x_{5}^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove(formula2,values='1,sqrt(3),2,sqrt(3),1')" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{k}a^{n}, a^{k}, a^{n}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((a**k)*(a**n), a**k, a**n, domain='ZZ')" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('a^(n+k)')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'FiniteSet' object has no attribute 'as_coeff_Mul'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'a^{n+k}/{b^n}+{b^{n+k}}/{c^n}+{c^{n+k}}/{a^n}-( a^k+b^k+c^k)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/sympify.py\u001b[0m in \u001b[0;36msympify\u001b[0;34m(a, locals, convert_xor, strict, rational, evaluate)\u001b[0m\n\u001b[1;32m 382\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 383\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreplace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'\\n'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 384\u001b[0;31m \u001b[0mexpr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparse_expr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_dict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlocals\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtransformations\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtransformations\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mevaluate\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mevaluate\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 385\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mTokenError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSyntaxError\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 386\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mSympifyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'could not parse %r'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/parsing/sympy_parser.py\u001b[0m in \u001b[0;36mparse_expr\u001b[0;34m(s, local_dict, transformations, global_dict, evaluate)\u001b[0m\n\u001b[1;32m 964\u001b[0m \u001b[0mcode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mevaluateFalse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'eval'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 965\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 966\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0meval_expr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_dict\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mglobal_dict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 967\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 968\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/parsing/sympy_parser.py\u001b[0m in \u001b[0;36meval_expr\u001b[0;34m(code, local_dict, global_dict)\u001b[0m\n\u001b[1;32m 877\u001b[0m \"\"\"\n\u001b[1;32m 878\u001b[0m expr = eval(\n\u001b[0;32m--> 879\u001b[0;31m code, global_dict, local_dict) # take local objects in preference\n\u001b[0m\u001b[1;32m 880\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 881\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/expr.py\u001b[0m in \u001b[0;36m__pow__\u001b[0;34m(self, other, mod)\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmod\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_pow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 166\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[0m_self\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py\u001b[0m in \u001b[0;36m__sympifyit_wrapper\u001b[0;34m(a, b)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'_op_priority'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msympify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstrict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 91\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mSympifyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mretval\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py\u001b[0m in \u001b[0;36mbinary_op_wrapper\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 127\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mf\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 128\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 129\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 130\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mbinary_op_wrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpriority_decorator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/expr.py\u001b[0m in \u001b[0;36m_pow\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mcall_highest_priority\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'__rpow__'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 160\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_pow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 161\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mPow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 162\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/cache.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 94\u001b[0;31m \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 95\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 96\u001b[0m \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/power.py\u001b[0m in \u001b[0;36m__new__\u001b[0;34m(cls, b, e, evaluate)\u001b[0m\n\u001b[1;32m 274\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Atom\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mb\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mExp1\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp_polar\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 275\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0msympy\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdenom\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlog\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msign\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mim\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfactor_terms\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 276\u001b[0;31m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfactor_terms\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msign\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_coeff_Mul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 277\u001b[0m \u001b[0mden\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdenom\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 278\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mden\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlog\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mden\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: 'FiniteSet' object has no attribute 'as_coeff_Mul'" + ] + } + ], + "source": [ + "S('a^{n+k}/{b^n}+{b^(n+k)/(c^n)+c^(n+k)/{a^n}-( a^k+b^k+c^k)')" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'767980716'" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import re\n", + "s=r\"\"\"99-my-name-is-John-Smith-6376827-%^-1-2-767980716\"\"\"\n", + "re.compile(r\"^(.*?)-\").search(str(s[::-1])).group(1)[::-1]" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] + }, + { + "data": { + "text/latex": [ + "numerator: $a^{k} a^{2 n} c^{n} - a^{k} a^{n} b^{n} c^{n} + a^{n} b^{k} b^{2 n} - a^{n} b^{k} b^{n} c^{n} - a^{n} b^{n} c^{k} c^{n} + b^{n} c^{k} c^{2 n}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 2" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Program couldn't find any proof." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ a^{k} a^{n} b^{n} c^{n}+a^{n} b^{k} b^{n} c^{n}+a^{n} b^{n} c^{k} c^{n} \\le a^{k} a^{2 n} c^{n}+a^{n} b^{k} b^{2 n}+b^{n} c^{k} c^{2 n} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $n\\to d + k$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $a^{2 d} a^{3 k} c^{d} c^{k} - a^{d} a^{2 k} b^{d} b^{k} c^{d} c^{k} + a^{d} a^{k} b^{2 d} b^{3 k} - a^{d} a^{k} b^{d} b^{2 k} c^{d} c^{k} - a^{d} a^{k} b^{d} b^{k} c^{d} c^{2 k} + b^{d} b^{k} c^{2 d} c^{3 k}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 2" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Program couldn't find any proof." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ a^{d} a^{2 k} b^{d} b^{k} c^{d} c^{k}+a^{d} a^{k} b^{d} b^{2 k} c^{d} c^{k}+a^{d} a^{k} b^{d} b^{k} c^{d} c^{2 k} \\le a^{2 d} a^{3 k} c^{d} c^{k}+a^{d} a^{k} b^{2 d} b^{3 k}+b^{d} b^{k} c^{2 d} c^{3 k} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sympy import *\n", + "from sympy.parsing.latex import parse_latex\n", + "from shiroindev import *\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))\n", + "formula=expand(parse_latex(r'(\\frac{a^{n+k}}{b^n}+\\frac{b^{n+k}}{c^n}+\\frac{c^{n+k}}{a^n}-( a^k+b^k+c^k))*a^nb^nc^n'))\n", + "newproof()\n", + "prove(formula)\n", + "prove(makesubs(formula,['k',oo],variables='n'))" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 6 x^{3}y^{9} + 5 x^{2}y^{7} + 4 xy^{8}, x, y, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(6*x**3*y**9 + 5*x**2*y**7 + 4*x*y**8, x, y, domain='ZZ')" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly(dict(zip([(1,8),(2,7),(3,9)],[4,5,6])),gens=S('x,y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\sqrt{x} + x^{2} + x$" + ], + "text/plain": [ + "sqrt(x) + x**2 + x" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly({1:1,2:1,4:1},gens=S('sqrt(x)')).as_expr()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "def _writ2(coef,fun,variables):\n", + "\treturn latex(Poly(dict(zip(fun,coef)),gens=variables).as_expr())" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'8 x^{3} y^{4} + 7 x y^{2}'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "_writ2([7,8],[(1,2),(3,4)],S('x,y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 2 a b$" + ], + "text/plain": [ + "2*(a*b)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse_latex(r' a^2+b^2\\geq 2ab').rhs" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle a^{2} + b^{2}$" + ], + "text/plain": [ + "a**2 + b**2" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse_latex(r'2ab \\geq a^2+b^2').rhs" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "numerator: $a d + a f + b c + b e + c f + d e - 2 \\sqrt{a b} \\sqrt{c d} - 2 \\sqrt{a b} \\sqrt{e f} - 2 \\sqrt{c d} \\sqrt{e f}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Poly((sqrt(a))**2*(sqrt(d))**2 + (sqrt(a))**2*(sqrt(f))**2 - 2*(sqrt(a))*(sqrt(b))*(sqrt(c))*(sqrt(d)) - 2*(sqrt(a))*(sqrt(b))*(sqrt(e))*(sqrt(f)) + (sqrt(b))**2*(sqrt(c))**2 + (sqrt(b))**2*(sqrt(e))**2 + (sqrt(c))**2*(sqrt(f))**2 - 2*(sqrt(c))*(sqrt(d))*(sqrt(e))*(sqrt(f)) + (sqrt(d))**2*(sqrt(e))**2, sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='ZZ')\n", + "Poly((sqrt(a))**2*(sqrt(d))**2 + (sqrt(a))**2*(sqrt(f))**2 + (sqrt(b))**2*(sqrt(c))**2 + (sqrt(b))**2*(sqrt(e))**2 + (sqrt(c))**2*(sqrt(f))**2 + (sqrt(d))**2*(sqrt(e))**2, sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='QQ')\n", + "Poly(2*(sqrt(a))*(sqrt(b))*(sqrt(c))*(sqrt(d)) + 2*(sqrt(a))*(sqrt(b))*(sqrt(e))*(sqrt(f)) + 2*(sqrt(c))*(sqrt(d))*(sqrt(e))*(sqrt(f)), sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='QQ')\n" + ] + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 \\sqrt{a} \\sqrt{b} \\sqrt{c} \\sqrt{d} \\le a d+b c$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 \\sqrt{a} \\sqrt{b} \\sqrt{e} \\sqrt{f} \\le a f+b e$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 \\sqrt{c} \\sqrt{d} \\sqrt{e} \\sqrt{f} \\le c f+d e$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 45, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fr=parse_latex(r'\\sqrt{ab}+\\sqrt{cd}+\\sqrt{ef}\\leq\\sqrt{(a+c+e)(b+d+f)}')\n", + "prove(fr.rhs**2-fr.lhs**2)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 0$" + ], + "text/plain": [ + "0" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "assumeall(S('sqrt(x*y)-sqrt(x)*sqrt(y)'),positive=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "ename": "GeneratorsError", + "evalue": "duplicated generators: [sqrt(x), sqrt(x)]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mGeneratorsError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mreducegens\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'x+sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'x+sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPoly\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPoly\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polytools.py\u001b[0m in \u001b[0;36m__new__\u001b[0;34m(cls, rep, *gens, **args)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__new__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrep\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;34m\"\"\"Create a new polynomial instance out of something useful. \"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 109\u001b[0;31m \u001b[0mopt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0moptions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuild_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 110\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'order'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mopt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mbuild_options\u001b[0;34m(gens, args)\u001b[0m\n\u001b[1;32m 729\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 730\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;34m'opt'\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0margs\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mgens\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 731\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mOptions\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 732\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 733\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'opt'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, gens, args, flags, strict)\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0moption\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpreprocess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 154\u001b[0;31m \u001b[0mpreprocess_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 155\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdefaults\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mpreprocess_options\u001b[0;34m(args)\u001b[0m\n\u001b[1;32m 150\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 152\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0moption\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpreprocess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[0mpreprocess_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mpreprocess\u001b[0;34m(cls, gens)\u001b[0m\n\u001b[1;32m 289\u001b[0m \u001b[0mgens\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 290\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mhas_dups\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 291\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mGeneratorsError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"duplicated generators: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 292\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0many\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgen\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_commutative\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mFalse\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mgen\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 293\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mGeneratorsError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"non-commutative generators: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mGeneratorsError\u001b[0m: duplicated generators: [sqrt(x), sqrt(x)]" + ] + } + ], + "source": [ + "p=reducegens('x+sqrt(x)')\n", + "q=S('x+sqrt(x)')\n", + "print(Poly(p,gens=[S('sqrt(x)'),S('sqrt(x)')]))\n", + "print(Poly(q,gens=S('sqrt(x)')))" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "from importlib import reload\n", + "from sympy import *\n", + "import shiroindev\n", + "reload(shiroindev)\n", + "from shiroindev import *\n", + "from sympy.parsing.latex import parse_latex\n", + "from itertools import permutations, combinations\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x, \\sqrt{x}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((sqrt(x))**2, sqrt(x), domain='ZZ')" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('sqrt(x)')*Poly('sqrt(x)')" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 0, x, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(0, x, domain='ZZ')" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x')-Poly('x').abs()" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x, x, y, domain=\\mathbb{Q} \\right)}$" + ], + "text/plain": [ + "Poly(x, x, y, domain='QQ')" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fr=Poly('x-y')\n", + "(fr+fr.abs())*(S('1/2'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from itertools import permutations \n", + "t5=[]\n", + "for ineq in ineqs2:\n", + " u=0\n", + " for vars in permutations(ineq.free_symbols):\n", + " ineqp=makesubs(ineq,list(zip(vars[1:],[oo]*len(vars[1:]))),variables=vars[:-1])\n", + " u=max(u,prove(ineqp))\n", + " print(u,end=',')\n", + " t5+=[u]\n", + "Counter(t5)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pvalue 4.43444926375551e-06\n", + "statistic 59.0\n" + ] + } + ], + "source": [ + "from statsmodels.stats.contingency_tables import mcnemar\n", + "print(mcnemar([[101,121],[59,33]]))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "nsimplify?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shiro.display=lambda x:display(Latex(x))\n", + "newproof()\n", + "fr=makesubs(ineqs2[15],'[c,oo],[a,oo]',variables='b,c')\n", + "display(fr)\n", + "fr2=fractioncancel(fr.subs(S('[[e,(sqrt(5)-1)/2*f]]')))[0]\n", + "display(fr2)\n", + "prove(makesubs(fr2,'11/5,9/4',variables=[S('sqrt(5)')]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def makesubs(formula,intervals,values=None,variables=None,numden=False):\n", + "#This function generates a new formula which satisfies this condition:\n", + "#for all positive variables new formula is nonnegative iff\n", + "#for all variables in corresponding intervals old formula is nonnegative\n", + "\tformula=S(formula)\n", + "\taddsymbols(formula)\n", + "\tintervals=_smakeiterable2(intervals)\n", + "\tif variables: variables=_smakeiterable(variables)\n", + "\telse: variables=sorted(formula.free_symbols,key=str)\n", + "\tif values!=None:\n", + "\t\tvalues=_smakeiterable(values)\n", + "\t\tequations=[var-value for var,value in zip(variables,values)]\n", + "\telse:\n", + "\t\tequations=[]\n", + "\tnewvars=[]\n", + "\tusedvars=set()\n", + "\tfor var,interval in zip(variables,intervals):\n", + "\t\tend1,end2=interval\n", + "\t\tz=newvar()\n", + "\t\tnewvars+=[z]\n", + "\t\tusedvars|={z}\n", + "\t\tif (end1.free_symbols|end2.free_symbols)&usedvars:\n", + "\t\t\tshiro.warning(shiro.translation[\n", + "\t\t\t'Warning: intervals contain backwards dependencies. Consider changing order of variables'])\n", + "\t\tif end1 in {S('-oo'),S('oo')}:\n", + "\t\t\tend1,end2=end2,end1\n", + "\t\tif {end1,end2}=={S('-oo'),S('oo')}:\n", + "\t\t\tsub1=sub2=(z-1/z)\n", + "\t\telif end2==S('oo'):\n", + "\t\t\tsub1=sub2=(end1+z)\n", + "\t\telif end2==S('-oo'):\n", + "\t\t\tsub1=sub2=end1-z\n", + "\t\telse:\n", + "\t\t\tsub1=end2+(end1-end2)/z\n", + "\t\t\tsub2=end2+(end1-end2)/(1+z)\n", + "\t\tformula=formula.subs(var,sub1)\n", + "\t\tshiro.display(shiro.translation['Substitute']+\" $\"+latex(var)+'\\\\to '+latex(sub2)+'$')\n", + "\t\tequations=[equation.subs(var,sub1) for equation in equations]\n", + "\tnum,den=fractioncancel(formula)\n", + "\tfor var,interval in zip(newvars,intervals):\n", + "\t\tif {interval[0],interval[1]} & {S('oo'),S('-oo')}==set():\n", + "\t\t\tnum=num.subs(var,var+1)\n", + "\t\t\tden=den.subs(var,var+1)\n", + "\t\t\tequations=[equation.subs(var,var+1) for equation in equations]\n", + "\tif values:\n", + "\t\tvalues=ssolve(equations,newvars)\n", + "\t\tif len(values):\n", + "\t\t\tvalues=values[0]\n", + "\tnum,den=expand(num),expand(den)\n", + "\t#shiro.display(shiro.translation[\"Formula after substitution:\"],\"$$\",latex(num/den),'$$')\n", + "\tif values and numden:\n", + "\t\treturn num,den,values\n", + "\telif values:\n", + "\t\treturn num/den,values\n", + "\telif numden:\n", + "\t\treturn num,den\n", + "\telse:\n", + "\t\treturn num/den" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{3, 5, 7, 8}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x={5,7,8}\n", + "x|={3}\n", + "x" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{x}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from shiroindev import *\n", + "S('x+7').free_symbols" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bool(set())" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $x\\to - y + 1 + \\frac{y - 1}{a + 1}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $b\\to \\frac{c}{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $a^{4} c^{2} + a^{3} c^{2} - 2 a^{3} c - 4 a^{2} c + 4 a^{2} + a c^{2} - 2 a c + c^{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $a^{3} c^{2} + 2 a^{3} c + 2 a^{2} c^{2} + 4 a^{2} c + a c^{2} + 2 a c$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a^{3} c \\le a^{4} c^{2}+a^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 a^{2} c \\le a^{3} c^{2}+2 a^{2}+a c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 a c \\le a^{2}+c^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from importlib import reload\n", + "newproof()\n", + "import shiroindev\n", + "reload(shiroindev)\n", + "from shiroindev import *\n", + "shiro.display=lambda x:display(Latex(x))\n", + "formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))\n", + "newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')\n", + "prove(newformula,values)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [], + "source": [ + "def findvalues(formula,values=None,variables=None,**kwargs):\n", + "\t\"\"\"finds a candidate for parameter \"values\" in \"prove\" function\n", + "\tblabla\"\"\"\n", + "\tformula=S(formula)\n", + "\taddsymbols(formula)\n", + "\tnum,den=fractioncancel(formula)\n", + "\tif variables==None:\n", + "\t\tvariables=sorted(formula.free_symbols,key=str)\n", + "\tnum=num.subs(zip(variables,list(map(lambda x:x**2,variables))))\n", + "\tnum=Poly(num)\n", + "\tnewformula=S((num.abs()+num)/(num.abs()-num))\n", + "\tf=lambdify(variables,newformula)\n", + "\tf2=lambda x:f(*x)\n", + "\tif values==None:\n", + "\t\tvalues=[1.0]*len(variables)\n", + "\telse:\n", + "\t\tvalues=S(values)\n", + "\ttup=tuple(fmin(f2,values,**kwargs))\n", + "\treturn tuple([x*x for x in tup])" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.000000\n", + " Iterations: 51\n", + " Function evaluations: 109\n" + ] + }, + { + "data": { + "text/plain": [ + "(1.9999999989778676, 0.6689493176765962)" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "findvalues(Sm('(x^2-4x+4)/y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [], + "source": [ + "findvalues?" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/.ipynb_checkpoints/statistics-checkpoint.ipynb b/.ipynb_checkpoints/statistics-checkpoint.ipynb new file mode 100644 index 0000000..ad6b447 --- /dev/null +++ b/.ipynb_checkpoints/statistics-checkpoint.ipynb @@ -0,0 +1,476 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this notebook several methods for proving inequalities have been compared.\n", + "\n", + "First of all we need a dataset. 35 inequalities were selected from https://www.imomath.com/index.php?options=592&lmm=0. Each inequality is represented by a tuple: inequality (in LaTeX), inequality constraints (for example: $a\\in [0,1]$, equality constraints (for example: $abc=1$) and a function which converts inequality to a formula which we want to prove it's nonnegativity. In most cases when this function is simply a difference between left and right-hand side, but sometimes it's better to use difference between squares of sides (to get rid of square roots). These tuples are used as parameters in `parser` function which converts them to equivalent inequalities with default constraints (i.e. all variables are positive).\n", + "\n", + "Some tuples have less than 4 elements. In this case `parser` use default arguments." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from importlib import reload\n", + "from sympy import *\n", + "import shiroindev\n", + "from shiroindev import *\n", + "from sympy.parsing.latex import parse_latex\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "`sympy` has a `parse_latex` function which converts LaTeX formula to a `sympy` one. Unfortunately it doesn't deal with missing braces in the way that LaTeX do. For example `\\frac12` generates $\\frac12$ which is the same as `\\frac{1}{2}`, but `parse_latex` accepts only the second version. So here there is a boring function which adds missing braces." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\\frac{ \\sqrt {3}}{2}\n", + "a^2+b^2+c^2\\geq ab+bc+ca\n" + ] + } + ], + "source": [ + "def addbraces(s):\n", + " arg={r'\\frac':2,r'\\sqrt':1}\n", + " s2=''\n", + " p=0\n", + " while 1:\n", + " m=re.search(r\"\\\\[a-zA-Z]+\", s[p:])\n", + " if not m:\n", + " break\n", + " s2+=s[p:p+m.end()]\n", + " #print('a',s[p:m.end()],p)\n", + " p+=m.end()\n", + " if m.group() in arg:\n", + " for i in range(arg[m.group()]):\n", + " sp=re.search('^ *',s[p:])\n", + " s2+=sp.group()\n", + " #print('b',sp.group(),p)\n", + " p+=sp.end()\n", + " if s[p]=='{':\n", + " cb=re.search(r'^\\{.*?\\}',s[p:])\n", + " ab=addbraces(cb.group())\n", + " s2+=ab\n", + " #print('c',ab,p)\n", + " p+=cb.end()\n", + " else:\n", + " s2+='{'+s[p]+'}'\n", + " #print('d','{'+s[p]+'}',p)\n", + " p+=1\n", + " #print('e',p)\n", + " s2+=s[p:]\n", + " return s2\n", + "print(addbraces(r'\\frac{ \\sqrt 3}2'))\n", + "print(addbraces(r'a^2+b^2+c^2\\geq ab+bc+ca'))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#(formula,intervals,subs,function)\n", + "dif=lambda b,s:b-s\n", + "dif2=lambda b,s:b*b-s*s\n", + "ineqs=[\n", + " (r'a^2+b^2+c^2\\geq ab+bc+ca',),\n", + " (r'a^2+b^2+c^2+d^2\\geq a(b+c+d)',),\n", + " (r'1\\leq\\frac{a^2b^2}{c^2}+\\frac{b^2c^2}{a^2}+\\frac{c^2a^2}{b^2}',\n", + " '[0,1-f],[0,1]','[a,sqrt(1-e-f)],[b,sqrt(e)],[c,sqrt(f)]',),\n", + " (r'\\frac1{1-x^2}+\\frac1{1-y^2}\\geq \\frac2{1-xy}','[0,1],[0,1]'),\n", + " (r'a^3+b^3\\geq a^2b+ab^2',),\n", + " (r'\\frac a{b+c}+\\frac b{c+a}+\\frac c{a+b}\\geq \\frac32',),\n", + " (r'2a^3+b^3\\geq 3a^2b',),\n", + " (r'a^3+b^3+c^3\\geq a^2b+b^2c+c^2a',),\n", + " (r'\\frac a{b+c}+\\frac b{c+d}+ \\frac c{d+a}+ \\frac d{a+b}\\geq 2',),\n", + " (r'\\frac{a^3}{a^2+ab+b^2}+ \\frac{b^3}{b^2+bc+c^2}+ \\frac{c^3}{c^2+ca+a^2} \\geq \\frac{a+b+c}3',),\n", + " (r'\\sqrt{ab}+\\sqrt{cd}+\\sqrt{ef}\\leq\\sqrt{(a+c+e)(b+d+f)}','','',dif2),\n", + " (r'\\frac{5a^3-ab^2}{a+b}+\\frac{5b^3-bc^2}{b+c}+\\frac{5c^3-ca^2}{c+a}\\geq 2(a^2+b^2+c^2)',),\n", + " #(r'\\frac{a^2}{(1+b)(1-c)}+\\frac{b^3}{(1+c)(1-d)}+\\frac{c^3}{(1+d)(1-a)}+\\frac{d^3}{(1+a)(1-b)}\\geq\\frac1{15}',\n", + " # '[0,1-c-d],[0,1-d],[0,1]','[a,1-b-c-d]'),\n", + " (r'\\frac{x^3}{(1+y)(1+z)}+\\frac{y^3}{(1+z)(1+x)}+\\frac{z^3}{(1+x)(1+y)}\\geq\\frac{3}{4}','','[z,1/(x*y)]'),\n", + " (r'\\frac ab+\\frac bc+\\frac ca\\geq \\frac{(a+b+c)^2}{ab+bc+ca}',),\n", + " (r'\\frac{a^2}b+\\frac{b^2}c+\\frac{c^2}a\\geq \\frac{a^2+b^2+c^2}{a+b+c}',),\n", + " (r'\\frac{a^2}b+\\frac{b^2}c+\\frac{c^2}a\\geq a+b+c+\\frac{4(a-b)^2}{a+b+c}',),\n", + " (r'\\frac1{a^3+b^3+abc}+ \\frac1{b^3+c^3+abc} +\\frac1{c^3+a^3+ abc} \\leq \\frac1{abc}',),\n", + " (r'\\frac1{a^3(b+c)}+ \\frac1{b^3(c+a)}+ \\frac1{c^3(a+b)} \\geq \\frac32','','[c,1/(a*b)]'),\n", + " (r'\\frac{a^3}{b^2-bc+c^2}+\\frac{b^3}{c^2-ca+a^2} + \\frac{c^3}{a^2-ab+b^2} \\geq 3 \\cdot\\frac{ab+bc+ca}{a+b+c}',),\n", + " (r'\\frac{x^5-x^2}{x^5+y^2+z^2}+\\frac{y^5-y^2}{y^5+z^2+x^2}+\\frac{z^5-z^2}{z^5+x^2+y^2}\\geq0','','[x,1/(y*z)]'),\n", + " (r'(a+b-c)(b+c-a)(c+a-b)\\leq abc',),\n", + " (r'\\frac1{1+xy}+\\frac1{1+yz}+\\frac1{1+zx}\\leq \\frac34','','[x,(y+z)/(y*z-1)]'),\n", + " (r'\\frac{x\\sqrt x}{y+z}+\\frac{y\\sqrt y}{z+x}+\\frac{z\\sqrt z}{x+y}\\geq\\frac{ \\sqrt 3}2',\n", + " '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'a^4+b^4+c^4+d^4\\geq 4abcd',),\n", + " (r'\\frac{ab}{a+b}+\\frac{bc}{b+c}+\\frac{ca}{c+a}\\leq\\frac{3(ab+bc+ca)}{2(a+b+c)}',),\n", + " (r'\\sqrt{a-1}+\\sqrt{b-1}+ \\sqrt{c-1} \\leq \\sqrt{c(ab+1)}','[1,oo],[1,oo],[1,oo]','',dif2),\n", + " (r'(x-1)(y-1)(z-1)\\geq 8','[0,1-b-c],[0,1-c],[0,1]','[x,1/a],[y,1/b],[z,1/c]'),\n", + " (r'ay+bz+cx\\leq s^2','[0,s],[0,s],[0,s]','[x,s-a],[y,s-b],[z,s-c]'),\n", + " (r'x_1^2+x_2^2+x_3^2+x_4^2+x_5^2\\geq 2 (x_1x_2+x_2x_3+x_3x_4+x_4x_5)/\\sqrt{3}',),\n", + " (r' xy+yz+zx - 2xyz \\leq \\frac7{27}', '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'0 \\leq xy+yz+zx - 2xyz', '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'\\sqrt{3+a+b+c}\\geq\\sqrt a+\\sqrt b+\\sqrt c','[1-z,1],[0,1]','[a,1/x-1],[b,1/y-1],[c,1/z-1],[x,2-y-z]',\n", + " dif2),\n", + " (r'\\frac{2a^3}{a^2+b^2}+\\frac{2b^3}{b^2+c^2}+\\frac{2c^3}{c^2+a^2}\\geq a+b+c',),\n", + " (r'\\frac{a^2}{b+c}+\\frac{b^2}{c+a}+\\frac{c^2}{a+b}\\geq \\frac12','[0,1-c],[0,1]','[a,1-b-c]'),\n", + " (r'\\frac{a+b}{2b+c}+\\frac{b+c}{2c+a}+\\frac{c+a}{2a+b}\\geq 2',),\n", + " #(r'\\frac x{5-y^2}+\\frac y{5-z^2}+\\frac z{5-x^2}\\geq \\frac34','[0,sqrt(5)],[0,sqrt(5)]','[x,1/(y*z)]')\n", + "]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "def parser(formula,intervals='[]',subs='[]',func=dif):\n", + " newproof()\n", + " shiro.display=lambda x:None\n", + " #display=lambda x:None\n", + " if intervals=='':\n", + " intervals='[]'\n", + " if subs=='':\n", + " subs='[]'\n", + " formula=addbraces(formula)\n", + " formula=Sm(str(parse_latex(formula)))\n", + " formula,_=fractioncancel(formula)\n", + " formula=formula.subs(shiroindev._smakeiterable2(subs))\n", + " formula=makesubs(formula,intervals)\n", + " b,s=formula.lhs,formula.rhs\n", + " if type(formula)==LessThan:\n", + " b,s=s,b\n", + " formula=func(b,s)\n", + " formula=simplify(formula)\n", + " num,den=fractioncancel(formula)\n", + " return num" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + " 74%|███████▍ | 26/35 [00:21<00:07, 1.21it/s]\n" + ] + }, + { + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mineqs2\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mineq\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtqdm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mineqs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mineqs2\u001b[0m\u001b[0;34m+=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mparser\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mineq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mparser\u001b[0;34m(formula, intervals, subs, func)\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0mformula\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0ms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 18\u001b[0;31m \u001b[0mformula\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msimplify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 19\u001b[0m \u001b[0mnum\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mden\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfractioncancel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnum\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/simplify/simplify.py\u001b[0m in \u001b[0;36msimplify\u001b[0;34m(expr, ratio, measure, rational, inverse)\u001b[0m\n\u001b[1;32m 560\u001b[0m \u001b[0m_e\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcancel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 561\u001b[0m \u001b[0mexpr1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mshorter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_e\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_mexpand\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_e\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcancel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# issue 6829\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 562\u001b[0;31m \u001b[0mexpr2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mshorter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtogether\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdeep\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtogether\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdeep\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 563\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 564\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mratio\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mInfinity\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36mtogether\u001b[0;34m(expr, deep, fraction)\u001b[0m\n\u001b[1;32m 83\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 84\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 85\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msympify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m_together\u001b[0;34m(expr)\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 79\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0marg\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0miterable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mex\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 79\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0marg\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0miterable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mex\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m_together\u001b[0;34m(expr)\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 67\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Add\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 68\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mgcd_terms\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_together\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mAdd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfraction\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfraction\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 69\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Pow\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[0mbase\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m_together\u001b[0;34m(expr)\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 79\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0marg\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0miterable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mex\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 77\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 78\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 79\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0marg\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 80\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0miterable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 81\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__class__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mex\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mexpr\u001b[0m \u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/rationaltools.py\u001b[0m in \u001b[0;36m_together\u001b[0;34m(expr)\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 67\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Add\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 68\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mgcd_terms\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlist\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0m_together\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mAdd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_args\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfraction\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfraction\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 69\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Pow\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 70\u001b[0m \u001b[0mbase\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_together\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexpr\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbase\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36mgcd_terms\u001b[0;34m(terms, isprimitive, clear, fraction)\u001b[0m\n\u001b[1;32m 1061\u001b[0m \u001b[0mterms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msympify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1062\u001b[0m \u001b[0mterms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreps\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmask\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1063\u001b[0;31m \u001b[0mcont\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdenom\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_gcd_terms\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterms\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0misprimitive\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfraction\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1064\u001b[0m \u001b[0mnumer\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mxreplace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mreps\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1065\u001b[0m \u001b[0mcoeff\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfactors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcont\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_coeff_Mul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36m_gcd_terms\u001b[0;34m(terms, isprimitive, fraction)\u001b[0m\n\u001b[1;32m 954\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 955\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mterm\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mterms\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 956\u001b[0;31m \u001b[0mterms\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mterm\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mquo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcont\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 957\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 958\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mfraction\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36mquo\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 872\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 873\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mquo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# Term\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 874\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 875\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 876\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mpow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# Term\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36mmul\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 864\u001b[0m \u001b[0mdenom\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdenom\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdenom\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 865\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 866\u001b[0;31m \u001b[0mnumer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdenom\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnormal\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdenom\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 867\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 868\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mTerm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcoeff\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdenom\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36mnormal\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 556\u001b[0m \u001b[0;32mdel\u001b[0m \u001b[0mother_factors\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfactor\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 557\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 558\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mFactors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself_factors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mFactors\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother_factors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 559\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 560\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdiv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# Factors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/exprtools.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, factors)\u001b[0m\n\u001b[1;32m 367\u001b[0m \u001b[0mhandle\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 368\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mfactors\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 369\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mI\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 370\u001b[0m \u001b[0mhandle\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 371\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mhandle\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/basic.py\u001b[0m in \u001b[0;36m__eq__\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 333\u001b[0m \u001b[0;31m# (https://github.com/sympy/sympy/issues/4269), we only compare\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 334\u001b[0m \u001b[0;31m# types in Python 2 directly if they actually have __ne__.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 335\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mPY3\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__ne__\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mtype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__ne__\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 336\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtself\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mtother\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 337\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;32mFalse\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: " + ] + } + ], + "source": [ + "from tqdm import tqdm\n", + "ineqs2=[]\n", + "for ineq in tqdm(ineqs):\n", + " ineqs2+=[parser(*ineq)]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's look at the formulas when converted to polynomials." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i,ineq in zip(range(len(ineqs2)),ineqs2):\n", + " print(i)\n", + " display(reducegens(assumeall(ineq,positive=True)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Most formulas was converted to polynomials of independent variables. However formulas No. 22 and No. 31 were not. For this reason it's very unlikely that any method of proving these ones will succeed.\n", + "\n", + "Now let's try some methods of proving these inequalities. The first one would be the simple `prove`." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "tm=[0]*4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from collections import Counter\n", + "from timeit import default_timer as timer\n", + "start=timer()\n", + "t=[]\n", + "for ineq in ineqs2:\n", + " t+=[prove(ineq)]\n", + " print(t[-1],end=',')\n", + "tm[0]=timer()-start\n", + "print('\\n',tm[0],sep='')\n", + "Counter(t)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Code 0 means that the proof was found, all other codes means that proof wasn't found. So this method has proved 21 inequalities.\n", + "\n", + "The second method uses `findvalues` function, rationalizes the result numbers and gives them as additional parameter to `prove` function." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def cut(a):\n", + " if a<=0 or a>=100 or (a is None):\n", + " return 1\n", + " return a\n", + "start=timer()\n", + "t2=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " values=nsimplify(numvalues,tolerance=0.1,rational=True)\n", + " values=list(map(cut,values))\n", + " t2+=[prove(ineq,values=values)]\n", + " print(t2[-1],end=',')\n", + "tm[1]=timer()-start\n", + "print('\\n',tm[1],sep='')\n", + "Counter(t2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The third method is similar to the second one, but instead of rationalize values it squares, rationalizes and makes square roots of these values." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def cut(a):\n", + " if a<=0 or a>=1000 or (a is None):\n", + " return S(1)\n", + " return a\n", + " \n", + "start=timer()\n", + "t3=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " numvalues=tuple([x**2 for x in numvalues])\n", + " values=nsimplify(numvalues,tolerance=0.1,rational=True)\n", + " values=[sqrt(x) for x in values]\n", + " values=list(map(cut,values))\n", + " t3+=[prove(ineq,values=values)]\n", + " print(t3[-1],end=',')\n", + "tm[2]=timer()-start\n", + "print('\\n',tm[2],sep='')\n", + "Counter(t3)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, the fourth method is a slight modification to the third method. It does the same \"findvalues, square, rationalize and make square roots\" thing, but then it scales the values and runs it again. It can sometimes help with uniform formulas." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def betw(a):\n", + " return a>0.001 and a<1000 and a!=None\n", + "def cut(a):\n", + " if betw(a):\n", + " return a\n", + " return S(1)\n", + "\n", + "start=timer()\n", + "t4=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " n=1\n", + " numvalues2=[]\n", + " for i in numvalues:\n", + " if betw(i):\n", + " n=1/i\n", + " break\n", + " for i in numvalues:\n", + " if betw(i):\n", + " numvalues2+=[i*n]\n", + " else:\n", + " numvalues2+=[1]\n", + " numvalues3=findvalues(ineq,values=numvalues2,disp=0)\n", + " numvalues4=tuple([x**2 for x in numvalues3])\n", + " values=nsimplify(numvalues4,tolerance=0.1,rational=True)\n", + " values=[sqrt(x) for x in values]\n", + " values=list(map(cut,values))\n", + " t4+=[prove(ineq,values=values)]\n", + " print(t4[-1],end=',')\n", + "tm[3]=timer()-start\n", + "print('\\n',tm[3],sep='')\n", + "Counter(t4)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt\n", + "plt.bar(['1','2','3','4'],tm)\n", + "plt.ylabel('time [seconds]')\n", + "plt.xlabel('method')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "u=pd.DataFrame(zip(['']*len(ineqs),t,t2,t3,t4))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.bar(['1','2','3','4'],[sum(u[i]==0)/len(ineqs2)*100 for i in range(1,5)])\n", + "plt.ylabel('inequalities proven [%]')\n", + "plt.xlabel('method')\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Down below there are contingency tables and McNemar test for every pair of methods." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(4):\n", + " for j in range(i+1,4):\n", + " display(pd.crosstab(u[i+1]==0, u[j+1]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from statsmodels.stats.contingency_tables import mcnemar\n", + "for i in range(4):\n", + " for j in range(i+1,4):\n", + " print(mcnemar(pd.crosstab(u[i+1]==0, u[j+1]==0)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In all cases p-value is greater than 0.05, so there is no statistical difference between the methods." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/__pycache__/shiroindev.cpython-36.pyc b/__pycache__/shiroindev.cpython-36.pyc index 4c76e45..5422fda 100644 Binary files a/__pycache__/shiroindev.cpython-36.pyc and b/__pycache__/shiroindev.cpython-36.pyc differ diff --git a/__pycache__/shiroindev.cpython-37.pyc b/__pycache__/shiroindev.cpython-37.pyc index 547e22c..713756e 100644 Binary files a/__pycache__/shiroindev.cpython-37.pyc and b/__pycache__/shiroindev.cpython-37.pyc differ diff --git a/examples.ipynb b/examples.ipynb index 7755427..4e27353 100644 --- a/examples.ipynb +++ b/examples.ipynb @@ -18,15 +18,15 @@ "from sympy import *\n", "from shiroindev import *\n", "from IPython.display import Latex\n", - "sVars.seed=1\n", - "sVars.display=lambda x:display(Latex(x))" + "shiro.seed=1\n", + "shiro.display=lambda x:display(Latex(x))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "`sVars.seed=1` sets a seed for proving functions. If you don't write it, you can get a slightly different proof each time you run a function. This line is here only for the sake of reproducibility. \n", + "`shiro.seed=1` sets a seed for proving functions. If you don't write it, you can get a slightly different proof each time you run a function. This line is here only for the sake of reproducibility. \n", "\n", "The next line provides a nicer display of proofs, i.e. formulas will be shown instead of LaTeX code of these formulas. Note that this works on Jupyter, but not on the git page.\n", "\n", @@ -56,7 +56,7 @@ { "data": { "text/latex": [ - "numerator: $a^2-ab-ac+b^2-bc+c^2$" + "numerator: $a^{2} - a b - a c + b^{2} - b c + c^{2}$" ], "text/plain": [ "" @@ -116,7 +116,7 @@ { "data": { "text/latex": [ - "$$ ab+ac+bc \\le a^2+b^2+c^2 $$" + "$$ a b+a c+b c \\le a^{2}+b^{2}+c^{2} $$" ], "text/plain": [ "" @@ -162,7 +162,7 @@ { "data": { "text/latex": [ - "numerator: $2a^2-2ab-2ac+2b^2-2bc+2c^2$" + "numerator: $2 a^{2} - 2 a b - 2 a c + 2 b^{2} - 2 b c + 2 c^{2}$" ], "text/plain": [ "" @@ -210,7 +210,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 a b \\le a^{2}+b^{2}$$" ], "text/plain": [ "" @@ -222,7 +222,7 @@ { "data": { "text/latex": [ - "$$2ac \\le a^2+c^2$$" + "$$2 a c \\le a^{2}+c^{2}$$" ], "text/plain": [ "" @@ -234,7 +234,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 b c \\le b^{2}+c^{2}$$" ], "text/plain": [ "" @@ -305,7 +305,7 @@ { "data": { "text/latex": [ - "numerator: $a^2-ab-ac-ad+b^2+c^2+d^2$" + "numerator: $a^{2} - a b - a c - a d + b^{2} + c^{2} + d^{2}$" ], "text/plain": [ "" @@ -353,7 +353,7 @@ { "data": { "text/latex": [ - "$$ ab+ac+ad \\le a^2+b^2+c^2+d^2 $$" + "$$ a b+a c+a d \\le a^{2}+b^{2}+c^{2}+d^{2} $$" ], "text/plain": [ "" @@ -398,7 +398,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 2a$" + "Substitute $a\\to 2 e$" ], "text/plain": [ "" @@ -410,7 +410,7 @@ { "data": { "text/latex": [ - "numerator: $4a^2-2ab-2ac-2ad+b^2+c^2+d^2$" + "numerator: $b^{2} - 2 b e + c^{2} - 2 c e + d^{2} - 2 d e + 4 e^{2}$" ], "text/plain": [ "" @@ -458,7 +458,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 b e \\le b^{2}+e^{2}$$" ], "text/plain": [ "" @@ -470,7 +470,7 @@ { "data": { "text/latex": [ - "$$2ac \\le a^2+c^2$$" + "$$2 c e \\le c^{2}+e^{2}$$" ], "text/plain": [ "" @@ -482,7 +482,7 @@ { "data": { "text/latex": [ - "$$2ad \\le a^2+d^2$$" + "$$2 d e \\le d^{2}+e^{2}$$" ], "text/plain": [ "" @@ -494,7 +494,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le a^2 $$" + "$$ 0 \\le e^{2} $$" ], "text/plain": [ "" @@ -534,7 +534,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Function makes a substitution $a\\to 2a$ (which should be understood as $a=2a'$) and try to prove new inequality. This time it succeeded. Moreover, if starting formula is equal to 0, then all these inequalities have to be equalities, so $a'^2=0$ and eventually $a=0$. We can also try a little bit lower value for $a$." + "Function makes a substitution $a\\to 2e$ and try to prove new inequality. This time it succeeded. Moreover, if starting formula is equal to 0, then all these inequalities have to be equalities, so $e^2=0$ and eventually $a=0$. We can also try a little bit lower value for $a$." ] }, { @@ -545,7 +545,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 7a/4$" + "Substitute $a\\to \\frac{7 f}{4}$" ], "text/plain": [ "" @@ -557,7 +557,7 @@ { "data": { "text/latex": [ - "numerator: $49a^2-28ab-28ac-28ad+16b^2+16c^2+16d^2$" + "numerator: $16 b^{2} - 28 b f + 16 c^{2} - 28 c f + 16 d^{2} - 28 d f + 49 f^{2}$" ], "text/plain": [ "" @@ -605,7 +605,7 @@ { "data": { "text/latex": [ - "$$28ab \\le 14a^2+14b^2$$" + "$$28 b f \\le 14 b^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -617,7 +617,7 @@ { "data": { "text/latex": [ - "$$28ac \\le 14a^2+14c^2$$" + "$$28 c f \\le 14 c^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -629,7 +629,7 @@ { "data": { "text/latex": [ - "$$28ad \\le 14a^2+14d^2$$" + "$$28 d f \\le 14 d^{2}+14 f^{2}$$" ], "text/plain": [ "" @@ -641,7 +641,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 7a^2+2b^2+2c^2+2d^2 $$" + "$$ 0 \\le 2 b^{2}+2 c^{2}+2 d^{2}+7 f^{2} $$" ], "text/plain": [ "" @@ -681,7 +681,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now we can see that if $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $7a'^2+2b^2+2c^2+2d^2=0$ and eventually $a=b=c=d=0$. Note that inequality is proved only for positive numbers (which, by continuity, can be expanded to nonnegative numbers). But using similar argumentation to the one in previous problem, if $(a,b,c,d)=(x,y,z,t)$ is the solution of $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $(a,b,c,d)=(|x|,|y|,|z|,|t|)$ is a solution, too. Since the only nonnegative solution is $(0,0,0,0)$, it means that it is the only solution.\n", + "Now we can see that if $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $7f^2+2b^2+2c^2+2d^2=0$ and eventually $a=b=c=d=0$. Note that inequality is proved only for positive numbers (which, by continuity, can be expanded to nonnegative numbers). But using similar argumentation to the one in previous problem, if $(a,b,c,d)=(x,y,z,t)$ is the solution of $a^2+b^2+c^2+d^2-a(b+c+d)=0$, then $(a,b,c,d)=(|x|,|y|,|z|,|t|)$ is a solution, too. Since the only nonnegative solution is $(0,0,0,0)$, it means that it is the only solution.\n", + "\n", + "It is worth noting that this time function `prove` used $f$ as a new variable instead of $e$. If you want to start a new proof and you don't care about the collision of variables from previous proofs, you can use `newproof` function, which clears the set of used variables.\n", "\n", "We can also use the `findvalues` function to find values for the proof more automatically. It looks for (local) minimum of the $quotient$ value defined above." ] @@ -760,7 +762,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 10a/7$" + "Substitute $a\\to \\frac{10 e}{7}$" ], "text/plain": [ "" @@ -772,7 +774,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to 5b/6$" + "Substitute $b\\to \\frac{5 f}{6}$" ], "text/plain": [ "" @@ -784,7 +786,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to 5c/6$" + "Substitute $c\\to \\frac{5 g}{6}$" ], "text/plain": [ "" @@ -796,7 +798,7 @@ { "data": { "text/latex": [ - "Substitute $d\\to 5d/6$" + "Substitute $d\\to \\frac{5 h}{6}$" ], "text/plain": [ "" @@ -808,7 +810,7 @@ { "data": { "text/latex": [ - "numerator: $3600a^2-2100ab-2100ac-2100ad+1225b^2+1225c^2+1225d^2$" + "numerator: $3600 e^{2} - 2100 e f - 2100 e g - 2100 e h + 1225 f^{2} + 1225 g^{2} + 1225 h^{2}$" ], "text/plain": [ "" @@ -856,7 +858,7 @@ { "data": { "text/latex": [ - "$$2100ab \\le 1050a^2+1050b^2$$" + "$$2100 e f \\le 1050 e^{2}+1050 f^{2}$$" ], "text/plain": [ "" @@ -868,7 +870,7 @@ { "data": { "text/latex": [ - "$$2100ac \\le 1050a^2+1050c^2$$" + "$$2100 e g \\le 1050 e^{2}+1050 g^{2}$$" ], "text/plain": [ "" @@ -880,7 +882,7 @@ { "data": { "text/latex": [ - "$$2100ad \\le 1050a^2+1050d^2$$" + "$$2100 e h \\le 1050 e^{2}+1050 h^{2}$$" ], "text/plain": [ "" @@ -892,7 +894,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 450a^2+175b^2+175c^2+175d^2 $$" + "$$ 0 \\le 450 e^{2}+175 f^{2}+175 g^{2}+175 h^{2} $$" ], "text/plain": [ "" @@ -925,6 +927,7 @@ } ], "source": [ + "newproof()\n", "prove(formula,values)" ] }, @@ -949,7 +952,7 @@ { "data": { "text/latex": [ - "numerator: $-x^3y+2x^2y^2-x^2-xy^3+2xy-y^2$" + "numerator: $- x^{3} y + 2 x^{2} y^{2} - x^{2} - x y^{3} + 2 x y - y^{2}$" ], "text/plain": [ "" @@ -961,7 +964,7 @@ { "data": { "text/latex": [ - "denominator: $x^3y^3-x^3y-x^2y^2+x^2-xy^3+xy+y^2-1$" + "denominator: $x^{3} y^{3} - x^{3} y - x^{2} y^{2} + x^{2} - x y^{3} + x y + y^{2} - 1$" ], "text/plain": [ "" @@ -997,7 +1000,7 @@ { "data": { "text/latex": [ - "$$ x^3y+x^2+xy^3+y^2 \\le 2x^2y^2+2xy $$" + "$$ x^{3} y+x^{2}+x y^{3}+y^{2} \\le 2 x^{2} y^{2}+2 x y $$" ], "text/plain": [ "" @@ -1063,7 +1066,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1-1/(x+1)$" + "Substitute $x\\to 1 - \\frac{1}{a + 1}$" ], "text/plain": [ "" @@ -1075,7 +1078,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to 1-1/(y+1)$" + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" ], "text/plain": [ "" @@ -1087,7 +1090,7 @@ { "data": { "text/latex": [ - "numerator: $6x^3y+3x^3-12x^2y^2-3x^2y+3x^2+6xy^3-3xy^2-6xy+3y^3+3y^2$" + "numerator: $6 a^{3} b + 3 a^{3} - 12 a^{2} b^{2} - 3 a^{2} b + 3 a^{2} + 6 a b^{3} - 3 a b^{2} - 6 a b + 3 b^{3} + 3 b^{2}$" ], "text/plain": [ "" @@ -1099,7 +1102,7 @@ { "data": { "text/latex": [ - "denominator: $4x^2y+2x^2+4xy^2+8xy+3x+2y^2+3y+1$" + "denominator: $4 a^{2} b + 2 a^{2} + 4 a b^{2} + 8 a b + 3 a + 2 b^{2} + 3 b + 1$" ], "text/plain": [ "" @@ -1135,7 +1138,7 @@ { "data": { "text/latex": [ - "$$12x^2y^2 \\le 6x^3y+6xy^3$$" + "$$12 a^{2} b^{2} \\le 6 a^{3} b+6 a b^{3}$$" ], "text/plain": [ "" @@ -1147,7 +1150,7 @@ { "data": { "text/latex": [ - "$$3x^2y \\le 2x^3+y^3$$" + "$$3 a^{2} b \\le 2 a^{3}+b^{3}$$" ], "text/plain": [ "" @@ -1159,7 +1162,7 @@ { "data": { "text/latex": [ - "$$3xy^2 \\le x^3+2y^3$$" + "$$3 a b^{2} \\le a^{3}+2 b^{3}$$" ], "text/plain": [ "" @@ -1171,7 +1174,7 @@ { "data": { "text/latex": [ - "$$6xy \\le 3x^2+3y^2$$" + "$$6 a b \\le 3 a^{2}+3 b^{2}$$" ], "text/plain": [ "" @@ -1216,6 +1219,7 @@ } ], "source": [ + "newproof()\n", "newformula,newvalues=makesubs('1/(1-x^2)+1/(1-y^2)-2/(1-x*y)','[0,1],[0,1]','1/2,1/2')\n", "prove(newformula*3,newvalues)" ] @@ -1235,8 +1239,7 @@ "* constraints for variables are written as intervals,\n", "* there are no \"backwards dependencies\", i.e. there is no $x$ in the interval of $y$.\n", "\n", - "If these two conditions hold, then you can use `makesubs` function.\n", - "**Warning:** at this moment `makesubs` **doesn't warn you if your list of intervals doesn't follow these rules!**\n" + "If these two conditions hold, then you can use `makesubs` function." ] }, { @@ -1247,7 +1250,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to -y+1+(y-1)/(x+1)$" + "Substitute $x\\to - y + 1 + \\frac{y - 1}{a + 1}$" ], "text/plain": [ "" @@ -1259,7 +1262,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to 1-1/(y+1)$" + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" ], "text/plain": [ "" @@ -1271,7 +1274,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to y/2$" + "Substitute $b\\to \\frac{c}{2}$" ], "text/plain": [ "" @@ -1283,7 +1286,7 @@ { "data": { "text/latex": [ - "numerator: $x^4y^2+x^3y^2-2x^3y-4x^2y+4x^2+xy^2-2xy+y^2$" + "numerator: $a^{4} c^{2} + a^{3} c^{2} - 2 a^{3} c - 4 a^{2} c + 4 a^{2} + a c^{2} - 2 a c + c^{2}$" ], "text/plain": [ "" @@ -1295,7 +1298,7 @@ { "data": { "text/latex": [ - "denominator: $x^3y^2+2x^3y+2x^2y^2+4x^2y+xy^2+2xy$" + "denominator: $a^{3} c^{2} + 2 a^{3} c + 2 a^{2} c^{2} + 4 a^{2} c + a c^{2} + 2 a c$" ], "text/plain": [ "" @@ -1331,7 +1334,7 @@ { "data": { "text/latex": [ - "$$2x^3y \\le x^4y^2+x^2$$" + "$$2 a^{3} c \\le a^{4} c^{2}+a^{2}$$" ], "text/plain": [ "" @@ -1343,7 +1346,7 @@ { "data": { "text/latex": [ - "$$4x^2y \\le x^3y^2+2x^2+xy^2$$" + "$$4 a^{2} c \\le a^{3} c^{2}+2 a^{2}+a c^{2}$$" ], "text/plain": [ "" @@ -1355,7 +1358,7 @@ { "data": { "text/latex": [ - "$$2xy \\le x^2+y^2$$" + "$$2 a c \\le a^{2}+c^{2}$$" ], "text/plain": [ "" @@ -1400,6 +1403,7 @@ } ], "source": [ + "newproof()\n", "formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))\n", "newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')\n", "prove(newformula,values)" @@ -1424,7 +1428,7 @@ { "data": { "text/latex": [ - "numerator: $2a^2-2ab-2ac+2b^2-2bc+2c^2$" + "numerator: $2 a^{2} - 2 a b - 2 a c + 2 b^{2} - 2 b c + 2 c^{2}$" ], "text/plain": [ "" @@ -1472,7 +1476,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 a b \\le a^{2}+b^{2}$$" ], "text/plain": [ "" @@ -1484,7 +1488,7 @@ { "data": { "text/latex": [ - "$$2ac \\le a^2+c^2$$" + "$$2 a c \\le a^{2}+c^{2}$$" ], "text/plain": [ "" @@ -1496,7 +1500,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 b c \\le b^{2}+c^{2}$$" ], "text/plain": [ "" @@ -1563,7 +1567,7 @@ { "data": { "text/latex": [ - "numerator: $x^4-4x^3+6x^2-4x+1$" + "numerator: $x^{4} - 4 x^{3} + 6 x^{2} - 4 x + 1$" ], "text/plain": [ "" @@ -1611,7 +1615,7 @@ { "data": { "text/latex": [ - "$$ 4x^3+4x \\le x^4+6x^2+1 $$" + "$$ 4 x^{3}+4 x \\le x^{4}+6 x^{2}+1 $$" ], "text/plain": [ "" @@ -1650,7 +1654,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+1$" + "Substitute $x\\to a + 1$" ], "text/plain": [ "" @@ -1662,7 +1666,7 @@ { "data": { "text/latex": [ - "numerator: $x^4$" + "numerator: $a^{4}$" ], "text/plain": [ "" @@ -1698,7 +1702,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le a^{4} $$" ], "text/plain": [ "" @@ -1731,6 +1735,7 @@ } ], "source": [ + "newproof()\n", "prove(makesubs('(x-1)^4','(1,oo)'))" ] }, @@ -1744,7 +1749,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1-x$" + "Substitute $x\\to 1 - a$" ], "text/plain": [ "" @@ -1756,7 +1761,7 @@ { "data": { "text/latex": [ - "numerator: $x^4$" + "numerator: $a^{4}$" ], "text/plain": [ "" @@ -1792,7 +1797,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le a^{4} $$" ], "text/plain": [ "" @@ -1825,6 +1830,7 @@ } ], "source": [ + "newproof()\n", "prove(makesubs('(x-1)^4','(-oo,1)'))" ] }, @@ -1872,7 +1878,7 @@ { "data": { "text/latex": [ - "numerator: $a^3c+a^3d+a^2b^2-a^2bd-2a^2c^2-a^2cd+a^2d^2+ab^3-ab^2c-ab^2d-abc^2+ac^3-acd^2+b^3d+b^2c^2-2b^2d^2+bc^3-bc^2d-bcd^2+bd^3+c^2d^2+cd^3$" + "numerator: $a^{3} c + a^{3} d + a^{2} b^{2} - a^{2} b d - 2 a^{2} c^{2} - a^{2} c d + a^{2} d^{2} + a b^{3} - a b^{2} c - a b^{2} d - a b c^{2} + a c^{3} - a c d^{2} + b^{3} d + b^{2} c^{2} - 2 b^{2} d^{2} + b c^{3} - b c^{2} d - b c d^{2} + b d^{3} + c^{2} d^{2} + c d^{3}$" ], "text/plain": [ "" @@ -1884,7 +1890,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+a^2cd+ab^2c+ab^2d+abc^2+2abcd+abd^2+ac^2d+acd^2+b^2cd+b^2d^2+bc^2d+bcd^2$" + "denominator: $a^{2} b c + a^{2} b d + a^{2} c^{2} + a^{2} c d + a b^{2} c + a b^{2} d + a b c^{2} + 2 a b c d + a b d^{2} + a c^{2} d + a c d^{2} + b^{2} c d + b^{2} d^{2} + b c^{2} d + b c d^{2}$" ], "text/plain": [ "" @@ -1920,7 +1926,7 @@ { "data": { "text/latex": [ - "$$ a^2bd+2a^2c^2+a^2cd+ab^2c+ab^2d+abc^2+acd^2+2b^2d^2+bc^2d+bcd^2 \\le a^3c+a^3d+a^2b^2+a^2d^2+ab^3+ac^3+b^3d+b^2c^2+bc^3+bd^3+c^2d^2+cd^3 $$" + "$$ a^{2} b d+2 a^{2} c^{2}+a^{2} c d+a b^{2} c+a b^{2} d+a b c^{2}+a c d^{2}+2 b^{2} d^{2}+b c^{2} d+b c d^{2} \\le a^{3} c+a^{3} d+a^{2} b^{2}+a^{2} d^{2}+a b^{3}+a c^{3}+b^{3} d+b^{2} c^{2}+b c^{3}+b d^{3}+c^{2} d^{2}+c d^{3} $$" ], "text/plain": [ "" @@ -1959,7 +1965,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c + e$" ], "text/plain": [ "" @@ -1971,7 +1977,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+d$" + "Substitute $b\\to d + f$" ], "text/plain": [ "" @@ -1983,7 +1989,7 @@ { "data": { "text/latex": [ - "numerator: $a^3c+a^3d+a^2b^2+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^3+ab^2c+2ab^2d-abc^2+abd^2+b^3c+b^3d+b^2c^2+2b^2cd+b^2d^2$" + "numerator: $c^{2} e^{2} - c^{2} e f + c^{2} f^{2} + 2 c d e^{2} + 2 c d f^{2} + c e^{3} + c e f^{2} + c f^{3} + d^{2} e^{2} + d^{2} e f + d^{2} f^{2} + d e^{3} + d e^{2} f + 2 d e f^{2} + d f^{3} + e^{2} f^{2} + e f^{3}$" ], "text/plain": [ "" @@ -1995,7 +2001,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^2c+ab^2d+3abc^2+6abcd+3abd^2+2ac^3+6ac^2d+6acd^2+2ad^3+b^2c^2+2b^2cd+b^2d^2+2bc^3+6bc^2d+6bcd^2+2bd^3+c^4+4c^3d+6c^2d^2+4cd^3+d^4$" + "denominator: $c^{4} + 4 c^{3} d + 2 c^{3} e + 2 c^{3} f + 6 c^{2} d^{2} + 6 c^{2} d e + 6 c^{2} d f + c^{2} e^{2} + 3 c^{2} e f + c^{2} f^{2} + 4 c d^{3} + 6 c d^{2} e + 6 c d^{2} f + 2 c d e^{2} + 6 c d e f + 2 c d f^{2} + c e^{2} f + c e f^{2} + d^{4} + 2 d^{3} e + 2 d^{3} f + d^{2} e^{2} + 3 d^{2} e f + d^{2} f^{2} + d e^{2} f + d e f^{2}$" ], "text/plain": [ "" @@ -2043,7 +2049,7 @@ { "data": { "text/latex": [ - "$$ abc^2 \\le a^3c+a^3d+a^2b^2+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^3+ab^2c+2ab^2d+abd^2+b^3c+b^3d+b^2c^2+2b^2cd+b^2d^2 $$" + "$$ c^{2} e f \\le c^{2} e^{2}+c^{2} f^{2}+2 c d e^{2}+2 c d f^{2}+c e^{3}+c e f^{2}+c f^{3}+d^{2} e^{2}+d^{2} e f+d^{2} f^{2}+d e^{3}+d e^{2} f+2 d e f^{2}+d f^{3}+e^{2} f^{2}+e f^{3} $$" ], "text/plain": [ "" @@ -2064,6 +2070,7 @@ } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[c,oo],[d,oo]'))" ] }, @@ -2075,7 +2082,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c + e$" ], "text/plain": [ "" @@ -2087,7 +2094,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+d$" + "Substitute $b\\to d + f$" ], "text/plain": [ "" @@ -2099,7 +2106,7 @@ { "data": { "text/latex": [ - "numerator: $2a^3c+2a^3d+2a^2b^2+2a^2bd+2a^2c^2+4a^2cd+2a^2d^2+2ab^3+2ab^2c+4ab^2d-2abc^2+2abd^2+2b^3c+2b^3d+2b^2c^2+4b^2cd+2b^2d^2$" + "numerator: $2 c^{2} e^{2} - 2 c^{2} e f + 2 c^{2} f^{2} + 4 c d e^{2} + 4 c d f^{2} + 2 c e^{3} + 2 c e f^{2} + 2 c f^{3} + 2 d^{2} e^{2} + 2 d^{2} e f + 2 d^{2} f^{2} + 2 d e^{3} + 2 d e^{2} f + 4 d e f^{2} + 2 d f^{3} + 2 e^{2} f^{2} + 2 e f^{3}$" ], "text/plain": [ "" @@ -2111,7 +2118,7 @@ { "data": { "text/latex": [ - "denominator: $a^2bc+a^2bd+a^2c^2+2a^2cd+a^2d^2+ab^2c+ab^2d+3abc^2+6abcd+3abd^2+2ac^3+6ac^2d+6acd^2+2ad^3+b^2c^2+2b^2cd+b^2d^2+2bc^3+6bc^2d+6bcd^2+2bd^3+c^4+4c^3d+6c^2d^2+4cd^3+d^4$" + "denominator: $c^{4} + 4 c^{3} d + 2 c^{3} e + 2 c^{3} f + 6 c^{2} d^{2} + 6 c^{2} d e + 6 c^{2} d f + c^{2} e^{2} + 3 c^{2} e f + c^{2} f^{2} + 4 c d^{3} + 6 c d^{2} e + 6 c d^{2} f + 2 c d e^{2} + 6 c d e f + 2 c d f^{2} + c e^{2} f + c e f^{2} + d^{4} + 2 d^{3} e + 2 d^{3} f + d^{2} e^{2} + 3 d^{2} e f + d^{2} f^{2} + d e^{2} f + d e f^{2}$" ], "text/plain": [ "" @@ -2147,7 +2154,7 @@ { "data": { "text/latex": [ - "$$2abc^2 \\le a^2c^2+b^2c^2$$" + "$$2 c^{2} e f \\le c^{2} e^{2}+c^{2} f^{2}$$" ], "text/plain": [ "" @@ -2159,7 +2166,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 2a^3c+2a^3d+2a^2b^2+2a^2bd+a^2c^2+4a^2cd+2a^2d^2+2ab^3+2ab^2c+4ab^2d+2abd^2+2b^3c+2b^3d+b^2c^2+4b^2cd+2b^2d^2 $$" + "$$ 0 \\le c^{2} e^{2}+c^{2} f^{2}+4 c d e^{2}+4 c d f^{2}+2 c e^{3}+2 c e f^{2}+2 c f^{3}+2 d^{2} e^{2}+2 d^{2} e f+2 d^{2} f^{2}+2 d e^{3}+2 d e^{2} f+4 d e f^{2}+2 d f^{3}+2 e^{2} f^{2}+2 e f^{3} $$" ], "text/plain": [ "" @@ -2192,6 +2199,7 @@ } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[c,oo],[d,oo]')*2)" ] }, @@ -2210,7 +2218,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to c-c/(a+1)$" + "Substitute $a\\to c - \\frac{c}{e + 1}$" ], "text/plain": [ "" @@ -2222,7 +2230,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to d-d/(b+1)$" + "Substitute $b\\to d - \\frac{d}{f + 1}$" ], "text/plain": [ "" @@ -2234,7 +2242,7 @@ { "data": { "text/latex": [ - "numerator: $2a^3bc^2d^2+4a^3bcd^3+2a^3bd^4+2a^3c^2d^2+2a^3cd^3-2a^2b^2c^3d+2a^2b^2cd^3-4a^2bc^3d+4a^2bc^2d^2+12a^2bcd^3+6a^2bd^4-2a^2c^3d+4a^2c^2d^2+6a^2cd^3+2ab^3c^4+4ab^3c^3d+2ab^3c^2d^2+6ab^2c^4+8ab^2c^3d+4ab^2c^2d^2+4ab^2cd^3+6abc^4+4abc^3d+6abc^2d^2+12abcd^3+6abd^4+2ac^4+4ac^2d^2+6acd^3+2b^3c^3d+2b^3c^2d^2+4b^2c^3d+4b^2c^2d^2+2b^2cd^3+2bc^3d+4bc^2d^2+4bcd^3+2bd^4+2c^2d^2+2cd^3$" + "numerator: $2 c^{4} e f^{3} + 6 c^{4} e f^{2} + 6 c^{4} e f + 2 c^{4} e - 2 c^{3} d e^{2} f^{2} - 4 c^{3} d e^{2} f - 2 c^{3} d e^{2} + 4 c^{3} d e f^{3} + 8 c^{3} d e f^{2} + 4 c^{3} d e f + 2 c^{3} d f^{3} + 4 c^{3} d f^{2} + 2 c^{3} d f + 2 c^{2} d^{2} e^{3} f + 2 c^{2} d^{2} e^{3} + 4 c^{2} d^{2} e^{2} f + 4 c^{2} d^{2} e^{2} + 2 c^{2} d^{2} e f^{3} + 4 c^{2} d^{2} e f^{2} + 6 c^{2} d^{2} e f + 4 c^{2} d^{2} e + 2 c^{2} d^{2} f^{3} + 4 c^{2} d^{2} f^{2} + 4 c^{2} d^{2} f + 2 c^{2} d^{2} + 4 c d^{3} e^{3} f + 2 c d^{3} e^{3} + 2 c d^{3} e^{2} f^{2} + 12 c d^{3} e^{2} f + 6 c d^{3} e^{2} + 4 c d^{3} e f^{2} + 12 c d^{3} e f + 6 c d^{3} e + 2 c d^{3} f^{2} + 4 c d^{3} f + 2 c d^{3} + 2 d^{4} e^{3} f + 6 d^{4} e^{2} f + 6 d^{4} e f + 2 d^{4} f$" ], "text/plain": [ "" @@ -2246,7 +2254,7 @@ { "data": { "text/latex": [ - "denominator: $a^3b^3c^4+4a^3b^3c^3d+6a^3b^3c^2d^2+4a^3b^3cd^3+a^3b^3d^4+3a^3b^2c^4+10a^3b^2c^3d+12a^3b^2c^2d^2+6a^3b^2cd^3+a^3b^2d^4+3a^3bc^4+8a^3bc^3d+7a^3bc^2d^2+2a^3bcd^3+a^3c^4+2a^3c^3d+a^3c^2d^2+a^2b^3c^4+6a^2b^3c^3d+12a^2b^3c^2d^2+10a^2b^3cd^3+3a^2b^3d^4+3a^2b^2c^4+15a^2b^2c^3d+24a^2b^2c^2d^2+15a^2b^2cd^3+3a^2b^2d^4+3a^2bc^4+12a^2bc^3d+14a^2bc^2d^2+5a^2bcd^3+a^2c^4+3a^2c^3d+2a^2c^2d^2+2ab^3c^3d+7ab^3c^2d^2+8ab^3cd^3+3ab^3d^4+5ab^2c^3d+14ab^2c^2d^2+12ab^2cd^3+3ab^2d^4+4abc^3d+8abc^2d^2+4abcd^3+ac^3d+ac^2d^2+b^3c^2d^2+2b^3cd^3+b^3d^4+2b^2c^2d^2+3b^2cd^3+b^2d^4+bc^2d^2+bcd^3$" + "denominator: $c^{4} e^{3} f^{3} + 3 c^{4} e^{3} f^{2} + 3 c^{4} e^{3} f + c^{4} e^{3} + c^{4} e^{2} f^{3} + 3 c^{4} e^{2} f^{2} + 3 c^{4} e^{2} f + c^{4} e^{2} + 4 c^{3} d e^{3} f^{3} + 10 c^{3} d e^{3} f^{2} + 8 c^{3} d e^{3} f + 2 c^{3} d e^{3} + 6 c^{3} d e^{2} f^{3} + 15 c^{3} d e^{2} f^{2} + 12 c^{3} d e^{2} f + 3 c^{3} d e^{2} + 2 c^{3} d e f^{3} + 5 c^{3} d e f^{2} + 4 c^{3} d e f + c^{3} d e + 6 c^{2} d^{2} e^{3} f^{3} + 12 c^{2} d^{2} e^{3} f^{2} + 7 c^{2} d^{2} e^{3} f + c^{2} d^{2} e^{3} + 12 c^{2} d^{2} e^{2} f^{3} + 24 c^{2} d^{2} e^{2} f^{2} + 14 c^{2} d^{2} e^{2} f + 2 c^{2} d^{2} e^{2} + 7 c^{2} d^{2} e f^{3} + 14 c^{2} d^{2} e f^{2} + 8 c^{2} d^{2} e f + c^{2} d^{2} e + c^{2} d^{2} f^{3} + 2 c^{2} d^{2} f^{2} + c^{2} d^{2} f + 4 c d^{3} e^{3} f^{3} + 6 c d^{3} e^{3} f^{2} + 2 c d^{3} e^{3} f + 10 c d^{3} e^{2} f^{3} + 15 c d^{3} e^{2} f^{2} + 5 c d^{3} e^{2} f + 8 c d^{3} e f^{3} + 12 c d^{3} e f^{2} + 4 c d^{3} e f + 2 c d^{3} f^{3} + 3 c d^{3} f^{2} + c d^{3} f + d^{4} e^{3} f^{3} + d^{4} e^{3} f^{2} + 3 d^{4} e^{2} f^{3} + 3 d^{4} e^{2} f^{2} + 3 d^{4} e f^{3} + 3 d^{4} e f^{2} + d^{4} f^{3} + d^{4} f^{2}$" ], "text/plain": [ "" @@ -2282,7 +2290,7 @@ { "data": { "text/latex": [ - "$$2a^2b^2c^3d \\le a^3bc^2d^2+ab^3c^4$$" + "$$2 c^{3} d e^{2} f^{2} \\le c^{4} e f^{3}+c^{2} d^{2} e^{3} f$$" ], "text/plain": [ "" @@ -2294,7 +2302,7 @@ { "data": { "text/latex": [ - "$$2a^2c^3d \\le a^3c^2d^2+ac^4$$" + "$$2 c^{3} d e^{2} \\le c^{4} e+c^{2} d^{2} e^{3}$$" ], "text/plain": [ "" @@ -2306,7 +2314,7 @@ { "data": { "text/latex": [ - "$$4a^2bc^3d \\le a^3bc^2d^2+a^3c^2d^2+ab^3c^4+ac^4$$" + "$$4 c^{3} d e^{2} f \\le c^{4} e f^{3}+c^{4} e+c^{2} d^{2} e^{3} f+c^{2} d^{2} e^{3}$$" ], "text/plain": [ "" @@ -2318,7 +2326,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^3bcd^3+2a^3bd^4+2a^3cd^3+2a^2b^2cd^3+4a^2bc^2d^2+12a^2bcd^3+6a^2bd^4+4a^2c^2d^2+6a^2cd^3+4ab^3c^3d+2ab^3c^2d^2+6ab^2c^4+8ab^2c^3d+4ab^2c^2d^2+4ab^2cd^3+6abc^4+4abc^3d+6abc^2d^2+12abcd^3+6abd^4+4ac^2d^2+6acd^3+2b^3c^3d+2b^3c^2d^2+4b^2c^3d+4b^2c^2d^2+2b^2cd^3+2bc^3d+4bc^2d^2+4bcd^3+2bd^4+2c^2d^2+2cd^3 $$" + "$$ 0 \\le 6 c^{4} e f^{2}+6 c^{4} e f+4 c^{3} d e f^{3}+8 c^{3} d e f^{2}+4 c^{3} d e f+2 c^{3} d f^{3}+4 c^{3} d f^{2}+2 c^{3} d f+4 c^{2} d^{2} e^{2} f+4 c^{2} d^{2} e^{2}+2 c^{2} d^{2} e f^{3}+4 c^{2} d^{2} e f^{2}+6 c^{2} d^{2} e f+4 c^{2} d^{2} e+2 c^{2} d^{2} f^{3}+4 c^{2} d^{2} f^{2}+4 c^{2} d^{2} f+2 c^{2} d^{2}+4 c d^{3} e^{3} f+2 c d^{3} e^{3}+2 c d^{3} e^{2} f^{2}+12 c d^{3} e^{2} f+6 c d^{3} e^{2}+4 c d^{3} e f^{2}+12 c d^{3} e f+6 c d^{3} e+2 c d^{3} f^{2}+4 c d^{3} f+2 c d^{3}+2 d^{4} e^{3} f+6 d^{4} e^{2} f+6 d^{4} e f+2 d^{4} f $$" ], "text/plain": [ "" @@ -2351,6 +2359,7 @@ } ], "source": [ + "newproof()\n", "prove(makesubs(formula,'[0,c],[0,d]')*2)" ] }, @@ -2369,7 +2378,7 @@ { "data": { "text/latex": [ - "numerator: $x^4-4x^3+6x^2-4x+1$" + "numerator: $x^{4} - 4 x^{3} + 6 x^{2} - 4 x + 1$" ], "text/plain": [ "" @@ -2393,8 +2402,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2406,7 +2414,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1+x$" + "Substitute $x\\to 1+a$" ], "text/plain": [ "" @@ -2418,7 +2426,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $x^4$" + "Numerator after substitutions: $a^{4}$" ], "text/plain": [ "" @@ -2442,7 +2450,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le a^{4} $$" ], "text/plain": [ "" @@ -2466,8 +2474,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2479,7 +2486,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to 1/(1+x)$" + "Substitute $x\\to 1/(1+b)$" ], "text/plain": [ "" @@ -2491,7 +2498,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $x^4$" + "Numerator after substitutions: $b^{4}$" ], "text/plain": [ "" @@ -2515,7 +2522,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le x^4 $$" + "$$ 0 \\le b^{4} $$" ], "text/plain": [ "" @@ -2548,6 +2555,7 @@ } ], "source": [ + "newproof()\n", "powerprove('(x-1)^4')" ] }, @@ -2559,7 +2567,7 @@ { "data": { "text/latex": [ - "numerator: $4a^5+4a^4b+4a^4c-6a^4-4a^3b-2a^3c+4ab^3-9ab^2+4ac^2-18ac+9a+4b^4+4b^3c-6b^3-3b^2c+4bc^2-12bc+10b+4c^3-6c^2+11c$" + "numerator: $4 a^{5} + 4 a^{4} b + 4 a^{4} c - 6 a^{4} - 4 a^{3} b - 2 a^{3} c + 4 a b^{3} - 9 a b^{2} + 4 a c^{2} - 18 a c + 9 a + 4 b^{4} + 4 b^{3} c - 6 b^{3} - 3 b^{2} c + 4 b c^{2} - 12 b c + 10 b + 4 c^{3} - 6 c^{2} + 11 c$" ], "text/plain": [ "" @@ -2583,8 +2591,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2596,7 +2603,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1+b,c\\to 1+c$" + "Substitute $a\\to 1+d,b\\to 1+e,c\\to 1+f$" ], "text/plain": [ "" @@ -2608,7 +2615,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5+4a^4b+4a^4c+22a^4+12a^3b+14a^3c+42a^3+12a^2b+18a^2c+34a^2+4ab^3+3ab^2-2ab+4ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 d^{5} + 4 d^{4} e + 4 d^{4} f + 22 d^{4} + 12 d^{3} e + 14 d^{3} f + 42 d^{3} + 12 d^{2} e + 18 d^{2} f + 34 d^{2} + 4 d e^{3} + 3 d e^{2} - 2 d e + 4 d f^{2} + 4 e^{4} + 4 e^{3} f + 18 e^{3} + 9 e^{2} f + 18 e^{2} + 4 e f^{2} + 2 e f + 4 f^{3} + 14 f^{2}$" ], "text/plain": [ "" @@ -2644,7 +2651,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 d e \\le d^{2}+e^{2}$$" ], "text/plain": [ "" @@ -2656,7 +2663,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5+4a^4b+4a^4c+22a^4+12a^3b+14a^3c+42a^3+12a^2b+18a^2c+33a^2+4ab^3+3ab^2+4ac^2+4b^4+4b^3c+18b^3+9b^2c+17b^2+4bc^2+2bc+4c^3+14c^2 $$" + "$$ 0 \\le 4 d^{5}+4 d^{4} e+4 d^{4} f+22 d^{4}+12 d^{3} e+14 d^{3} f+42 d^{3}+12 d^{2} e+18 d^{2} f+33 d^{2}+4 d e^{3}+3 d e^{2}+4 d f^{2}+4 e^{4}+4 e^{3} f+18 e^{3}+9 e^{2} f+17 e^{2}+4 e f^{2}+2 e f+4 f^{3}+14 f^{2} $$" ], "text/plain": [ "" @@ -2680,8 +2687,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2693,7 +2699,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1+b,c\\to 1+c$" + "Substitute $a\\to 1/(1+g),b\\to 1+h,c\\to 1+i$" ], "text/plain": [ "" @@ -2705,7 +2711,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4+4a^5b^3c+14a^5b^3+9a^5b^2c+15a^5b^2+4a^5bc^2+2a^5bc+6a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4+20a^4b^3c+74a^4b^3+45a^4b^2c+78a^4b^2+20a^4bc^2+10a^4bc+24a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4+40a^3b^3c+156a^3b^3+90a^3b^2c+162a^3b^2+40a^3bc^2+20a^3bc+36a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4+40a^2b^3c+164a^2b^3+90a^2b^2c+168a^2b^2+40a^2bc^2+20a^2bc+20a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4+20ab^3c+86ab^3+45ab^2c+87ab^2+20abc^2+10abc+2ab+20ac^3+66ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 g^{5} h^{4} + 4 g^{5} h^{3} i + 14 g^{5} h^{3} + 9 g^{5} h^{2} i + 15 g^{5} h^{2} + 4 g^{5} h i^{2} + 2 g^{5} h i + 6 g^{5} h + 4 g^{5} i^{3} + 10 g^{5} i^{2} + 8 g^{5} i + 10 g^{5} + 20 g^{4} h^{4} + 20 g^{4} h^{3} i + 74 g^{4} h^{3} + 45 g^{4} h^{2} i + 78 g^{4} h^{2} + 20 g^{4} h i^{2} + 10 g^{4} h i + 24 g^{4} h + 20 g^{4} i^{3} + 54 g^{4} i^{2} + 30 g^{4} i + 40 g^{4} + 40 g^{3} h^{4} + 40 g^{3} h^{3} i + 156 g^{3} h^{3} + 90 g^{3} h^{2} i + 162 g^{3} h^{2} + 40 g^{3} h i^{2} + 20 g^{3} h i + 36 g^{3} h + 40 g^{3} i^{3} + 116 g^{3} i^{2} + 40 g^{3} i + 60 g^{3} + 40 g^{2} h^{4} + 40 g^{2} h^{3} i + 164 g^{2} h^{3} + 90 g^{2} h^{2} i + 168 g^{2} h^{2} + 40 g^{2} h i^{2} + 20 g^{2} h i + 20 g^{2} h + 40 g^{2} i^{3} + 124 g^{2} i^{2} + 18 g^{2} i + 34 g^{2} + 20 g h^{4} + 20 g h^{3} i + 86 g h^{3} + 45 g h^{2} i + 87 g h^{2} + 20 g h i^{2} + 10 g h i + 2 g h + 20 g i^{3} + 66 g i^{2} + 4 h^{4} + 4 h^{3} i + 18 h^{3} + 9 h^{2} i + 18 h^{2} + 4 h i^{2} + 2 h i + 4 i^{3} + 14 i^{2}$" ], "text/plain": [ "" @@ -2729,7 +2735,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4+4a^5b^3c+14a^5b^3+9a^5b^2c+15a^5b^2+4a^5bc^2+2a^5bc+6a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4+20a^4b^3c+74a^4b^3+45a^4b^2c+78a^4b^2+20a^4bc^2+10a^4bc+24a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4+40a^3b^3c+156a^3b^3+90a^3b^2c+162a^3b^2+40a^3bc^2+20a^3bc+36a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4+40a^2b^3c+164a^2b^3+90a^2b^2c+168a^2b^2+40a^2bc^2+20a^2bc+20a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4+20ab^3c+86ab^3+45ab^2c+87ab^2+20abc^2+10abc+2ab+20ac^3+66ac^2+4b^4+4b^3c+18b^3+9b^2c+18b^2+4bc^2+2bc+4c^3+14c^2 $$" + "$$ 0 \\le 4 g^{5} h^{4}+4 g^{5} h^{3} i+14 g^{5} h^{3}+9 g^{5} h^{2} i+15 g^{5} h^{2}+4 g^{5} h i^{2}+2 g^{5} h i+6 g^{5} h+4 g^{5} i^{3}+10 g^{5} i^{2}+8 g^{5} i+10 g^{5}+20 g^{4} h^{4}+20 g^{4} h^{3} i+74 g^{4} h^{3}+45 g^{4} h^{2} i+78 g^{4} h^{2}+20 g^{4} h i^{2}+10 g^{4} h i+24 g^{4} h+20 g^{4} i^{3}+54 g^{4} i^{2}+30 g^{4} i+40 g^{4}+40 g^{3} h^{4}+40 g^{3} h^{3} i+156 g^{3} h^{3}+90 g^{3} h^{2} i+162 g^{3} h^{2}+40 g^{3} h i^{2}+20 g^{3} h i+36 g^{3} h+40 g^{3} i^{3}+116 g^{3} i^{2}+40 g^{3} i+60 g^{3}+40 g^{2} h^{4}+40 g^{2} h^{3} i+164 g^{2} h^{3}+90 g^{2} h^{2} i+168 g^{2} h^{2}+40 g^{2} h i^{2}+20 g^{2} h i+20 g^{2} h+40 g^{2} i^{3}+124 g^{2} i^{2}+18 g^{2} i+34 g^{2}+20 g h^{4}+20 g h^{3} i+86 g h^{3}+45 g h^{2} i+87 g h^{2}+20 g h i^{2}+10 g h i+2 g h+20 g i^{3}+66 g i^{2}+4 h^{4}+4 h^{3} i+18 h^{3}+9 h^{2} i+18 h^{2}+4 h i^{2}+2 h i+4 i^{3}+14 i^{2} $$" ], "text/plain": [ "" @@ -2753,8 +2759,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2766,7 +2771,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1/(1+b),c\\to 1+c$" + "Substitute $a\\to 1+j,b\\to 1/(1+k),c\\to 1+l$" ], "text/plain": [ "" @@ -2778,7 +2783,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4+16a^5b^3+24a^5b^2+16a^5b+4a^5+4a^4b^4c+18a^4b^4+16a^4b^3c+76a^4b^3+24a^4b^2c+120a^4b^2+16a^4bc+84a^4b+4a^4c+22a^4+14a^3b^4c+30a^3b^4+56a^3b^3c+132a^3b^3+84a^3b^2c+216a^3b^2+56a^3bc+156a^3b+14a^3c+42a^3+18a^2b^4c+22a^2b^4+72a^2b^3c+100a^2b^3+108a^2b^2c+168a^2b^2+72a^2bc+124a^2b+18a^2c+34a^2+4ab^4c^2+ab^4+16ab^3c^2+8ab^3+24ab^2c^2+9ab^2+16abc^2+2ab+4ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+18b^2+16bc^3+52bc^2-2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 j^{5} k^{4} + 16 j^{5} k^{3} + 24 j^{5} k^{2} + 16 j^{5} k + 4 j^{5} + 4 j^{4} k^{4} l + 18 j^{4} k^{4} + 16 j^{4} k^{3} l + 76 j^{4} k^{3} + 24 j^{4} k^{2} l + 120 j^{4} k^{2} + 16 j^{4} k l + 84 j^{4} k + 4 j^{4} l + 22 j^{4} + 14 j^{3} k^{4} l + 30 j^{3} k^{4} + 56 j^{3} k^{3} l + 132 j^{3} k^{3} + 84 j^{3} k^{2} l + 216 j^{3} k^{2} + 56 j^{3} k l + 156 j^{3} k + 14 j^{3} l + 42 j^{3} + 18 j^{2} k^{4} l + 22 j^{2} k^{4} + 72 j^{2} k^{3} l + 100 j^{2} k^{3} + 108 j^{2} k^{2} l + 168 j^{2} k^{2} + 72 j^{2} k l + 124 j^{2} k + 18 j^{2} l + 34 j^{2} + 4 j k^{4} l^{2} + j k^{4} + 16 j k^{3} l^{2} + 8 j k^{3} + 24 j k^{2} l^{2} + 9 j k^{2} + 16 j k l^{2} + 2 j k + 4 j l^{2} + 4 k^{4} l^{3} + 10 k^{4} l^{2} + 3 k^{4} l + 4 k^{4} + 16 k^{3} l^{3} + 44 k^{3} l^{2} + 8 k^{3} l + 18 k^{3} + 24 k^{2} l^{3} + 72 k^{2} l^{2} + 3 k^{2} l + 18 k^{2} + 16 k l^{3} + 52 k l^{2} - 2 k l + 4 l^{3} + 14 l^{2}$" ], "text/plain": [ "" @@ -2814,7 +2819,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 k l \\le k^{2}+l^{2}$$" ], "text/plain": [ "" @@ -2826,7 +2831,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4+16a^5b^3+24a^5b^2+16a^5b+4a^5+4a^4b^4c+18a^4b^4+16a^4b^3c+76a^4b^3+24a^4b^2c+120a^4b^2+16a^4bc+84a^4b+4a^4c+22a^4+14a^3b^4c+30a^3b^4+56a^3b^3c+132a^3b^3+84a^3b^2c+216a^3b^2+56a^3bc+156a^3b+14a^3c+42a^3+18a^2b^4c+22a^2b^4+72a^2b^3c+100a^2b^3+108a^2b^2c+168a^2b^2+72a^2bc+124a^2b+18a^2c+34a^2+4ab^4c^2+ab^4+16ab^3c^2+8ab^3+24ab^2c^2+9ab^2+16abc^2+2ab+4ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+17b^2+16bc^3+52bc^2+4c^3+13c^2 $$" + "$$ 0 \\le 4 j^{5} k^{4}+16 j^{5} k^{3}+24 j^{5} k^{2}+16 j^{5} k+4 j^{5}+4 j^{4} k^{4} l+18 j^{4} k^{4}+16 j^{4} k^{3} l+76 j^{4} k^{3}+24 j^{4} k^{2} l+120 j^{4} k^{2}+16 j^{4} k l+84 j^{4} k+4 j^{4} l+22 j^{4}+14 j^{3} k^{4} l+30 j^{3} k^{4}+56 j^{3} k^{3} l+132 j^{3} k^{3}+84 j^{3} k^{2} l+216 j^{3} k^{2}+56 j^{3} k l+156 j^{3} k+14 j^{3} l+42 j^{3}+18 j^{2} k^{4} l+22 j^{2} k^{4}+72 j^{2} k^{3} l+100 j^{2} k^{3}+108 j^{2} k^{2} l+168 j^{2} k^{2}+72 j^{2} k l+124 j^{2} k+18 j^{2} l+34 j^{2}+4 j k^{4} l^{2}+j k^{4}+16 j k^{3} l^{2}+8 j k^{3}+24 j k^{2} l^{2}+9 j k^{2}+16 j k l^{2}+2 j k+4 j l^{2}+4 k^{4} l^{3}+10 k^{4} l^{2}+3 k^{4} l+4 k^{4}+16 k^{3} l^{3}+44 k^{3} l^{2}+8 k^{3} l+18 k^{3}+24 k^{2} l^{3}+72 k^{2} l^{2}+3 k^{2} l+17 k^{2}+16 k l^{3}+52 k l^{2}+4 l^{3}+13 l^{2} $$" ], "text/plain": [ "" @@ -2850,8 +2855,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2863,7 +2867,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1/(1+b),c\\to 1+c$" + "Substitute $a\\to 1/(1+m),b\\to 1/(1+n),c\\to 1+o$" ], "text/plain": [ "" @@ -2875,7 +2879,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+6a^5b^4c^2+11a^5b^4c+9a^5b^4+16a^5b^3c^3+28a^5b^3c^2+40a^5b^3c+38a^5b^3+24a^5b^2c^3+48a^5b^2c^2+51a^5b^2c+57a^5b^2+16a^5bc^3+36a^5bc^2+30a^5bc+34a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4c^3+34a^4b^4c^2+45a^4b^4c+40a^4b^4+80a^4b^3c^3+156a^4b^3c^2+160a^4b^3c+170a^4b^3+120a^4b^2c^3+264a^4b^2c^2+195a^4b^2c+246a^4b^2+80a^4bc^3+196a^4bc^2+110a^4bc+136a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4c^3+76a^3b^4c^2+70a^3b^4c+70a^3b^4+160a^3b^3c^3+344a^3b^3c^2+240a^3b^3c+300a^3b^3+240a^3b^2c^3+576a^3b^2c^2+270a^3b^2c+414a^3b^2+160a^3bc^3+424a^3bc^2+140a^3bc+204a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4c^3+84a^2b^4c^2+48a^2b^4c+58a^2b^4+160a^2b^3c^3+376a^2b^3c^2+152a^2b^3c+248a^2b^3+240a^2b^2c^3+624a^2b^2c^2+138a^2b^2c+312a^2b^2+160a^2bc^3+456a^2bc^2+52a^2bc+116a^2b+40a^2c^3+124a^2c^2+18a^2c+34a^2+20ab^4c^3+46ab^4c^2+15ab^4c+19ab^4+80ab^3c^3+204ab^3c^2+40ab^3c+82ab^3+120ab^2c^3+336ab^2c^2+15ab^2c+81ab^2+80abc^3+244abc^2-10abc-2ab+20ac^3+66ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+18b^3+24b^2c^3+72b^2c^2+3b^2c+18b^2+16bc^3+52bc^2-2bc+4c^3+14c^2$" + "Numerator after substitutions: $4 m^{5} n^{4} o^{3} + 6 m^{5} n^{4} o^{2} + 11 m^{5} n^{4} o + 9 m^{5} n^{4} + 16 m^{5} n^{3} o^{3} + 28 m^{5} n^{3} o^{2} + 40 m^{5} n^{3} o + 38 m^{5} n^{3} + 24 m^{5} n^{2} o^{3} + 48 m^{5} n^{2} o^{2} + 51 m^{5} n^{2} o + 57 m^{5} n^{2} + 16 m^{5} n o^{3} + 36 m^{5} n o^{2} + 30 m^{5} n o + 34 m^{5} n + 4 m^{5} o^{3} + 10 m^{5} o^{2} + 8 m^{5} o + 10 m^{5} + 20 m^{4} n^{4} o^{3} + 34 m^{4} n^{4} o^{2} + 45 m^{4} n^{4} o + 40 m^{4} n^{4} + 80 m^{4} n^{3} o^{3} + 156 m^{4} n^{3} o^{2} + 160 m^{4} n^{3} o + 170 m^{4} n^{3} + 120 m^{4} n^{2} o^{3} + 264 m^{4} n^{2} o^{2} + 195 m^{4} n^{2} o + 246 m^{4} n^{2} + 80 m^{4} n o^{3} + 196 m^{4} n o^{2} + 110 m^{4} n o + 136 m^{4} n + 20 m^{4} o^{3} + 54 m^{4} o^{2} + 30 m^{4} o + 40 m^{4} + 40 m^{3} n^{4} o^{3} + 76 m^{3} n^{4} o^{2} + 70 m^{3} n^{4} o + 70 m^{3} n^{4} + 160 m^{3} n^{3} o^{3} + 344 m^{3} n^{3} o^{2} + 240 m^{3} n^{3} o + 300 m^{3} n^{3} + 240 m^{3} n^{2} o^{3} + 576 m^{3} n^{2} o^{2} + 270 m^{3} n^{2} o + 414 m^{3} n^{2} + 160 m^{3} n o^{3} + 424 m^{3} n o^{2} + 140 m^{3} n o + 204 m^{3} n + 40 m^{3} o^{3} + 116 m^{3} o^{2} + 40 m^{3} o + 60 m^{3} + 40 m^{2} n^{4} o^{3} + 84 m^{2} n^{4} o^{2} + 48 m^{2} n^{4} o + 58 m^{2} n^{4} + 160 m^{2} n^{3} o^{3} + 376 m^{2} n^{3} o^{2} + 152 m^{2} n^{3} o + 248 m^{2} n^{3} + 240 m^{2} n^{2} o^{3} + 624 m^{2} n^{2} o^{2} + 138 m^{2} n^{2} o + 312 m^{2} n^{2} + 160 m^{2} n o^{3} + 456 m^{2} n o^{2} + 52 m^{2} n o + 116 m^{2} n + 40 m^{2} o^{3} + 124 m^{2} o^{2} + 18 m^{2} o + 34 m^{2} + 20 m n^{4} o^{3} + 46 m n^{4} o^{2} + 15 m n^{4} o + 19 m n^{4} + 80 m n^{3} o^{3} + 204 m n^{3} o^{2} + 40 m n^{3} o + 82 m n^{3} + 120 m n^{2} o^{3} + 336 m n^{2} o^{2} + 15 m n^{2} o + 81 m n^{2} + 80 m n o^{3} + 244 m n o^{2} - 10 m n o - 2 m n + 20 m o^{3} + 66 m o^{2} + 4 n^{4} o^{3} + 10 n^{4} o^{2} + 3 n^{4} o + 4 n^{4} + 16 n^{3} o^{3} + 44 n^{3} o^{2} + 8 n^{3} o + 18 n^{3} + 24 n^{2} o^{3} + 72 n^{2} o^{2} + 3 n^{2} o + 18 n^{2} + 16 n o^{3} + 52 n o^{2} - 2 n o + 4 o^{3} + 14 o^{2}$" ], "text/plain": [ "" @@ -2911,7 +2915,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 m n \\le m^{2}+n^{2}$$" ], "text/plain": [ "" @@ -2923,7 +2927,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 n o \\le n^{2}+o^{2}$$" ], "text/plain": [ "" @@ -2935,7 +2939,7 @@ { "data": { "text/latex": [ - "$$10abc \\le 2a^2+2ab^2c+4ac^2+2b^3$$" + "$$10 m n o \\le 2 m^{2}+2 m n^{2} o+4 m o^{2}+2 n^{3}$$" ], "text/plain": [ "" @@ -2947,7 +2951,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+6a^5b^4c^2+11a^5b^4c+9a^5b^4+16a^5b^3c^3+28a^5b^3c^2+40a^5b^3c+38a^5b^3+24a^5b^2c^3+48a^5b^2c^2+51a^5b^2c+57a^5b^2+16a^5bc^3+36a^5bc^2+30a^5bc+34a^5b+4a^5c^3+10a^5c^2+8a^5c+10a^5+20a^4b^4c^3+34a^4b^4c^2+45a^4b^4c+40a^4b^4+80a^4b^3c^3+156a^4b^3c^2+160a^4b^3c+170a^4b^3+120a^4b^2c^3+264a^4b^2c^2+195a^4b^2c+246a^4b^2+80a^4bc^3+196a^4bc^2+110a^4bc+136a^4b+20a^4c^3+54a^4c^2+30a^4c+40a^4+40a^3b^4c^3+76a^3b^4c^2+70a^3b^4c+70a^3b^4+160a^3b^3c^3+344a^3b^3c^2+240a^3b^3c+300a^3b^3+240a^3b^2c^3+576a^3b^2c^2+270a^3b^2c+414a^3b^2+160a^3bc^3+424a^3bc^2+140a^3bc+204a^3b+40a^3c^3+116a^3c^2+40a^3c+60a^3+40a^2b^4c^3+84a^2b^4c^2+48a^2b^4c+58a^2b^4+160a^2b^3c^3+376a^2b^3c^2+152a^2b^3c+248a^2b^3+240a^2b^2c^3+624a^2b^2c^2+138a^2b^2c+312a^2b^2+160a^2bc^3+456a^2bc^2+52a^2bc+116a^2b+40a^2c^3+124a^2c^2+18a^2c+31a^2+20ab^4c^3+46ab^4c^2+15ab^4c+19ab^4+80ab^3c^3+204ab^3c^2+40ab^3c+82ab^3+120ab^2c^3+336ab^2c^2+13ab^2c+81ab^2+80abc^3+244abc^2+20ac^3+62ac^2+4b^4c^3+10b^4c^2+3b^4c+4b^4+16b^3c^3+44b^3c^2+8b^3c+16b^3+24b^2c^3+72b^2c^2+3b^2c+16b^2+16bc^3+52bc^2+4c^3+13c^2 $$" + "$$ 0 \\le 4 m^{5} n^{4} o^{3}+6 m^{5} n^{4} o^{2}+11 m^{5} n^{4} o+9 m^{5} n^{4}+16 m^{5} n^{3} o^{3}+28 m^{5} n^{3} o^{2}+40 m^{5} n^{3} o+38 m^{5} n^{3}+24 m^{5} n^{2} o^{3}+48 m^{5} n^{2} o^{2}+51 m^{5} n^{2} o+57 m^{5} n^{2}+16 m^{5} n o^{3}+36 m^{5} n o^{2}+30 m^{5} n o+34 m^{5} n+4 m^{5} o^{3}+10 m^{5} o^{2}+8 m^{5} o+10 m^{5}+20 m^{4} n^{4} o^{3}+34 m^{4} n^{4} o^{2}+45 m^{4} n^{4} o+40 m^{4} n^{4}+80 m^{4} n^{3} o^{3}+156 m^{4} n^{3} o^{2}+160 m^{4} n^{3} o+170 m^{4} n^{3}+120 m^{4} n^{2} o^{3}+264 m^{4} n^{2} o^{2}+195 m^{4} n^{2} o+246 m^{4} n^{2}+80 m^{4} n o^{3}+196 m^{4} n o^{2}+110 m^{4} n o+136 m^{4} n+20 m^{4} o^{3}+54 m^{4} o^{2}+30 m^{4} o+40 m^{4}+40 m^{3} n^{4} o^{3}+76 m^{3} n^{4} o^{2}+70 m^{3} n^{4} o+70 m^{3} n^{4}+160 m^{3} n^{3} o^{3}+344 m^{3} n^{3} o^{2}+240 m^{3} n^{3} o+300 m^{3} n^{3}+240 m^{3} n^{2} o^{3}+576 m^{3} n^{2} o^{2}+270 m^{3} n^{2} o+414 m^{3} n^{2}+160 m^{3} n o^{3}+424 m^{3} n o^{2}+140 m^{3} n o+204 m^{3} n+40 m^{3} o^{3}+116 m^{3} o^{2}+40 m^{3} o+60 m^{3}+40 m^{2} n^{4} o^{3}+84 m^{2} n^{4} o^{2}+48 m^{2} n^{4} o+58 m^{2} n^{4}+160 m^{2} n^{3} o^{3}+376 m^{2} n^{3} o^{2}+152 m^{2} n^{3} o+248 m^{2} n^{3}+240 m^{2} n^{2} o^{3}+624 m^{2} n^{2} o^{2}+138 m^{2} n^{2} o+312 m^{2} n^{2}+160 m^{2} n o^{3}+456 m^{2} n o^{2}+52 m^{2} n o+116 m^{2} n+40 m^{2} o^{3}+124 m^{2} o^{2}+18 m^{2} o+31 m^{2}+20 m n^{4} o^{3}+46 m n^{4} o^{2}+15 m n^{4} o+19 m n^{4}+80 m n^{3} o^{3}+204 m n^{3} o^{2}+40 m n^{3} o+82 m n^{3}+120 m n^{2} o^{3}+336 m n^{2} o^{2}+13 m n^{2} o+81 m n^{2}+80 m n o^{3}+244 m n o^{2}+20 m o^{3}+62 m o^{2}+4 n^{4} o^{3}+10 n^{4} o^{2}+3 n^{4} o+4 n^{4}+16 n^{3} o^{3}+44 n^{3} o^{2}+8 n^{3} o+16 n^{3}+24 n^{2} o^{3}+72 n^{2} o^{2}+3 n^{2} o+16 n^{2}+16 n o^{3}+52 n o^{2}+4 o^{3}+13 o^{2} $$" ], "text/plain": [ "" @@ -2971,8 +2975,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -2984,7 +2987,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1+b,c\\to 1/(1+c)$" + "Substitute $a\\to 1+p,b\\to 1+q,c\\to 1/(1+r)$" ], "text/plain": [ "" @@ -2996,7 +2999,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5c^3+12a^5c^2+12a^5c+4a^5+4a^4bc^3+12a^4bc^2+12a^4bc+4a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+12a^3bc^3+36a^3bc^2+36a^3bc+12a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+12a^2bc^3+36a^2bc^2+36a^2bc+12a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+4ab^3c^3+12ab^3c^2+12ab^3c+4ab^3+3ab^2c^3+9ab^2c^2+9ab^2c+3ab^2-2abc^3-6abc^2-6abc-2ab+4ac^3+4ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+18b^2+2bc^3-2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 p^{5} r^{3} + 12 p^{5} r^{2} + 12 p^{5} r + 4 p^{5} + 4 p^{4} q r^{3} + 12 p^{4} q r^{2} + 12 p^{4} q r + 4 p^{4} q + 18 p^{4} r^{3} + 58 p^{4} r^{2} + 62 p^{4} r + 22 p^{4} + 12 p^{3} q r^{3} + 36 p^{3} q r^{2} + 36 p^{3} q r + 12 p^{3} q + 28 p^{3} r^{3} + 98 p^{3} r^{2} + 112 p^{3} r + 42 p^{3} + 12 p^{2} q r^{3} + 36 p^{2} q r^{2} + 36 p^{2} q r + 12 p^{2} q + 16 p^{2} r^{3} + 66 p^{2} r^{2} + 84 p^{2} r + 34 p^{2} + 4 p q^{3} r^{3} + 12 p q^{3} r^{2} + 12 p q^{3} r + 4 p q^{3} + 3 p q^{2} r^{3} + 9 p q^{2} r^{2} + 9 p q^{2} r + 3 p q^{2} - 2 p q r^{3} - 6 p q r^{2} - 6 p q r - 2 p q + 4 p r^{3} + 4 p r^{2} + 4 q^{4} r^{3} + 12 q^{4} r^{2} + 12 q^{4} r + 4 q^{4} + 14 q^{3} r^{3} + 46 q^{3} r^{2} + 50 q^{3} r + 18 q^{3} + 9 q^{2} r^{3} + 36 q^{2} r^{2} + 45 q^{2} r + 18 q^{2} + 2 q r^{3} - 2 q r + 10 r^{3} + 14 r^{2}$" ], "text/plain": [ "" @@ -3032,7 +3035,7 @@ { "data": { "text/latex": [ - "$$2abc^3 \\le a^2bc^3+bc^3$$" + "$$2 p q r^{3} \\le p^{2} q r^{3}+q r^{3}$$" ], "text/plain": [ "" @@ -3044,7 +3047,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 p q \\le p^{2}+q^{2}$$" ], "text/plain": [ "" @@ -3056,7 +3059,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 q r \\le q^{2}+r^{2}$$" ], "text/plain": [ "" @@ -3068,7 +3071,7 @@ { "data": { "text/latex": [ - "$$6abc \\le 2a^3b+2b^2c+2c^2$$" + "$$6 p q r \\le 2 p^{3} q+2 q^{2} r+2 r^{2}$$" ], "text/plain": [ "" @@ -3080,7 +3083,7 @@ { "data": { "text/latex": [ - "$$6abc^2 \\le 2ab^2c^3+ab^2+3ac^2$$" + "$$6 p q r^{2} \\le 2 p q^{2} r^{3}+p q^{2}+3 p r^{2}$$" ], "text/plain": [ "" @@ -3092,7 +3095,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5c^3+12a^5c^2+12a^5c+4a^5+4a^4bc^3+12a^4bc^2+12a^4bc+4a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+12a^3bc^3+36a^3bc^2+36a^3bc+10a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+11a^2bc^3+36a^2bc^2+36a^2bc+12a^2b+16a^2c^3+66a^2c^2+84a^2c+33a^2+4ab^3c^3+12ab^3c^2+12ab^3c+4ab^3+ab^2c^3+9ab^2c^2+9ab^2c+2ab^2+4ac^3+ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+43b^2c+16b^2+bc^3+10c^3+11c^2 $$" + "$$ 0 \\le 4 p^{5} r^{3}+12 p^{5} r^{2}+12 p^{5} r+4 p^{5}+4 p^{4} q r^{3}+12 p^{4} q r^{2}+12 p^{4} q r+4 p^{4} q+18 p^{4} r^{3}+58 p^{4} r^{2}+62 p^{4} r+22 p^{4}+12 p^{3} q r^{3}+36 p^{3} q r^{2}+36 p^{3} q r+10 p^{3} q+28 p^{3} r^{3}+98 p^{3} r^{2}+112 p^{3} r+42 p^{3}+11 p^{2} q r^{3}+36 p^{2} q r^{2}+36 p^{2} q r+12 p^{2} q+16 p^{2} r^{3}+66 p^{2} r^{2}+84 p^{2} r+33 p^{2}+4 p q^{3} r^{3}+12 p q^{3} r^{2}+12 p q^{3} r+4 p q^{3}+p q^{2} r^{3}+9 p q^{2} r^{2}+9 p q^{2} r+2 p q^{2}+4 p r^{3}+p r^{2}+4 q^{4} r^{3}+12 q^{4} r^{2}+12 q^{4} r+4 q^{4}+14 q^{3} r^{3}+46 q^{3} r^{2}+50 q^{3} r+18 q^{3}+9 q^{2} r^{3}+36 q^{2} r^{2}+43 q^{2} r+16 q^{2}+q r^{3}+10 r^{3}+11 r^{2} $$" ], "text/plain": [ "" @@ -3116,8 +3119,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -3129,7 +3131,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1+b,c\\to 1/(1+c)$" + "Substitute $a\\to 1/(1+s),b\\to 1+t,c\\to 1/(1+u)$" ], "text/plain": [ "" @@ -3141,7 +3143,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+10a^5b^3c^3+34a^5b^3c^2+38a^5b^3c+14a^5b^3+6a^5b^2c^3+27a^5b^2c^2+36a^5b^2c+15a^5b^2+8a^5bc^3+18a^5bc^2+16a^5bc+6a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+20a^4b^4c^3+60a^4b^4c^2+60a^4b^4c+20a^4b^4+54a^4b^3c^3+182a^4b^3c^2+202a^4b^3c+74a^4b^3+33a^4b^2c^3+144a^4b^2c^2+189a^4b^2c+78a^4b^2+34a^4bc^3+72a^4bc^2+62a^4bc+24a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+40a^3b^4c^3+120a^3b^4c^2+120a^3b^4c+40a^3b^4+116a^3b^3c^3+388a^3b^3c^2+428a^3b^3c+156a^3b^3+72a^3b^2c^3+306a^3b^2c^2+396a^3b^2c+162a^3b^2+56a^3bc^3+108a^3bc^2+88a^3bc+36a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+40a^2b^4c^3+120a^2b^4c^2+120a^2b^4c+40a^2b^4+124a^2b^3c^3+412a^2b^3c^2+452a^2b^3c+164a^2b^3+78a^2b^2c^3+324a^2b^2c^2+414a^2b^2c+168a^2b^2+40a^2bc^3+60a^2bc^2+40a^2bc+20a^2b+100a^2c^3+190a^2c^2+84a^2c+34a^2+20ab^4c^3+60ab^4c^2+60ab^4c+20ab^4+66ab^3c^3+218ab^3c^2+238ab^3c+86ab^3+42ab^2c^3+171ab^2c^2+216ab^2c+87ab^2+12abc^3+6abc^2-4abc+2ab+46ac^3+66ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+18b^2+2bc^3-2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 s^{5} t^{4} u^{3} + 12 s^{5} t^{4} u^{2} + 12 s^{5} t^{4} u + 4 s^{5} t^{4} + 10 s^{5} t^{3} u^{3} + 34 s^{5} t^{3} u^{2} + 38 s^{5} t^{3} u + 14 s^{5} t^{3} + 6 s^{5} t^{2} u^{3} + 27 s^{5} t^{2} u^{2} + 36 s^{5} t^{2} u + 15 s^{5} t^{2} + 8 s^{5} t u^{3} + 18 s^{5} t u^{2} + 16 s^{5} t u + 6 s^{5} t + 8 s^{5} u^{3} + 24 s^{5} u^{2} + 22 s^{5} u + 10 s^{5} + 20 s^{4} t^{4} u^{3} + 60 s^{4} t^{4} u^{2} + 60 s^{4} t^{4} u + 20 s^{4} t^{4} + 54 s^{4} t^{3} u^{3} + 182 s^{4} t^{3} u^{2} + 202 s^{4} t^{3} u + 74 s^{4} t^{3} + 33 s^{4} t^{2} u^{3} + 144 s^{4} t^{2} u^{2} + 189 s^{4} t^{2} u + 78 s^{4} t^{2} + 34 s^{4} t u^{3} + 72 s^{4} t u^{2} + 62 s^{4} t u + 24 s^{4} t + 44 s^{4} u^{3} + 114 s^{4} u^{2} + 90 s^{4} u + 40 s^{4} + 40 s^{3} t^{4} u^{3} + 120 s^{3} t^{4} u^{2} + 120 s^{3} t^{4} u + 40 s^{3} t^{4} + 116 s^{3} t^{3} u^{3} + 388 s^{3} t^{3} u^{2} + 428 s^{3} t^{3} u + 156 s^{3} t^{3} + 72 s^{3} t^{2} u^{3} + 306 s^{3} t^{2} u^{2} + 396 s^{3} t^{2} u + 162 s^{3} t^{2} + 56 s^{3} t u^{3} + 108 s^{3} t u^{2} + 88 s^{3} t u + 36 s^{3} t + 96 s^{3} u^{3} + 216 s^{3} u^{2} + 140 s^{3} u + 60 s^{3} + 40 s^{2} t^{4} u^{3} + 120 s^{2} t^{4} u^{2} + 120 s^{2} t^{4} u + 40 s^{2} t^{4} + 124 s^{2} t^{3} u^{3} + 412 s^{2} t^{3} u^{2} + 452 s^{2} t^{3} u + 164 s^{2} t^{3} + 78 s^{2} t^{2} u^{3} + 324 s^{2} t^{2} u^{2} + 414 s^{2} t^{2} u + 168 s^{2} t^{2} + 40 s^{2} t u^{3} + 60 s^{2} t u^{2} + 40 s^{2} t u + 20 s^{2} t + 100 s^{2} u^{3} + 190 s^{2} u^{2} + 84 s^{2} u + 34 s^{2} + 20 s t^{4} u^{3} + 60 s t^{4} u^{2} + 60 s t^{4} u + 20 s t^{4} + 66 s t^{3} u^{3} + 218 s t^{3} u^{2} + 238 s t^{3} u + 86 s t^{3} + 42 s t^{2} u^{3} + 171 s t^{2} u^{2} + 216 s t^{2} u + 87 s t^{2} + 12 s t u^{3} + 6 s t u^{2} - 4 s t u + 2 s t + 46 s u^{3} + 66 s u^{2} + 4 t^{4} u^{3} + 12 t^{4} u^{2} + 12 t^{4} u + 4 t^{4} + 14 t^{3} u^{3} + 46 t^{3} u^{2} + 50 t^{3} u + 18 t^{3} + 9 t^{2} u^{3} + 36 t^{2} u^{2} + 45 t^{2} u + 18 t^{2} + 2 t u^{3} - 2 t u + 10 u^{3} + 14 u^{2}$" ], "text/plain": [ "" @@ -3177,7 +3179,7 @@ { "data": { "text/latex": [ - "$$4abc \\le a^2c^2+2ab^2+c^2$$" + "$$4 s t u \\le s^{2} u^{2}+2 s t^{2}+u^{2}$$" ], "text/plain": [ "" @@ -3189,7 +3191,7 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$2 t u \\le t^{2}+u^{2}$$" ], "text/plain": [ "" @@ -3201,7 +3203,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+10a^5b^3c^3+34a^5b^3c^2+38a^5b^3c+14a^5b^3+6a^5b^2c^3+27a^5b^2c^2+36a^5b^2c+15a^5b^2+8a^5bc^3+18a^5bc^2+16a^5bc+6a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+20a^4b^4c^3+60a^4b^4c^2+60a^4b^4c+20a^4b^4+54a^4b^3c^3+182a^4b^3c^2+202a^4b^3c+74a^4b^3+33a^4b^2c^3+144a^4b^2c^2+189a^4b^2c+78a^4b^2+34a^4bc^3+72a^4bc^2+62a^4bc+24a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+40a^3b^4c^3+120a^3b^4c^2+120a^3b^4c+40a^3b^4+116a^3b^3c^3+388a^3b^3c^2+428a^3b^3c+156a^3b^3+72a^3b^2c^3+306a^3b^2c^2+396a^3b^2c+162a^3b^2+56a^3bc^3+108a^3bc^2+88a^3bc+36a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+40a^2b^4c^3+120a^2b^4c^2+120a^2b^4c+40a^2b^4+124a^2b^3c^3+412a^2b^3c^2+452a^2b^3c+164a^2b^3+78a^2b^2c^3+324a^2b^2c^2+414a^2b^2c+168a^2b^2+40a^2bc^3+60a^2bc^2+40a^2bc+20a^2b+100a^2c^3+189a^2c^2+84a^2c+34a^2+20ab^4c^3+60ab^4c^2+60ab^4c+20ab^4+66ab^3c^3+218ab^3c^2+238ab^3c+86ab^3+42ab^2c^3+171ab^2c^2+216ab^2c+85ab^2+12abc^3+6abc^2+2ab+46ac^3+66ac^2+4b^4c^3+12b^4c^2+12b^4c+4b^4+14b^3c^3+46b^3c^2+50b^3c+18b^3+9b^2c^3+36b^2c^2+45b^2c+17b^2+2bc^3+10c^3+12c^2 $$" + "$$ 0 \\le 4 s^{5} t^{4} u^{3}+12 s^{5} t^{4} u^{2}+12 s^{5} t^{4} u+4 s^{5} t^{4}+10 s^{5} t^{3} u^{3}+34 s^{5} t^{3} u^{2}+38 s^{5} t^{3} u+14 s^{5} t^{3}+6 s^{5} t^{2} u^{3}+27 s^{5} t^{2} u^{2}+36 s^{5} t^{2} u+15 s^{5} t^{2}+8 s^{5} t u^{3}+18 s^{5} t u^{2}+16 s^{5} t u+6 s^{5} t+8 s^{5} u^{3}+24 s^{5} u^{2}+22 s^{5} u+10 s^{5}+20 s^{4} t^{4} u^{3}+60 s^{4} t^{4} u^{2}+60 s^{4} t^{4} u+20 s^{4} t^{4}+54 s^{4} t^{3} u^{3}+182 s^{4} t^{3} u^{2}+202 s^{4} t^{3} u+74 s^{4} t^{3}+33 s^{4} t^{2} u^{3}+144 s^{4} t^{2} u^{2}+189 s^{4} t^{2} u+78 s^{4} t^{2}+34 s^{4} t u^{3}+72 s^{4} t u^{2}+62 s^{4} t u+24 s^{4} t+44 s^{4} u^{3}+114 s^{4} u^{2}+90 s^{4} u+40 s^{4}+40 s^{3} t^{4} u^{3}+120 s^{3} t^{4} u^{2}+120 s^{3} t^{4} u+40 s^{3} t^{4}+116 s^{3} t^{3} u^{3}+388 s^{3} t^{3} u^{2}+428 s^{3} t^{3} u+156 s^{3} t^{3}+72 s^{3} t^{2} u^{3}+306 s^{3} t^{2} u^{2}+396 s^{3} t^{2} u+162 s^{3} t^{2}+56 s^{3} t u^{3}+108 s^{3} t u^{2}+88 s^{3} t u+36 s^{3} t+96 s^{3} u^{3}+216 s^{3} u^{2}+140 s^{3} u+60 s^{3}+40 s^{2} t^{4} u^{3}+120 s^{2} t^{4} u^{2}+120 s^{2} t^{4} u+40 s^{2} t^{4}+124 s^{2} t^{3} u^{3}+412 s^{2} t^{3} u^{2}+452 s^{2} t^{3} u+164 s^{2} t^{3}+78 s^{2} t^{2} u^{3}+324 s^{2} t^{2} u^{2}+414 s^{2} t^{2} u+168 s^{2} t^{2}+40 s^{2} t u^{3}+60 s^{2} t u^{2}+40 s^{2} t u+20 s^{2} t+100 s^{2} u^{3}+189 s^{2} u^{2}+84 s^{2} u+34 s^{2}+20 s t^{4} u^{3}+60 s t^{4} u^{2}+60 s t^{4} u+20 s t^{4}+66 s t^{3} u^{3}+218 s t^{3} u^{2}+238 s t^{3} u+86 s t^{3}+42 s t^{2} u^{3}+171 s t^{2} u^{2}+216 s t^{2} u+85 s t^{2}+12 s t u^{3}+6 s t u^{2}+2 s t+46 s u^{3}+66 s u^{2}+4 t^{4} u^{3}+12 t^{4} u^{2}+12 t^{4} u+4 t^{4}+14 t^{3} u^{3}+46 t^{3} u^{2}+50 t^{3} u+18 t^{3}+9 t^{2} u^{3}+36 t^{2} u^{2}+45 t^{2} u+17 t^{2}+2 t u^{3}+10 u^{3}+12 u^{2} $$" ], "text/plain": [ "" @@ -3225,8 +3227,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -3238,7 +3239,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1+a,b\\to 1/(1+b),c\\to 1/(1+c)$" + "Substitute $a\\to 1+v,b\\to 1/(1+w),c\\to 1/(1+x)$" ], "text/plain": [ "" @@ -3250,7 +3251,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+16a^5b^3c^3+48a^5b^3c^2+48a^5b^3c+16a^5b^3+24a^5b^2c^3+72a^5b^2c^2+72a^5b^2c+24a^5b^2+16a^5bc^3+48a^5bc^2+48a^5bc+16a^5b+4a^5c^3+12a^5c^2+12a^5c+4a^5+14a^4b^4c^3+46a^4b^4c^2+50a^4b^4c+18a^4b^4+60a^4b^3c^3+196a^4b^3c^2+212a^4b^3c+76a^4b^3+96a^4b^2c^3+312a^4b^2c^2+336a^4b^2c+120a^4b^2+68a^4bc^3+220a^4bc^2+236a^4bc+84a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+16a^3b^4c^3+62a^3b^4c^2+76a^3b^4c+30a^3b^4+76a^3b^3c^3+284a^3b^3c^2+340a^3b^3c+132a^3b^3+132a^3b^2c^3+480a^3b^2c^2+564a^3b^2c+216a^3b^2+100a^3bc^3+356a^3bc^2+412a^3bc+156a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+4a^2b^4c^3+30a^2b^4c^2+48a^2b^4c+22a^2b^4+28a^2b^3c^3+156a^2b^3c^2+228a^2b^3c+100a^2b^3+60a^2b^2c^3+288a^2b^2c^2+396a^2b^2c+168a^2b^2+52a^2bc^3+228a^2bc^2+300a^2bc+124a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+5ab^4c^3+7ab^4c^2+3ab^4c+ab^4+24ab^3c^3+40ab^3c^2+24ab^3c+8ab^3+33ab^2c^3+51ab^2c^2+27ab^2c+9ab^2+18abc^3+22abc^2+6abc+2ab+4ac^3+4ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2$" + "Numerator after substitutions: $4 v^{5} w^{4} x^{3} + 12 v^{5} w^{4} x^{2} + 12 v^{5} w^{4} x + 4 v^{5} w^{4} + 16 v^{5} w^{3} x^{3} + 48 v^{5} w^{3} x^{2} + 48 v^{5} w^{3} x + 16 v^{5} w^{3} + 24 v^{5} w^{2} x^{3} + 72 v^{5} w^{2} x^{2} + 72 v^{5} w^{2} x + 24 v^{5} w^{2} + 16 v^{5} w x^{3} + 48 v^{5} w x^{2} + 48 v^{5} w x + 16 v^{5} w + 4 v^{5} x^{3} + 12 v^{5} x^{2} + 12 v^{5} x + 4 v^{5} + 14 v^{4} w^{4} x^{3} + 46 v^{4} w^{4} x^{2} + 50 v^{4} w^{4} x + 18 v^{4} w^{4} + 60 v^{4} w^{3} x^{3} + 196 v^{4} w^{3} x^{2} + 212 v^{4} w^{3} x + 76 v^{4} w^{3} + 96 v^{4} w^{2} x^{3} + 312 v^{4} w^{2} x^{2} + 336 v^{4} w^{2} x + 120 v^{4} w^{2} + 68 v^{4} w x^{3} + 220 v^{4} w x^{2} + 236 v^{4} w x + 84 v^{4} w + 18 v^{4} x^{3} + 58 v^{4} x^{2} + 62 v^{4} x + 22 v^{4} + 16 v^{3} w^{4} x^{3} + 62 v^{3} w^{4} x^{2} + 76 v^{3} w^{4} x + 30 v^{3} w^{4} + 76 v^{3} w^{3} x^{3} + 284 v^{3} w^{3} x^{2} + 340 v^{3} w^{3} x + 132 v^{3} w^{3} + 132 v^{3} w^{2} x^{3} + 480 v^{3} w^{2} x^{2} + 564 v^{3} w^{2} x + 216 v^{3} w^{2} + 100 v^{3} w x^{3} + 356 v^{3} w x^{2} + 412 v^{3} w x + 156 v^{3} w + 28 v^{3} x^{3} + 98 v^{3} x^{2} + 112 v^{3} x + 42 v^{3} + 4 v^{2} w^{4} x^{3} + 30 v^{2} w^{4} x^{2} + 48 v^{2} w^{4} x + 22 v^{2} w^{4} + 28 v^{2} w^{3} x^{3} + 156 v^{2} w^{3} x^{2} + 228 v^{2} w^{3} x + 100 v^{2} w^{3} + 60 v^{2} w^{2} x^{3} + 288 v^{2} w^{2} x^{2} + 396 v^{2} w^{2} x + 168 v^{2} w^{2} + 52 v^{2} w x^{3} + 228 v^{2} w x^{2} + 300 v^{2} w x + 124 v^{2} w + 16 v^{2} x^{3} + 66 v^{2} x^{2} + 84 v^{2} x + 34 v^{2} + 5 v w^{4} x^{3} + 7 v w^{4} x^{2} + 3 v w^{4} x + v w^{4} + 24 v w^{3} x^{3} + 40 v w^{3} x^{2} + 24 v w^{3} x + 8 v w^{3} + 33 v w^{2} x^{3} + 51 v w^{2} x^{2} + 27 v w^{2} x + 9 v w^{2} + 18 v w x^{3} + 22 v w x^{2} + 6 v w x + 2 v w + 4 v x^{3} + 4 v x^{2} + 7 w^{4} x^{3} + 16 w^{4} x^{2} + 9 w^{4} x + 4 w^{4} + 38 w^{3} x^{3} + 82 w^{3} x^{2} + 46 w^{3} x + 18 w^{3} + 63 w^{2} x^{3} + 120 w^{2} x^{2} + 51 w^{2} x + 18 w^{2} + 38 w x^{3} + 56 w x^{2} + 2 w x + 10 x^{3} + 14 x^{2}$" ], "text/plain": [ "" @@ -3274,7 +3275,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^5b^4c^3+12a^5b^4c^2+12a^5b^4c+4a^5b^4+16a^5b^3c^3+48a^5b^3c^2+48a^5b^3c+16a^5b^3+24a^5b^2c^3+72a^5b^2c^2+72a^5b^2c+24a^5b^2+16a^5bc^3+48a^5bc^2+48a^5bc+16a^5b+4a^5c^3+12a^5c^2+12a^5c+4a^5+14a^4b^4c^3+46a^4b^4c^2+50a^4b^4c+18a^4b^4+60a^4b^3c^3+196a^4b^3c^2+212a^4b^3c+76a^4b^3+96a^4b^2c^3+312a^4b^2c^2+336a^4b^2c+120a^4b^2+68a^4bc^3+220a^4bc^2+236a^4bc+84a^4b+18a^4c^3+58a^4c^2+62a^4c+22a^4+16a^3b^4c^3+62a^3b^4c^2+76a^3b^4c+30a^3b^4+76a^3b^3c^3+284a^3b^3c^2+340a^3b^3c+132a^3b^3+132a^3b^2c^3+480a^3b^2c^2+564a^3b^2c+216a^3b^2+100a^3bc^3+356a^3bc^2+412a^3bc+156a^3b+28a^3c^3+98a^3c^2+112a^3c+42a^3+4a^2b^4c^3+30a^2b^4c^2+48a^2b^4c+22a^2b^4+28a^2b^3c^3+156a^2b^3c^2+228a^2b^3c+100a^2b^3+60a^2b^2c^3+288a^2b^2c^2+396a^2b^2c+168a^2b^2+52a^2bc^3+228a^2bc^2+300a^2bc+124a^2b+16a^2c^3+66a^2c^2+84a^2c+34a^2+5ab^4c^3+7ab^4c^2+3ab^4c+ab^4+24ab^3c^3+40ab^3c^2+24ab^3c+8ab^3+33ab^2c^3+51ab^2c^2+27ab^2c+9ab^2+18abc^3+22abc^2+6abc+2ab+4ac^3+4ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2 $$" + "$$ 0 \\le 4 v^{5} w^{4} x^{3}+16 v^{5} w^{3} x^{3}+24 v^{5} w^{2} x^{3}+16 v^{5} w x^{3}+4 v^{5} x^{3}+14 v^{4} w^{4} x^{3}+60 v^{4} w^{3} x^{3}+96 v^{4} w^{2} x^{3}+68 v^{4} w x^{3}+18 v^{4} x^{3}+16 v^{3} w^{4} x^{3}+76 v^{3} w^{3} x^{3}+132 v^{3} w^{2} x^{3}+100 v^{3} w x^{3}+28 v^{3} x^{3}+4 v^{2} w^{4} x^{3}+28 v^{2} w^{3} x^{3}+60 v^{2} w^{2} x^{3}+52 v^{2} w x^{3}+16 v^{2} x^{3}+5 v w^{4} x^{3}+24 v w^{3} x^{3}+33 v w^{2} x^{3}+18 v w x^{3}+4 v x^{3}+7 w^{4} x^{3}+38 w^{3} x^{3}+63 w^{2} x^{3}+38 w x^{3}+10 x^{3}+12 v^{5} w^{4} x^{2}+48 v^{5} w^{3} x^{2}+72 v^{5} w^{2} x^{2}+48 v^{5} w x^{2}+12 v^{5} x^{2}+46 v^{4} w^{4} x^{2}+196 v^{4} w^{3} x^{2}+312 v^{4} w^{2} x^{2}+220 v^{4} w x^{2}+58 v^{4} x^{2}+62 v^{3} w^{4} x^{2}+284 v^{3} w^{3} x^{2}+480 v^{3} w^{2} x^{2}+356 v^{3} w x^{2}+98 v^{3} x^{2}+30 v^{2} w^{4} x^{2}+156 v^{2} w^{3} x^{2}+288 v^{2} w^{2} x^{2}+228 v^{2} w x^{2}+66 v^{2} x^{2}+7 v w^{4} x^{2}+40 v w^{3} x^{2}+51 v w^{2} x^{2}+22 v w x^{2}+4 v x^{2}+16 w^{4} x^{2}+82 w^{3} x^{2}+120 w^{2} x^{2}+56 w x^{2}+14 x^{2}+12 v^{5} w^{4} x+48 v^{5} w^{3} x+72 v^{5} w^{2} x+48 v^{5} w x+12 v^{5} x+50 v^{4} w^{4} x+212 v^{4} w^{3} x+336 v^{4} w^{2} x+236 v^{4} w x+62 v^{4} x+76 v^{3} w^{4} x+340 v^{3} w^{3} x+564 v^{3} w^{2} x+412 v^{3} w x+112 v^{3} x+48 v^{2} w^{4} x+228 v^{2} w^{3} x+396 v^{2} w^{2} x+300 v^{2} w x+84 v^{2} x+3 v w^{4} x+24 v w^{3} x+27 v w^{2} x+6 v w x+9 w^{4} x+46 w^{3} x+51 w^{2} x+2 w x+4 v^{5} w^{4}+16 v^{5} w^{3}+24 v^{5} w^{2}+16 v^{5} w+4 v^{5}+18 v^{4} w^{4}+76 v^{4} w^{3}+120 v^{4} w^{2}+84 v^{4} w+22 v^{4}+30 v^{3} w^{4}+132 v^{3} w^{3}+216 v^{3} w^{2}+156 v^{3} w+42 v^{3}+22 v^{2} w^{4}+100 v^{2} w^{3}+168 v^{2} w^{2}+124 v^{2} w+34 v^{2}+v w^{4}+8 v w^{3}+9 v w^{2}+2 v w+4 w^{4}+18 w^{3}+18 w^{2} $$" ], "text/plain": [ "" @@ -3298,8 +3299,7 @@ { "data": { "text/latex": [ - "\n", - "\\hline\n" + "_______________________" ], "text/plain": [ "" @@ -3311,7 +3311,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 1/(1+a),b\\to 1/(1+b),c\\to 1/(1+c)$" + "Substitute $a\\to 1/(1+y),b\\to 1/(1+z),c\\to 1/(1+a_{1})$" ], "text/plain": [ "" @@ -3323,7 +3323,7 @@ { "data": { "text/latex": [ - "Numerator after substitutions: $11a^5b^4c^2+16a^5b^4c+9a^5b^4+10a^5b^3c^3+62a^5b^3c^2+74a^5b^3c+38a^5b^3+30a^5b^2c^3+117a^5b^2c^2+120a^5b^2c+57a^5b^2+24a^5bc^3+78a^5bc^2+72a^5bc+34a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+9a^4b^4c^3+64a^4b^4c^2+75a^4b^4c+40a^4b^4+86a^4b^3c^3+346a^4b^3c^2+350a^4b^3c+170a^4b^3+195a^4b^2c^3+612a^4b^2c^2+543a^4b^2c+246a^4b^2+142a^4bc^3+384a^4bc^2+298a^4bc+136a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+36a^3b^4c^3+146a^3b^4c^2+140a^3b^4c+70a^3b^4+244a^3b^3c^3+764a^3b^3c^2+660a^3b^3c+300a^3b^3+480a^3b^2c^3+1278a^3b^2c^2+972a^3b^2c+414a^3b^2+328a^3bc^3+756a^3bc^2+472a^3bc+204a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+54a^2b^4c^3+162a^2b^4c^2+126a^2b^4c+58a^2b^4+312a^2b^3c^3+816a^2b^3c^2+592a^2b^3c+248a^2b^3+558a^2b^2c^3+1284a^2b^2c^2+798a^2b^2c+312a^2b^2+360a^2bc^3+700a^2bc^2+296a^2bc+116a^2b+100a^2c^3+190a^2c^2+84a^2c+34a^2+30ab^4c^3+73ab^4c^2+42ab^4c+19ab^4+166ab^3c^3+370ab^3c^2+206ab^3c+82ab^3+282ab^2c^3+549ab^2c^2+228ab^2c+81ab^2+172abc^3+258abc^2+4abc-2ab+46ac^3+66ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+18b^2+38bc^3+56bc^2+2bc+10c^3+14c^2$" + "Numerator after substitutions: $10 a_{1}^{3} y^{5} z^{3} + 30 a_{1}^{3} y^{5} z^{2} + 24 a_{1}^{3} y^{5} z + 8 a_{1}^{3} y^{5} + 9 a_{1}^{3} y^{4} z^{4} + 86 a_{1}^{3} y^{4} z^{3} + 195 a_{1}^{3} y^{4} z^{2} + 142 a_{1}^{3} y^{4} z + 44 a_{1}^{3} y^{4} + 36 a_{1}^{3} y^{3} z^{4} + 244 a_{1}^{3} y^{3} z^{3} + 480 a_{1}^{3} y^{3} z^{2} + 328 a_{1}^{3} y^{3} z + 96 a_{1}^{3} y^{3} + 54 a_{1}^{3} y^{2} z^{4} + 312 a_{1}^{3} y^{2} z^{3} + 558 a_{1}^{3} y^{2} z^{2} + 360 a_{1}^{3} y^{2} z + 100 a_{1}^{3} y^{2} + 30 a_{1}^{3} y z^{4} + 166 a_{1}^{3} y z^{3} + 282 a_{1}^{3} y z^{2} + 172 a_{1}^{3} y z + 46 a_{1}^{3} y + 7 a_{1}^{3} z^{4} + 38 a_{1}^{3} z^{3} + 63 a_{1}^{3} z^{2} + 38 a_{1}^{3} z + 10 a_{1}^{3} + 11 a_{1}^{2} y^{5} z^{4} + 62 a_{1}^{2} y^{5} z^{3} + 117 a_{1}^{2} y^{5} z^{2} + 78 a_{1}^{2} y^{5} z + 24 a_{1}^{2} y^{5} + 64 a_{1}^{2} y^{4} z^{4} + 346 a_{1}^{2} y^{4} z^{3} + 612 a_{1}^{2} y^{4} z^{2} + 384 a_{1}^{2} y^{4} z + 114 a_{1}^{2} y^{4} + 146 a_{1}^{2} y^{3} z^{4} + 764 a_{1}^{2} y^{3} z^{3} + 1278 a_{1}^{2} y^{3} z^{2} + 756 a_{1}^{2} y^{3} z + 216 a_{1}^{2} y^{3} + 162 a_{1}^{2} y^{2} z^{4} + 816 a_{1}^{2} y^{2} z^{3} + 1284 a_{1}^{2} y^{2} z^{2} + 700 a_{1}^{2} y^{2} z + 190 a_{1}^{2} y^{2} + 73 a_{1}^{2} y z^{4} + 370 a_{1}^{2} y z^{3} + 549 a_{1}^{2} y z^{2} + 258 a_{1}^{2} y z + 66 a_{1}^{2} y + 16 a_{1}^{2} z^{4} + 82 a_{1}^{2} z^{3} + 120 a_{1}^{2} z^{2} + 56 a_{1}^{2} z + 14 a_{1}^{2} + 16 a_{1} y^{5} z^{4} + 74 a_{1} y^{5} z^{3} + 120 a_{1} y^{5} z^{2} + 72 a_{1} y^{5} z + 22 a_{1} y^{5} + 75 a_{1} y^{4} z^{4} + 350 a_{1} y^{4} z^{3} + 543 a_{1} y^{4} z^{2} + 298 a_{1} y^{4} z + 90 a_{1} y^{4} + 140 a_{1} y^{3} z^{4} + 660 a_{1} y^{3} z^{3} + 972 a_{1} y^{3} z^{2} + 472 a_{1} y^{3} z + 140 a_{1} y^{3} + 126 a_{1} y^{2} z^{4} + 592 a_{1} y^{2} z^{3} + 798 a_{1} y^{2} z^{2} + 296 a_{1} y^{2} z + 84 a_{1} y^{2} + 42 a_{1} y z^{4} + 206 a_{1} y z^{3} + 228 a_{1} y z^{2} + 4 a_{1} y z + 9 a_{1} z^{4} + 46 a_{1} z^{3} + 51 a_{1} z^{2} + 2 a_{1} z + 9 y^{5} z^{4} + 38 y^{5} z^{3} + 57 y^{5} z^{2} + 34 y^{5} z + 10 y^{5} + 40 y^{4} z^{4} + 170 y^{4} z^{3} + 246 y^{4} z^{2} + 136 y^{4} z + 40 y^{4} + 70 y^{3} z^{4} + 300 y^{3} z^{3} + 414 y^{3} z^{2} + 204 y^{3} z + 60 y^{3} + 58 y^{2} z^{4} + 248 y^{2} z^{3} + 312 y^{2} z^{2} + 116 y^{2} z + 34 y^{2} + 19 y z^{4} + 82 y z^{3} + 81 y z^{2} - 2 y z + 4 z^{4} + 18 z^{3} + 18 z^{2}$" ], "text/plain": [ "" @@ -3359,7 +3359,7 @@ { "data": { "text/latex": [ - "$$2ab \\le a^2+b^2$$" + "$$2 y z \\le y^{2}+z^{2}$$" ], "text/plain": [ "" @@ -3371,7 +3371,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 11a^5b^4c^2+16a^5b^4c+9a^5b^4+10a^5b^3c^3+62a^5b^3c^2+74a^5b^3c+38a^5b^3+30a^5b^2c^3+117a^5b^2c^2+120a^5b^2c+57a^5b^2+24a^5bc^3+78a^5bc^2+72a^5bc+34a^5b+8a^5c^3+24a^5c^2+22a^5c+10a^5+9a^4b^4c^3+64a^4b^4c^2+75a^4b^4c+40a^4b^4+86a^4b^3c^3+346a^4b^3c^2+350a^4b^3c+170a^4b^3+195a^4b^2c^3+612a^4b^2c^2+543a^4b^2c+246a^4b^2+142a^4bc^3+384a^4bc^2+298a^4bc+136a^4b+44a^4c^3+114a^4c^2+90a^4c+40a^4+36a^3b^4c^3+146a^3b^4c^2+140a^3b^4c+70a^3b^4+244a^3b^3c^3+764a^3b^3c^2+660a^3b^3c+300a^3b^3+480a^3b^2c^3+1278a^3b^2c^2+972a^3b^2c+414a^3b^2+328a^3bc^3+756a^3bc^2+472a^3bc+204a^3b+96a^3c^3+216a^3c^2+140a^3c+60a^3+54a^2b^4c^3+162a^2b^4c^2+126a^2b^4c+58a^2b^4+312a^2b^3c^3+816a^2b^3c^2+592a^2b^3c+248a^2b^3+558a^2b^2c^3+1284a^2b^2c^2+798a^2b^2c+312a^2b^2+360a^2bc^3+700a^2bc^2+296a^2bc+116a^2b+100a^2c^3+190a^2c^2+84a^2c+33a^2+30ab^4c^3+73ab^4c^2+42ab^4c+19ab^4+166ab^3c^3+370ab^3c^2+206ab^3c+82ab^3+282ab^2c^3+549ab^2c^2+228ab^2c+81ab^2+172abc^3+258abc^2+4abc+46ac^3+66ac^2+7b^4c^3+16b^4c^2+9b^4c+4b^4+38b^3c^3+82b^3c^2+46b^3c+18b^3+63b^2c^3+120b^2c^2+51b^2c+17b^2+38bc^3+56bc^2+2bc+10c^3+14c^2 $$" + "$$ 0 \\le 11 a_{1}^{2} y^{5} z^{4}+16 a_{1} y^{5} z^{4}+9 y^{5} z^{4}+10 a_{1}^{3} y^{5} z^{3}+62 a_{1}^{2} y^{5} z^{3}+74 a_{1} y^{5} z^{3}+38 y^{5} z^{3}+30 a_{1}^{3} y^{5} z^{2}+117 a_{1}^{2} y^{5} z^{2}+120 a_{1} y^{5} z^{2}+57 y^{5} z^{2}+24 a_{1}^{3} y^{5} z+78 a_{1}^{2} y^{5} z+72 a_{1} y^{5} z+34 y^{5} z+8 a_{1}^{3} y^{5}+24 a_{1}^{2} y^{5}+22 a_{1} y^{5}+10 y^{5}+9 a_{1}^{3} y^{4} z^{4}+64 a_{1}^{2} y^{4} z^{4}+75 a_{1} y^{4} z^{4}+40 y^{4} z^{4}+86 a_{1}^{3} y^{4} z^{3}+346 a_{1}^{2} y^{4} z^{3}+350 a_{1} y^{4} z^{3}+170 y^{4} z^{3}+195 a_{1}^{3} y^{4} z^{2}+612 a_{1}^{2} y^{4} z^{2}+543 a_{1} y^{4} z^{2}+246 y^{4} z^{2}+142 a_{1}^{3} y^{4} z+384 a_{1}^{2} y^{4} z+298 a_{1} y^{4} z+136 y^{4} z+44 a_{1}^{3} y^{4}+114 a_{1}^{2} y^{4}+90 a_{1} y^{4}+40 y^{4}+36 a_{1}^{3} y^{3} z^{4}+146 a_{1}^{2} y^{3} z^{4}+140 a_{1} y^{3} z^{4}+70 y^{3} z^{4}+244 a_{1}^{3} y^{3} z^{3}+764 a_{1}^{2} y^{3} z^{3}+660 a_{1} y^{3} z^{3}+300 y^{3} z^{3}+480 a_{1}^{3} y^{3} z^{2}+1278 a_{1}^{2} y^{3} z^{2}+972 a_{1} y^{3} z^{2}+414 y^{3} z^{2}+328 a_{1}^{3} y^{3} z+756 a_{1}^{2} y^{3} z+472 a_{1} y^{3} z+204 y^{3} z+96 a_{1}^{3} y^{3}+216 a_{1}^{2} y^{3}+140 a_{1} y^{3}+60 y^{3}+54 a_{1}^{3} y^{2} z^{4}+162 a_{1}^{2} y^{2} z^{4}+126 a_{1} y^{2} z^{4}+58 y^{2} z^{4}+312 a_{1}^{3} y^{2} z^{3}+816 a_{1}^{2} y^{2} z^{3}+592 a_{1} y^{2} z^{3}+248 y^{2} z^{3}+558 a_{1}^{3} y^{2} z^{2}+1284 a_{1}^{2} y^{2} z^{2}+798 a_{1} y^{2} z^{2}+312 y^{2} z^{2}+360 a_{1}^{3} y^{2} z+700 a_{1}^{2} y^{2} z+296 a_{1} y^{2} z+116 y^{2} z+100 a_{1}^{3} y^{2}+190 a_{1}^{2} y^{2}+84 a_{1} y^{2}+33 y^{2}+30 a_{1}^{3} y z^{4}+73 a_{1}^{2} y z^{4}+42 a_{1} y z^{4}+19 y z^{4}+166 a_{1}^{3} y z^{3}+370 a_{1}^{2} y z^{3}+206 a_{1} y z^{3}+82 y z^{3}+282 a_{1}^{3} y z^{2}+549 a_{1}^{2} y z^{2}+228 a_{1} y z^{2}+81 y z^{2}+172 a_{1}^{3} y z+258 a_{1}^{2} y z+4 a_{1} y z+46 a_{1}^{3} y+66 a_{1}^{2} y+7 a_{1}^{3} z^{4}+16 a_{1}^{2} z^{4}+9 a_{1} z^{4}+4 z^{4}+38 a_{1}^{3} z^{3}+82 a_{1}^{2} z^{3}+46 a_{1} z^{3}+18 z^{3}+63 a_{1}^{3} z^{2}+120 a_{1}^{2} z^{2}+51 a_{1} z^{2}+17 z^{2}+38 a_{1}^{3} z+56 a_{1}^{2} z+2 a_{1} z+10 a_{1}^{3}+14 a_{1}^{2} $$" ], "text/plain": [ "" @@ -3404,6 +3404,7 @@ } ], "source": [ + "newproof()\n", "formula=Sm('-(3a + 2b + c)(2a^3 + 3b^2 + 6c + 1) + (4a + 4b + 4c)(a^4 + b^3 + c^2 + 3)')\n", "powerprove(formula)" ] @@ -3428,7 +3429,7 @@ { "data": { "text/latex": [ - "numerator: $21f(-1,4,3)-21f(1,2,3)-21f(2,3,1)+21f(3,-1,4)-21f(3,1,2)+21f(4,3,-1)$" + "numerator: $21 f{\\left(-1,4,3 \\right)} - 21 f{\\left(1,2,3 \\right)} - 21 f{\\left(2,3,1 \\right)} + 21 f{\\left(3,-1,4 \\right)} - 21 f{\\left(3,1,2 \\right)} + 21 f{\\left(4,3,-1 \\right)}$" ], "text/plain": [ "" @@ -3568,7 +3569,8 @@ "metadata": {}, "outputs": [], "source": [ - "sVars.display=lambda x:None #turn off printing of proofs\n", + "shiro.display=lambda x:None #turn off printing of proofs\n", + "newproof()\n", "formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')" ] }, @@ -3639,7 +3641,7 @@ { "data": { "text/plain": [ - "(2.5326984818340415e-10, 7.129450063690368, 1.7908873553542452e-10)" + "(1.7908873553542452e-10, 2.5326984818340415e-10, 7.129450063690368)" ] }, "execution_count": 28, @@ -3656,7 +3658,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "First and third value is approximately equal to 0, so we can try to replace 0 with 1." + "First and second value is approximately equal to 0, so we can try to replace 0 with 1." ] }, { @@ -3676,7 +3678,7 @@ } ], "source": [ - "prove(formula1,values='1,7,1')" + "prove(formula1,values='1,1,7')" ] }, { @@ -3694,7 +3696,7 @@ { "data": { "text/plain": [ - "(1.4142142855953455, 39809595184.05965, 1)" + "(1, 1.4142142855953455, 39809595184.05965)" ] }, "execution_count": 30, @@ -3703,7 +3705,7 @@ } ], "source": [ - "newvalues=(values[0]/values[2],values[1]/values[2],1)\n", + "newvalues=(1,values[1]/values[0],values[2]/values[0])\n", "newvalues" ] }, @@ -3724,14 +3726,14 @@ } ], "source": [ - "newvalues[0]**2" + "newvalues[1]**2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now the second value is very big. Technically we could use it, but it would run into overflow error, so we will use 1 instead of it. First value is very close to $\\sqrt{2}$, so this value will be our next try." + "Now the third value is very big. Technically we could use it, but it would run into overflow error, so we will use 1 instead of it. Second value is very close to $\\sqrt{2}$, so this value will be our next try." ] }, { @@ -3751,7 +3753,7 @@ } ], "source": [ - "prove(formula1,values='sqrt(2),1,1')" + "prove(formula1,values='1,sqrt(2),1')" ] }, { @@ -3781,7 +3783,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c + d$" ], "text/plain": [ "" @@ -3793,7 +3795,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to b+c$" + "Substitute $c\\to b + e$" ], "text/plain": [ "" @@ -3805,7 +3807,7 @@ { "data": { "text/latex": [ - "numerator: $2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4a^2bc^3+4\\sqrt{2}a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4ab^2c^3+4\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $2 b^{4} d^{2} + 2 b^{4} d e + 2 b^{4} e^{2} + 4 b^{3} d^{3} + 2 \\sqrt{2} b^{3} d^{2} e + 10 b^{3} d^{2} e + 2 \\sqrt{2} b^{3} d e^{2} + 6 b^{3} d e^{2} + 4 b^{3} e^{3} + 2 b^{2} d^{4} + 2 \\sqrt{2} b^{2} d^{3} e + 10 b^{2} d^{3} e + 6 \\sqrt{2} b^{2} d^{2} e^{2} + 12 b^{2} d^{2} e^{2} + 4 b^{2} d e^{3} + 4 \\sqrt{2} b^{2} d e^{3} + 2 b^{2} e^{4} + 2 b d^{4} e + 2 \\sqrt{2} b d^{3} e^{2} + 6 b d^{3} e^{2} + 4 b d^{2} e^{3} + 4 \\sqrt{2} b d^{2} e^{3} + 2 \\sqrt{2} b d e^{4} + d^{4} e^{2} + 2 d^{3} e^{3} + d^{2} e^{4}$" ], "text/plain": [ "" @@ -3817,7 +3819,7 @@ { "data": { "text/latex": [ - "denominator: $a^2b^4+2a^2b^3c+a^2b^2c^2+2ab^5+6ab^4c+6ab^3c^2+2ab^2c^3+b^6+4b^5c+6b^4c^2+4b^3c^3+b^2c^4$" + "denominator: $b^{6} + 2 b^{5} d + 4 b^{5} e + b^{4} d^{2} + 6 b^{4} d e + 6 b^{4} e^{2} + 2 b^{3} d^{2} e + 6 b^{3} d e^{2} + 4 b^{3} e^{3} + b^{2} d^{2} e^{2} + 2 b^{2} d e^{3} + b^{2} e^{4}$" ], "text/plain": [ "" @@ -3841,7 +3843,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4\\sqrt{2}a^2bc^3+4a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4\\sqrt{2}ab^2c^3+4ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4 $$" + "$$ 0 \\le 2 b^{4} d^{2}+2 b^{4} d e+2 b^{4} e^{2}+4 b^{3} d^{3}+2 \\sqrt{2} b^{3} d^{2} e+10 b^{3} d^{2} e+2 \\sqrt{2} b^{3} d e^{2}+6 b^{3} d e^{2}+4 b^{3} e^{3}+2 b^{2} d^{4}+2 \\sqrt{2} b^{2} d^{3} e+10 b^{2} d^{3} e+6 \\sqrt{2} b^{2} d^{2} e^{2}+12 b^{2} d^{2} e^{2}+4 \\sqrt{2} b^{2} d e^{3}+4 b^{2} d e^{3}+2 b^{2} e^{4}+2 b d^{4} e+2 \\sqrt{2} b d^{3} e^{2}+6 b d^{3} e^{2}+4 \\sqrt{2} b d^{2} e^{3}+4 b d^{2} e^{3}+2 \\sqrt{2} b d e^{4}+d^{4} e^{2}+2 d^{3} e^{3}+d^{2} e^{4} $$" ], "text/plain": [ "" @@ -3877,7 +3879,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b + f$" ], "text/plain": [ "" @@ -3889,7 +3891,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c + g$" ], "text/plain": [ "" @@ -3901,7 +3903,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to \\sqrt{2}a$" + "Substitute $f\\to \\sqrt{2} h$" ], "text/plain": [ "" @@ -3913,7 +3915,7 @@ { "data": { "text/latex": [ - "numerator: $4a^4b^2+8a^4bc+8a^4c^2+4\\sqrt{2}a^3b^3-8a^3b^2c+12\\sqrt{2}a^3b^2c-8a^3bc^2+20\\sqrt{2}a^3bc^2+8\\sqrt{2}a^3c^3+2a^2b^4-8\\sqrt{2}a^2b^3c+8a^2b^3c-12\\sqrt{2}a^2b^2c^2+24a^2b^2c^2-4\\sqrt{2}a^2bc^3+20a^2bc^3+4a^2c^4-4ab^4c-8ab^3c^2+4\\sqrt{2}ab^3c^2-4ab^2c^3+6\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $2 c^{4} g^{2} + 2 \\sqrt{2} c^{4} g h + 4 c^{4} h^{2} + 4 c^{3} g^{3} - 4 c^{3} g^{2} h + 6 \\sqrt{2} c^{3} g^{2} h - 4 \\sqrt{2} c^{3} g h^{2} + 20 c^{3} g h^{2} + 8 \\sqrt{2} c^{3} h^{3} + 2 c^{2} g^{4} - 8 c^{2} g^{3} h + 4 \\sqrt{2} c^{2} g^{3} h - 12 \\sqrt{2} c^{2} g^{2} h^{2} + 24 c^{2} g^{2} h^{2} - 8 c^{2} g h^{3} + 20 \\sqrt{2} c^{2} g h^{3} + 8 c^{2} h^{4} - 4 c g^{4} h - 8 \\sqrt{2} c g^{3} h^{2} + 8 c g^{3} h^{2} - 8 c g^{2} h^{3} + 12 \\sqrt{2} c g^{2} h^{3} + 8 c g h^{4} + 2 g^{4} h^{2} + 4 \\sqrt{2} g^{3} h^{3} + 4 g^{2} h^{4}$" ], "text/plain": [ "" @@ -3925,7 +3927,7 @@ { "data": { "text/latex": [ - "denominator: $2a^2b^2c^2+4a^2bc^3+2a^2c^4+2\\sqrt{2}ab^3c^2+6\\sqrt{2}ab^2c^3+6\\sqrt{2}abc^4+2\\sqrt{2}ac^5+b^4c^2+4b^3c^3+6b^2c^4+4bc^5+c^6$" + "denominator: $c^{6} + 4 c^{5} g + 2 \\sqrt{2} c^{5} h + 6 c^{4} g^{2} + 6 \\sqrt{2} c^{4} g h + 2 c^{4} h^{2} + 4 c^{3} g^{3} + 6 \\sqrt{2} c^{3} g^{2} h + 4 c^{3} g h^{2} + c^{2} g^{4} + 2 \\sqrt{2} c^{2} g^{3} h + 2 c^{2} g^{2} h^{2}$" ], "text/plain": [ "" @@ -3961,7 +3963,7 @@ { "data": { "text/latex": [ - "$$8a^3b^2c \\le 4a^4b^2+4a^2b^2c^2$$" + "$$4 c^{3} g^{2} h \\le 2 c^{4} g^{2}+2 c^{2} g^{2} h^{2}$$" ], "text/plain": [ "" @@ -3973,7 +3975,7 @@ { "data": { "text/latex": [ - "$$8\\sqrt{2}a^2b^3c \\le 4\\sqrt{2}a^3b^3+4\\sqrt{2}ab^3c^2$$" + "$$4 \\sqrt{2} c^{3} g h^{2} \\le 2 \\sqrt{2} c^{4} g h+\\sqrt{2} c^{3} h^{3}+\\sqrt{2} c g^{2} h^{3}$$" ], "text/plain": [ "" @@ -3985,7 +3987,7 @@ { "data": { "text/latex": [ - "$$12\\sqrt{2}a^2b^2c^2 \\le 6\\sqrt{2}a^3b^2c+6\\sqrt{2}ab^2c^3$$" + "$$8 c^{2} g^{3} h \\le 4 c^{3} g^{3}+4 c g^{3} h^{2}$$" ], "text/plain": [ "" @@ -3997,7 +3999,7 @@ { "data": { "text/latex": [ - "$$4\\sqrt{2}a^2bc^3 \\le 2\\sqrt{2}a^3bc^2+2\\sqrt{2}abc^4$$" + "$$12 \\sqrt{2} c^{2} g^{2} h^{2} \\le 6 \\sqrt{2} c^{3} g^{2} h+6 \\sqrt{2} c g^{2} h^{3}$$" ], "text/plain": [ "" @@ -4009,7 +4011,7 @@ { "data": { "text/latex": [ - "$$4ab^4c \\le 2a^2b^4+2b^4c^2$$" + "$$8 c^{2} g h^{3} \\le 4 c^{3} g h^{2}+2 c^{2} h^{4}+2 g^{2} h^{4}$$" ], "text/plain": [ "" @@ -4021,7 +4023,7 @@ { "data": { "text/latex": [ - "$$8ab^3c^2 \\le 4a^2b^3c+4b^3c^3$$" + "$$4 c g^{4} h \\le 2 c^{2} g^{4}+2 g^{4} h^{2}$$" ], "text/plain": [ "" @@ -4033,7 +4035,7 @@ { "data": { "text/latex": [ - "$$8a^3bc^2 \\le 4a^4bc+4a^2bc^3$$" + "$$8 \\sqrt{2} c g^{3} h^{2} \\le 4 \\sqrt{2} c^{2} g^{3} h+4 \\sqrt{2} g^{3} h^{3}$$" ], "text/plain": [ "" @@ -4045,7 +4047,7 @@ { "data": { "text/latex": [ - "$$4ab^2c^3 \\le 2a^2b^2c^2+2b^2c^4$$" + "$$8 c g^{2} h^{3} \\le 4 c g^{3} h^{2}+4 c g h^{4}$$" ], "text/plain": [ "" @@ -4057,7 +4059,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 4a^4bc+8a^4c^2+6\\sqrt{2}a^3b^2c+18\\sqrt{2}a^3bc^2+8\\sqrt{2}a^3c^3+4a^2b^3c+18a^2b^2c^2+16a^2bc^3+4a^2c^4 $$" + "$$ 0 \\le 4 c^{4} h^{2}+16 c^{3} g h^{2}+7 \\sqrt{2} c^{3} h^{3}+22 c^{2} g^{2} h^{2}+20 \\sqrt{2} c^{2} g h^{3}+6 c^{2} h^{4}+5 \\sqrt{2} c g^{2} h^{3}+4 c g h^{4}+2 g^{2} h^{4} $$" ], "text/plain": [ "" @@ -4090,22 +4092,16 @@ } ], "source": [ - "sVars.display=lambda x:display(Latex(x)) #turn on printing proofs \n", + "newproof()\n", + "shiro.display=lambda x:display(Latex(x)) #turn on printing proofs \n", "formula=cyclize('((a-b)/c)^2-2*sqrt(2)*(a-b)/c')\n", "display(Latex('Case $a\\ge c\\ge b$'))\n", "formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')\n", "prove(formula1)\n", "display(Latex('Case $a\\ge b\\ge c$'))\n", "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", - "prove(formula2,values='2**(1/2),1,1')" + "prove(formula2,values='1,2**(1/2),1')" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/examples.pdf b/examples.pdf index 71c7234..f90f158 100644 Binary files a/examples.pdf and b/examples.pdf differ diff --git a/sandbox.ipynb b/sandbox.ipynb index 8596d7a..1274680 100644 --- a/sandbox.ipynb +++ b/sandbox.ipynb @@ -16,145 +16,39 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "from shiroindev import *\n", "from sympy import *\n", "from itertools import permutations, combinations\n", - "sVars.seed=1\n", + "shiro.seed=1\n", "from IPython.display import Latex\n", - "sVars.display=lambda x:display(Latex(x))" + "shiro.display=lambda x:display(Latex(x))" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "numerator: $12a^3-18a^2b+6a^2c+6ab^2-18ac^2+12b^3-18b^2c+6bc^2+12c^3$" + "__________________________" ], "text/plain": [ "" ] }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $4a^2b+2a^2c+2ab^2+9abc+4ac^2+4b^2c+2bc^2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "From weighted AM-GM inequality:" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18a^2b \\le 10a^3+6ab^2+2b^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18ac^2 \\le 2a^3+6a^2c+10c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$18b^2c \\le 10b^3+6bc^2+2c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 0 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [ - "0" - ] - }, - "execution_count": 3, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "formula=cyclize('(a+b)/(2*b+c)')-2\n", - "prove(formula*6)" + "Latex(r'__________________________')" ] }, { @@ -165,7 +59,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to s-s/(a+1)$" + "Substitute $a\\to s-\\frac{s}{d+1}$" ], "text/plain": [ "" @@ -177,7 +71,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to s-s/(b+1)$" + "Substitute $b\\to s-\\frac{s}{e+1}$" ], "text/plain": [ "" @@ -189,7 +83,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to s-s/(c+1)$" + "Substitute $c\\to s-\\frac{s}{f+1}$" ], "text/plain": [ "" @@ -201,7 +95,7 @@ { "data": { "text/latex": [ - "numerator: $abcs^2+s^2$" + "numerator: $defs^2+s^2$" ], "text/plain": [ "" @@ -213,7 +107,7 @@ { "data": { "text/latex": [ - "denominator: $abc+ab+ac+a+bc+b+c+1$" + "denominator: $def+de+df+d+ef+e+f+1$" ], "text/plain": [ "" @@ -237,7 +131,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le abcs^2+s^2 $$" + "$$ 0 \\le defs^2+s^2 $$" ], "text/plain": [ "" @@ -317,7 +211,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+y$" + "Substitute $x\\to g+y$" ], "text/plain": [ "" @@ -329,7 +223,7 @@ { "data": { "text/latex": [ - "$$x^{2}$$" + "$$g^{2}$$" ], "text/plain": [ "" @@ -372,7 +266,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to h+x$" ], "text/plain": [ "" @@ -384,7 +278,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} z^{t} - x x^{t} y + x y z^{t} + x y \\left(x + y\\right)^{t} - 2 x z z^{t} + x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z z^{t} - y z \\left(x + y\\right)^{t} + z^{2} z^{t}$$" + "4 $$h^{2} \\left(h + x\\right)^{t} - h x x^{t} + h x z^{t} + h x \\left(h + x\\right)^{t} + h x^{t} z - h z z^{t} - h z \\left(h + x\\right)^{t} + x^{2} z^{t} - 2 x z z^{t} + z^{2} z^{t}$$" ], "text/plain": [ "" @@ -396,7 +290,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to i+x$" ], "text/plain": [ "" @@ -408,7 +302,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} y^{t} - x x^{t} z - 2 x y y^{t} + x y^{t} z + x z \\left(x + z\\right)^{t} + x^{t} y z + y^{2} y^{t} - y y^{t} z - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$i^{2} \\left(i + x\\right)^{t} - i x x^{t} + i x y^{t} + i x \\left(i + x\\right)^{t} + i x^{t} y - i y y^{t} - i y \\left(i + x\\right)^{t} + x^{2} y^{t} - 2 x y y^{t} + y^{2} y^{t}$$" ], "text/plain": [ "" @@ -420,7 +314,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $z\\to j+y$" ], "text/plain": [ "" @@ -432,7 +326,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} x^{t} - 2 x x^{t} y - x x^{t} z + x y^{t} z - x z \\left(y + z\\right)^{t} + x^{t} y^{2} + x^{t} y z - y y^{t} z + y z \\left(y + z\\right)^{t} + z^{2} \\left(y + z\\right)^{t}$$" + "4 $$j^{2} \\left(j + y\\right)^{t} - j x x^{t} + j x y^{t} - j x \\left(j + y\\right)^{t} + j x^{t} y - j y y^{t} + j y \\left(j + y\\right)^{t} + x^{2} x^{t} - 2 x x^{t} y + x^{t} y^{2}$$" ], "text/plain": [ "" @@ -444,7 +338,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to k+x$" ], "text/plain": [ "" @@ -456,7 +350,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to l+x$" ], "text/plain": [ "" @@ -468,7 +362,7 @@ { "data": { "text/latex": [ - "4 $$x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z \\left(x + y\\right)^{t} - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$k^{2} \\left(k + x\\right)^{t} + k l x^{t} - k l \\left(k + x\\right)^{t} - k l \\left(l + x\\right)^{t} + l^{2} \\left(l + x\\right)^{t}$$" ], "text/plain": [ "" @@ -480,7 +374,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $l\\to k+m$" ], "text/plain": [ "" @@ -492,7 +386,7 @@ { "data": { "text/latex": [ - "3 $$x^{t} y^{2} + x^{t} y z - y z \\left(x + y\\right)^{t} + y z \\left(x + y + z\\right)^{t} + z^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$k^{2} x^{t} + k m x^{t} - k m \\left(k + x\\right)^{t} + k m \\left(k + m + x\\right)^{t} + m^{2} \\left(k + m + x\\right)^{t}$$" ], "text/plain": [ "" @@ -504,7 +398,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to n+x$" ], "text/plain": [ "" @@ -516,7 +410,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to o+x$" ], "text/plain": [ "" @@ -528,7 +422,7 @@ { "data": { "text/latex": [ - "4 $$x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z \\left(x + y\\right)^{t} - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$n^{2} \\left(n + x\\right)^{t} + n o x^{t} - n o \\left(n + x\\right)^{t} - n o \\left(o + x\\right)^{t} + o^{2} \\left(o + x\\right)^{t}$$" ], "text/plain": [ "" @@ -540,7 +434,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $o\\to n+p$" ], "text/plain": [ "" @@ -552,7 +446,7 @@ { "data": { "text/latex": [ - "3 $$x^{t} y^{2} + x^{t} y z - y z \\left(x + y\\right)^{t} + y z \\left(x + y + z\\right)^{t} + z^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$n^{2} x^{t} + n p x^{t} - n p \\left(n + x\\right)^{t} + n p \\left(n + p + x\\right)^{t} + p^{2} \\left(n + p + x\\right)^{t}$$" ], "text/plain": [ "" @@ -574,7 +468,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+y$" + "Substitute $x\\to q+y$" ], "text/plain": [ "" @@ -586,10 +480,10 @@ { "data": { "text/latex": [ - "$\\displaystyle x^{2} \\left(x + y\\right)^{t} - x y y^{t} + x y z^{t} + x y \\left(x + y\\right)^{t} + x y^{t} z - x z z^{t} - x z \\left(x + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" + "$\\displaystyle q^{2} \\left(q + y\\right)^{t} - q y y^{t} + q y z^{t} + q y \\left(q + y\\right)^{t} + q y^{t} z - q z z^{t} - q z \\left(q + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" ], "text/plain": [ - "x**2*(x + y)**t - x*y*y**t + x*y*z**t + x*y*(x + y)**t + x*y**t*z - x*z*z**t - x*z*(x + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" + "q**2*(q + y)**t - q*y*y**t + q*y*z**t + q*y*(q + y)**t + q*y**t*z - q*z*z**t - q*z*(q + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" ] }, "execution_count": 10, @@ -609,7 +503,7 @@ { "data": { "text/latex": [ - "Substitute $x\\to x+y$" + "Substitute $x\\to r+y$" ], "text/plain": [ "" @@ -621,10 +515,10 @@ { "data": { "text/latex": [ - "$\\displaystyle x^{2} \\left(x + y\\right)^{t} - x y y^{t} + x y z^{t} + x y \\left(x + y\\right)^{t} + x y^{t} z - x z z^{t} - x z \\left(x + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" + "$\\displaystyle r^{2} \\left(r + y\\right)^{t} - r y y^{t} + r y z^{t} + r y \\left(r + y\\right)^{t} + r y^{t} z - r z z^{t} - r z \\left(r + y\\right)^{t} + y^{2} z^{t} - 2 y z z^{t} + z^{2} z^{t}$" ], "text/plain": [ - "x**2*(x + y)**t - x*y*y**t + x*y*z**t + x*y*(x + y)**t + x*y**t*z - x*z*z**t - x*z*(x + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" + "r**2*(r + y)**t - r*y*y**t + r*y*z**t + r*y*(r + y)**t + r*y**t*z - r*z*z**t - r*z*(r + y)**t + y**2*z**t - 2*y*z*z**t + z**2*z**t" ] }, "execution_count": 11, @@ -644,7 +538,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to u+x$" ], "text/plain": [ "" @@ -656,7 +550,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} z^{t} - x x^{t} y + x y z^{t} + x y \\left(x + y\\right)^{t} - 2 x z z^{t} + x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z z^{t} - y z \\left(x + y\\right)^{t} + z^{2} z^{t}$$" + "4 $$u^{2} \\left(u + x\\right)^{t} - u x x^{t} + u x z^{t} + u x \\left(u + x\\right)^{t} + u x^{t} z - u z z^{t} - u z \\left(u + x\\right)^{t} + x^{2} z^{t} - 2 x z z^{t} + z^{2} z^{t}$$" ], "text/plain": [ "" @@ -668,7 +562,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to v+x$" ], "text/plain": [ "" @@ -680,7 +574,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} y^{t} - x x^{t} z - 2 x y y^{t} + x y^{t} z + x z \\left(x + z\\right)^{t} + x^{t} y z + y^{2} y^{t} - y y^{t} z - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$v^{2} \\left(v + x\\right)^{t} - v x x^{t} + v x y^{t} + v x \\left(v + x\\right)^{t} + v x^{t} y - v y y^{t} - v y \\left(v + x\\right)^{t} + x^{2} y^{t} - 2 x y y^{t} + y^{2} y^{t}$$" ], "text/plain": [ "" @@ -692,7 +586,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $z\\to w+y$" ], "text/plain": [ "" @@ -704,7 +598,7 @@ { "data": { "text/latex": [ - "4 $$x^{2} x^{t} - 2 x x^{t} y - x x^{t} z + x y^{t} z - x z \\left(y + z\\right)^{t} + x^{t} y^{2} + x^{t} y z - y y^{t} z + y z \\left(y + z\\right)^{t} + z^{2} \\left(y + z\\right)^{t}$$" + "4 $$w^{2} \\left(w + y\\right)^{t} - w x x^{t} + w x y^{t} - w x \\left(w + y\\right)^{t} + w x^{t} y - w y y^{t} + w y \\left(w + y\\right)^{t} + x^{2} x^{t} - 2 x x^{t} y + x^{t} y^{2}$$" ], "text/plain": [ "" @@ -716,7 +610,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to a_{1}+x$" ], "text/plain": [ "" @@ -728,7 +622,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to b_{1}+x$" ], "text/plain": [ "" @@ -740,7 +634,7 @@ { "data": { "text/latex": [ - "4 $$x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z \\left(x + y\\right)^{t} - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$a_{1}^{2} \\left(a_{1} + x\\right)^{t} + a_{1} b_{1} x^{t} - a_{1} b_{1} \\left(a_{1} + x\\right)^{t} - a_{1} b_{1} \\left(b_{1} + x\\right)^{t} + b_{1}^{2} \\left(b_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -752,7 +646,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $b_{1}\\to a_{1}+c_{1}$" ], "text/plain": [ "" @@ -764,7 +658,7 @@ { "data": { "text/latex": [ - "3 $$x^{t} y^{2} + x^{t} y z - y z \\left(x + y\\right)^{t} + y z \\left(x + y + z\\right)^{t} + z^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$a_{1}^{2} x^{t} + a_{1} c_{1} x^{t} - a_{1} c_{1} \\left(a_{1} + x\\right)^{t} + a_{1} c_{1} \\left(a_{1} + c_{1} + x\\right)^{t} + c_{1}^{2} \\left(a_{1} + c_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -776,7 +670,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to x+z$" + "Substitute $z\\to d_{1}+x$" ], "text/plain": [ "" @@ -788,7 +682,7 @@ { "data": { "text/latex": [ - "Substitute $y\\to x+y$" + "Substitute $y\\to e_{1}+x$" ], "text/plain": [ "" @@ -800,7 +694,7 @@ { "data": { "text/latex": [ - "4 $$x^{t} y z + y^{2} \\left(x + y\\right)^{t} - y z \\left(x + y\\right)^{t} - y z \\left(x + z\\right)^{t} + z^{2} \\left(x + z\\right)^{t}$$" + "4 $$d_{1}^{2} \\left(d_{1} + x\\right)^{t} + d_{1} e_{1} x^{t} - d_{1} e_{1} \\left(d_{1} + x\\right)^{t} - d_{1} e_{1} \\left(e_{1} + x\\right)^{t} + e_{1}^{2} \\left(e_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -812,7 +706,7 @@ { "data": { "text/latex": [ - "Substitute $z\\to y+z$" + "Substitute $e_{1}\\to d_{1}+f_{1}$" ], "text/plain": [ "" @@ -824,7 +718,7 @@ { "data": { "text/latex": [ - "3 $$x^{t} y^{2} + x^{t} y z - y z \\left(x + y\\right)^{t} + y z \\left(x + y + z\\right)^{t} + z^{2} \\left(x + y + z\\right)^{t}$$" + "3 $$d_{1}^{2} x^{t} + d_{1} f_{1} x^{t} - d_{1} f_{1} \\left(d_{1} + x\\right)^{t} + d_{1} f_{1} \\left(d_{1} + f_{1} + x\\right)^{t} + f_{1}^{2} \\left(d_{1} + f_{1} + x\\right)^{t}$$" ], "text/plain": [ "" @@ -953,7 +847,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to 11a/8$" + "Substitute $a\\to 11g_{1}/8$" ], "text/plain": [ "" @@ -965,7 +859,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to 4b/5$" + "Substitute $b\\to 4h_{1}/5$" ], "text/plain": [ "" @@ -977,7 +871,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to 4c/5$" + "Substitute $c\\to 4i_{1}/5$" ], "text/plain": [ "" @@ -989,7 +883,7 @@ { "data": { "text/latex": [ - "Substitute $d\\to 4d/5$" + "Substitute $d\\to 4j_{1}/5$" ], "text/plain": [ "" @@ -1001,7 +895,7 @@ { "data": { "text/latex": [ - "numerator: $3025a^2-1760ab-1760ac-1760ad+1024b^2+1024c^2+1024d^2$" + "numerator: $3025g_{1}^2-1760g_{1}h_{1}-1760g_{1}i_{1}-1760g_{1}j_{1}+1024h_{1}^2+1024i_{1}^2+1024j_{1}^2$" ], "text/plain": [ "" @@ -1049,7 +943,7 @@ { "data": { "text/latex": [ - "$$1760ab \\le 880a^2+880b^2$$" + "$$1760g_{1}h_{1} \\le 880g_{1}^2+880h_{1}^2$$" ], "text/plain": [ "" @@ -1061,7 +955,7 @@ { "data": { "text/latex": [ - "$$1760ac \\le 880a^2+880c^2$$" + "$$1760g_{1}i_{1} \\le 880g_{1}^2+880i_{1}^2$$" ], "text/plain": [ "" @@ -1073,7 +967,7 @@ { "data": { "text/latex": [ - "$$1760ad \\le 880a^2+880d^2$$" + "$$1760g_{1}j_{1} \\le 880g_{1}^2+880j_{1}^2$$" ], "text/plain": [ "" @@ -1085,7 +979,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 385a^2+144b^2+144c^2+144d^2 $$" + "$$ 0 \\le 385g_{1}^2+144h_{1}^2+144i_{1}^2+144j_{1}^2 $$" ], "text/plain": [ "" @@ -1148,76 +1042,29 @@ "outputs": [ { "data": { - "text/latex": [ - "$\\displaystyle - \\frac{2 \\sqrt{2} \\left(a - b\\right)}{c} + \\frac{\\left(a - b\\right)^{2}}{c^{2}} - \\frac{2 \\sqrt{2} \\left(- a + c\\right)}{b} + \\frac{\\left(- a + c\\right)^{2}}{b^{2}} - \\frac{2 \\sqrt{2} \\left(b - c\\right)}{a} + \\frac{\\left(b - c\\right)^{2}}{a^{2}}$" - ], "text/plain": [ - "-2*sqrt(2)*(a - b)/c + (a - b)**2/c**2 - 2*sqrt(2)*(-a + c)/b + (-a + c)**2/b**2 - 2*sqrt(2)*(b - c)/a + (b - c)**2/a**2" + "\"formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\\ndisplay(formula)\\nfrom scipy.optimize import fmin\\nimport numpy as np\\ndef f(x):\\n num,den=fraction(cancel(newformula))\\n fs=sorted(newformula.free_symbols,key=str)\\n return float(num.subs(list(zip(fs,x))))\\nnewformula=(makesubs(formula,'[b,oo],[c,oo]'))\\nprint(f([2,1,1]))\\nfmin(f,[2,1,1])\\nprint(fmin(f,np.array([2,1,1])))\\ndisplay(simplify(newformula))\"" ] }, + "execution_count": 20, "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $a\\to a+b$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $b\\to b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Optimization terminated successfully.\n", - " Current function value: 0.000000\n", - " Iterations: 51\n", - " Function evaluations: 97\n", - "[1.17092486 1.170961 1.17093843]\n" - ] - }, - { - "data": { - "text/latex": [ - "$\\displaystyle \\frac{a^{4} b^{2} + 2 a^{4} b c + 2 a^{4} c^{2} + 2 a^{3} b^{3} - 2 \\sqrt{2} a^{3} b^{2} c + 6 a^{3} b^{2} c - 2 \\sqrt{2} a^{3} b c^{2} + 10 a^{3} b c^{2} + 4 a^{3} c^{3} + a^{2} b^{4} - 4 \\sqrt{2} a^{2} b^{3} c + 4 a^{2} b^{3} c - 6 \\sqrt{2} a^{2} b^{2} c^{2} + 12 a^{2} b^{2} c^{2} - 2 \\sqrt{2} a^{2} b c^{3} + 10 a^{2} b c^{3} + 2 a^{2} c^{4} - 2 \\sqrt{2} a b^{4} c - 4 \\sqrt{2} a b^{3} c^{2} + 4 a b^{3} c^{2} - 2 \\sqrt{2} a b^{2} c^{3} + 6 a b^{2} c^{3} + 2 a b c^{4} + 2 b^{4} c^{2} + 4 b^{3} c^{3} + 2 b^{2} c^{4}}{c^{2} \\left(a^{2} b^{2} + 2 a^{2} b c + a^{2} c^{2} + 2 a b^{3} + 6 a b^{2} c + 6 a b c^{2} + 2 a c^{3} + b^{4} + 4 b^{3} c + 6 b^{2} c^{2} + 4 b c^{3} + c^{4}\\right)}$" - ], - "text/plain": [ - "(a**4*b**2 + 2*a**4*b*c + 2*a**4*c**2 + 2*a**3*b**3 - 2*sqrt(2)*a**3*b**2*c + 6*a**3*b**2*c - 2*sqrt(2)*a**3*b*c**2 + 10*a**3*b*c**2 + 4*a**3*c**3 + a**2*b**4 - 4*sqrt(2)*a**2*b**3*c + 4*a**2*b**3*c - 6*sqrt(2)*a**2*b**2*c**2 + 12*a**2*b**2*c**2 - 2*sqrt(2)*a**2*b*c**3 + 10*a**2*b*c**3 + 2*a**2*c**4 - 2*sqrt(2)*a*b**4*c - 4*sqrt(2)*a*b**3*c**2 + 4*a*b**3*c**2 - 2*sqrt(2)*a*b**2*c**3 + 6*a*b**2*c**3 + 2*a*b*c**4 + 2*b**4*c**2 + 4*b**3*c**3 + 2*b**2*c**4)/(c**2*(a**2*b**2 + 2*a**2*b*c + a**2*c**2 + 2*a*b**3 + 6*a*b**2*c + 6*a*b*c**2 + 2*a*c**3 + b**4 + 4*b**3*c + 6*b**2*c**2 + 4*b*c**3 + c**4))" - ] - }, - "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ - "formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", + "\"\"\"formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", "display(formula)\n", "from scipy.optimize import fmin\n", "import numpy as np\n", "def f(x):\n", - " num,den=fraction(cancel(formula))\n", + " num,den=fraction(cancel(newformula))\n", " fs=sorted(newformula.free_symbols,key=str)\n", - " return num.subs(zip(fs,x))\n", + " return float(num.subs(list(zip(fs,x))))\n", "newformula=(makesubs(formula,'[b,oo],[c,oo]'))\n", + "print(f([2,1,1]))\n", + "fmin(f,[2,1,1])\n", "print(fmin(f,np.array([2,1,1])))\n", - "display(simplify(newformula))\n", + "display(simplify(newformula))\"\"\"\n", "#prove(newformula)\n", "#prove(makesubs(formula,'[b,oo],[a,oo]',variables='c,b,a'))" ] @@ -1332,7 +1179,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+k_{1}$" ], "text/plain": [ "" @@ -1344,7 +1191,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+l_{1}$" ], "text/plain": [ "" @@ -1394,25 +1241,50 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left( 2, \\ \\frac{31}{3}, \\ \\frac{7}{4}\\right)$" + ], + "text/plain": [ + "(2, 31/3, 7/4)" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "nsimplify((2.1002573656763053, 10.340431462974655, 1.7661001788212371),tolerance=0.3,rational=True)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1.414211498165453" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "(2.1002573656763053/1.7661001788212371)**2" ] }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -1430,7 +1302,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $a\\to c+r_{1}$" ], "text/plain": [ "" @@ -1442,7 +1314,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to b+c$" + "Substitute $c\\to b+s_{1}$" ], "text/plain": [ "" @@ -1454,7 +1326,7 @@ { "data": { "text/latex": [ - "numerator: $2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4a^2bc^3+4\\sqrt{2}a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4ab^2c^3+4\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $2b^4r_{1}^2+2b^4r_{1}s_{1}+2b^4s_{1}^2+4b^3r_{1}^3+2\\sqrt{2}b^3r_{1}^2s_{1}+10b^3r_{1}^2s_{1}+2\\sqrt{2}b^3r_{1}s_{1}^2+6b^3r_{1}s_{1}^2+4b^3s_{1}^3+2b^2r_{1}^4+2\\sqrt{2}b^2r_{1}^3s_{1}+10b^2r_{1}^3s_{1}+6\\sqrt{2}b^2r_{1}^2s_{1}^2+12b^2r_{1}^2s_{1}^2+4b^2r_{1}s_{1}^3+4\\sqrt{2}b^2r_{1}s_{1}^3+2b^2s_{1}^4+2br_{1}^4s_{1}+2\\sqrt{2}br_{1}^3s_{1}^2+6br_{1}^3s_{1}^2+4br_{1}^2s_{1}^3+4\\sqrt{2}br_{1}^2s_{1}^3+2\\sqrt{2}br_{1}s_{1}^4+r_{1}^4s_{1}^2+2r_{1}^3s_{1}^3+r_{1}^2s_{1}^4$" ], "text/plain": [ "" @@ -1466,7 +1338,7 @@ { "data": { "text/latex": [ - "denominator: $a^2b^4+2a^2b^3c+a^2b^2c^2+2ab^5+6ab^4c+6ab^3c^2+2ab^2c^3+b^6+4b^5c+6b^4c^2+4b^3c^3+b^2c^4$" + "denominator: $b^6+2b^5r_{1}+4b^5s_{1}+b^4r_{1}^2+6b^4r_{1}s_{1}+6b^4s_{1}^2+2b^3r_{1}^2s_{1}+6b^3r_{1}s_{1}^2+4b^3s_{1}^3+b^2r_{1}^2s_{1}^2+2b^2r_{1}s_{1}^3+b^2s_{1}^4$" ], "text/plain": [ "" @@ -1490,7 +1362,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4\\sqrt{2}a^2bc^3+4a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4\\sqrt{2}ab^2c^3+4ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4 $$" + "$$ 0 \\le r_{1}^4s_{1}^2+2br_{1}^4s_{1}+2b^2r_{1}^4+2r_{1}^3s_{1}^3+2\\sqrt{2}br_{1}^3s_{1}^2+6br_{1}^3s_{1}^2+2\\sqrt{2}b^2r_{1}^3s_{1}+10b^2r_{1}^3s_{1}+4b^3r_{1}^3+r_{1}^2s_{1}^4+4\\sqrt{2}br_{1}^2s_{1}^3+4br_{1}^2s_{1}^3+6\\sqrt{2}b^2r_{1}^2s_{1}^2+12b^2r_{1}^2s_{1}^2+2\\sqrt{2}b^3r_{1}^2s_{1}+10b^3r_{1}^2s_{1}+2b^4r_{1}^2+2\\sqrt{2}br_{1}s_{1}^4+4\\sqrt{2}b^2r_{1}s_{1}^3+4b^2r_{1}s_{1}^3+2\\sqrt{2}b^3r_{1}s_{1}^2+6b^3r_{1}s_{1}^2+2b^4r_{1}s_{1}+2b^2s_{1}^4+4b^3s_{1}^3+2b^4s_{1}^2 $$" ], "text/plain": [ "" @@ -1526,7 +1398,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "Substitute $a\\to b+t_{1}$" ], "text/plain": [ "" @@ -1538,7 +1410,7 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "Substitute $b\\to c+u_{1}$" ], "text/plain": [ "" @@ -1550,7 +1422,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to \\sqrt{2}a$" + "Substitute $t_{1}\\to \\sqrt{2}v_{1}$" ], "text/plain": [ "" @@ -1562,7 +1434,7 @@ { "data": { "text/latex": [ - "numerator: $16a^4b^2+32a^4bc+32a^4c^2+16\\sqrt{2}a^3b^3-32a^3b^2c+48\\sqrt{2}a^3b^2c-32a^3bc^2+80\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+8a^2b^4-32\\sqrt{2}a^2b^3c+32a^2b^3c-48\\sqrt{2}a^2b^2c^2+96a^2b^2c^2-16\\sqrt{2}a^2bc^3+80a^2bc^3+16a^2c^4-16ab^4c-32ab^3c^2+16\\sqrt{2}ab^3c^2-16ab^2c^3+24\\sqrt{2}ab^2c^3+8\\sqrt{2}abc^4+8b^4c^2+16b^3c^3+8b^2c^4$" + "numerator: $8c^4u_{1}^2+8\\sqrt{2}c^4u_{1}v_{1}+16c^4v_{1}^2+16c^3u_{1}^3-16c^3u_{1}^2v_{1}+24\\sqrt{2}c^3u_{1}^2v_{1}-16\\sqrt{2}c^3u_{1}v_{1}^2+80c^3u_{1}v_{1}^2+32\\sqrt{2}c^3v_{1}^3+8c^2u_{1}^4-32c^2u_{1}^3v_{1}+16\\sqrt{2}c^2u_{1}^3v_{1}-48\\sqrt{2}c^2u_{1}^2v_{1}^2+96c^2u_{1}^2v_{1}^2-32c^2u_{1}v_{1}^3+80\\sqrt{2}c^2u_{1}v_{1}^3+32c^2v_{1}^4-16cu_{1}^4v_{1}-32\\sqrt{2}cu_{1}^3v_{1}^2+32cu_{1}^3v_{1}^2-32cu_{1}^2v_{1}^3+48\\sqrt{2}cu_{1}^2v_{1}^3+32cu_{1}v_{1}^4+8u_{1}^4v_{1}^2+16\\sqrt{2}u_{1}^3v_{1}^3+16u_{1}^2v_{1}^4$" ], "text/plain": [ "" @@ -1574,7 +1446,7 @@ { "data": { "text/latex": [ - "denominator: $2a^2b^2c^2+4a^2bc^3+2a^2c^4+2\\sqrt{2}ab^3c^2+6\\sqrt{2}ab^2c^3+6\\sqrt{2}abc^4+2\\sqrt{2}ac^5+b^4c^2+4b^3c^3+6b^2c^4+4bc^5+c^6$" + "denominator: $c^6+4c^5u_{1}+2\\sqrt{2}c^5v_{1}+6c^4u_{1}^2+6\\sqrt{2}c^4u_{1}v_{1}+2c^4v_{1}^2+4c^3u_{1}^3+6\\sqrt{2}c^3u_{1}^2v_{1}+4c^3u_{1}v_{1}^2+c^2u_{1}^4+2\\sqrt{2}c^2u_{1}^3v_{1}+2c^2u_{1}^2v_{1}^2$" ], "text/plain": [ "" @@ -1610,7 +1482,7 @@ { "data": { "text/latex": [ - "$$32a^3b^2c \\le 16a^4b^2+16a^2b^2c^2$$" + "$$16cu_{1}^4v_{1} \\le 8u_{1}^4v_{1}^2+8c^2u_{1}^4$$" ], "text/plain": [ "" @@ -1622,7 +1494,7 @@ { "data": { "text/latex": [ - "$$32\\sqrt{2}a^2b^3c \\le 16\\sqrt{2}a^3b^3+16\\sqrt{2}ab^3c^2$$" + "$$32\\sqrt{2}cu_{1}^3v_{1}^2 \\le 16\\sqrt{2}u_{1}^3v_{1}^3+16\\sqrt{2}c^2u_{1}^3v_{1}$$" ], "text/plain": [ "" @@ -1634,7 +1506,7 @@ { "data": { "text/latex": [ - "$$48\\sqrt{2}a^2b^2c^2 \\le 24\\sqrt{2}a^3b^2c+24\\sqrt{2}ab^2c^3$$" + "$$32c^2u_{1}^3v_{1} \\le 16cu_{1}^3v_{1}^2+16c^3u_{1}^3$$" ], "text/plain": [ "" @@ -1646,7 +1518,7 @@ { "data": { "text/latex": [ - "$$16\\sqrt{2}a^2bc^3 \\le 8\\sqrt{2}a^3bc^2+8\\sqrt{2}abc^4$$" + "$$32cu_{1}^2v_{1}^3 \\le 16cu_{1}^3v_{1}^2+16cu_{1}v_{1}^4$$" ], "text/plain": [ "" @@ -1658,7 +1530,7 @@ { "data": { "text/latex": [ - "$$16ab^4c \\le 8a^2b^4+8b^4c^2$$" + "$$48\\sqrt{2}c^2u_{1}^2v_{1}^2 \\le 24\\sqrt{2}cu_{1}^2v_{1}^3+24\\sqrt{2}c^3u_{1}^2v_{1}$$" ], "text/plain": [ "" @@ -1670,7 +1542,7 @@ { "data": { "text/latex": [ - "$$32ab^3c^2 \\le 16a^2b^3c+16b^3c^3$$" + "$$16c^3u_{1}^2v_{1} \\le 8c^2u_{1}^2v_{1}^2+8c^4u_{1}^2$$" ], "text/plain": [ "" @@ -1682,7 +1554,7 @@ { "data": { "text/latex": [ - "$$32a^3bc^2 \\le 16a^4bc+16a^2bc^3$$" + "$$32c^2u_{1}v_{1}^3 \\le 16u_{1}^2v_{1}^4+16c^4v_{1}^2$$" ], "text/plain": [ "" @@ -1694,7 +1566,7 @@ { "data": { "text/latex": [ - "$$16ab^2c^3 \\le 8a^2b^2c^2+8b^2c^4$$" + "$$16\\sqrt{2}c^3u_{1}v_{1}^2 \\le 8\\sqrt{2}c^2u_{1}v_{1}^3+8\\sqrt{2}c^4u_{1}v_{1}$$" ], "text/plain": [ "" @@ -1706,7 +1578,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le 16a^4bc+32a^4c^2+24\\sqrt{2}a^3b^2c+72\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+16a^2b^3c+72a^2b^2c^2+64a^2bc^3+16a^2c^4 $$" + "$$ 0 \\le 24\\sqrt{2}cu_{1}^2v_{1}^3+88c^2u_{1}^2v_{1}^2+16cu_{1}v_{1}^4+72\\sqrt{2}c^2u_{1}v_{1}^3+80c^3u_{1}v_{1}^2+32c^2v_{1}^4+32\\sqrt{2}c^3v_{1}^3 $$" ], "text/plain": [ "" @@ -1736,7 +1608,7 @@ "-2*sqrt(2)*(a - b)/c + (a - b)**2/c**2 - 2*sqrt(2)*(-a + c)/b + (-a + c)**2/b**2 - 2*sqrt(2)*(b - c)/a + (b - c)**2/a**2" ] }, - "execution_count": 39, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -1748,15 +1620,122 @@ "prove(formula1)\n", "display(Latex('Case $a\\ge b\\ge c$'))\n", "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", - "prove(formula2*4,values='2**(1/2),1,1')\n", + "prove(formula2*4,values='1,sqrt(2),1')\n", "formula" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $a\\to b+w_{1}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $b\\to c+x_{1}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $a\\to\\sqrt{2}a$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "numerator: $2c^4w_{1}^2+2c^4w_{1}x_{1}+2c^4x_{1}^2+4c^3w_{1}^3-2\\sqrt{2}c^3w_{1}^2x_{1}+10c^3w_{1}^2x_{1}-2\\sqrt{2}c^3w_{1}x_{1}^2+6c^3w_{1}x_{1}^2+4c^3x_{1}^3+2c^2w_{1}^4-2\\sqrt{2}c^2w_{1}^3x_{1}+10c^2w_{1}^3x_{1}-6\\sqrt{2}c^2w_{1}^2x_{1}^2+12c^2w_{1}^2x_{1}^2-4\\sqrt{2}c^2w_{1}x_{1}^3+4c^2w_{1}x_{1}^3+2c^2x_{1}^4+2cw_{1}^4x_{1}-2\\sqrt{2}cw_{1}^3x_{1}^2+6cw_{1}^3x_{1}^2-4\\sqrt{2}cw_{1}^2x_{1}^3+4cw_{1}^2x_{1}^3-2\\sqrt{2}cw_{1}x_{1}^4+w_{1}^4x_{1}^2+2w_{1}^3x_{1}^3+w_{1}^2x_{1}^4$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 2" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Program couldn't find any proof." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 2\\sqrt{2}cw_{1}x_{1}^4+4\\sqrt{2}cw_{1}^2x_{1}^3+4\\sqrt{2}c^2w_{1}x_{1}^3+2\\sqrt{2}cw_{1}^3x_{1}^2+6\\sqrt{2}c^2w_{1}^2x_{1}^2+2\\sqrt{2}c^3w_{1}x_{1}^2+2\\sqrt{2}c^2w_{1}^3x_{1}+2\\sqrt{2}c^3w_{1}^2x_{1} \\le w_{1}^2x_{1}^4+2c^2x_{1}^4+2w_{1}^3x_{1}^3+4cw_{1}^2x_{1}^3+4c^2w_{1}x_{1}^3+4c^3x_{1}^3+w_{1}^4x_{1}^2+6cw_{1}^3x_{1}^2+12c^2w_{1}^2x_{1}^2+6c^3w_{1}x_{1}^2+2c^4x_{1}^2+2cw_{1}^4x_{1}+10c^2w_{1}^3x_{1}+10c^3w_{1}^2x_{1}+2c^4w_{1}x_{1}+2c^2w_{1}^4+4c^3w_{1}^3+2c^4w_{1}^2 $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", "formula=(makesubs(formula,'[b,oo],[c,oo]'))\n", @@ -1768,54 +1747,120 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(1, (x, y, sqrt(2)))" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "S('2**(1/2)*x*y').as_coeff_mul()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(1, (x, y, sqrt(2)))" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "S('sqrt(2)*x*y').as_coeff_mul()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[(1, 1, 1), (0, 0, 0)]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "Poly('sqrt(2)*x*y+8').monoms()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 58]" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "Poly('sqrt(2)*x*y+58').coeffs()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 34, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(x, y, sqrt(2), sqrt(3), sqrt(6))" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "Poly('sqrt(2)*x*y+sqrt(3)+sqrt(2)*sqrt(3)').gens" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "([0], [(0, 0)], [1, 7], [(2, 0), (0, 1)], (x, y))" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def _formula2list(formula):\n", " neg=pos=0\n", @@ -1831,134 +1876,6 @@ "_formula2list(S('x^2+7*y'))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "prove(S('sqrt(2)*x^2-sqrt(8)*x*y+sqrt(2)*y^2'))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "[Poly('1+2**(1/3)+4**(1/3)+x').monoms(),Poly('1+2**(1/3)+4**(1/3)+x').coeffs()]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "x=Symbol('x', positive=True)\n", - "Poly(x+sqrt(x))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "prove?" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly('x^2-1').abs()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly(Poly('x')/Poly('x+y'))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly('sqrt(2)+x+sqrt(x)+x**(1/4)+x**(1/3)+x**(2/3)',extension=1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly('x+sqrt(6)',S('x'),S('sqrt(2)'),S('sqrt(3)')).coeffs()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly('x+sqrt(x)',S('sqrt(x)')).coeffs()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "source(Poly)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "Poly({1:1,2:1},gens=S('sqrt(x)'))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "x=symbols('x', positive=True)\n", - "S('sqrt(x^2)-x')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "str(Poly({1:1,2:1,4:1},gens=S('sqrt(x)')))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "str(Poly('x^2+x+sqrt(x)'))" - ] - }, { "cell_type": "code", "execution_count": 36, @@ -1967,7 +1884,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+b$" + "numerator: $\\sqrt{2}x^2-2\\sqrt{2}xy+\\sqrt{2}y^2$" ], "text/plain": [ "" @@ -1979,7 +1896,4496 @@ { "data": { "text/latex": [ - "Substitute $b\\to b+c$" + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "status: 0" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "From weighted AM-GM inequality:" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2\\sqrt{2}xy \\le \\sqrt{2}x^2+\\sqrt{2}y^2$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ 0 \\le 0 $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "The sum of all inequalities gives us a proof of the inequality." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove(S('sqrt(2)*x^2-sqrt(8)*x*y+sqrt(2)*y^2'))" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[(1, 0), (0, 2), (0, 1), (0, 0)], [1, 1, 1, 1]]" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[Poly('1+2**(1/3)+4**(1/3)+x').monoms(),Poly('1+2**(1/3)+4**(1/3)+x').coeffs()]" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x + \\sqrt{x}, x, \\sqrt{x}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(x + (sqrt(x)), x, sqrt(x), domain='ZZ')" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x=Symbol('x', positive=True)\n", + "Poly(x+sqrt(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "prove?" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x^{2} + 1, x, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(x**2 + 1, x, domain='ZZ')" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x^2-1').abs()" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x\\frac{1}{x + y}, x, \\frac{1}{x + y}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(x*(1/(x + y)), x, 1/(x + y), domain='ZZ')" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly(Poly('x')/Poly('x+y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x + \\sqrt{x} + x^{\\frac{2}{3}} + \\sqrt[3]{x} + \\sqrt[4]{x} + \\sqrt{2}, x, \\sqrt{x}, \\sqrt[3]{x}, \\sqrt[4]{x}, domain=QQ \\right)}$" + ], + "text/plain": [ + "Poly(x + (sqrt(x)) + (x**(1/3))**2 + (x**(1/3)) + (x**(1/4)) + sqrt(2), x, sqrt(x), x**(1/3), x**(1/4), domain='QQ')" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('sqrt(2)+x+sqrt(x)+x**(1/4)+x**(1/3)+x**(2/3)',extension=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, sqrt(6)]" + ] + }, + "execution_count": 43, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x+sqrt(6)',S('x'),S('sqrt(2)'),S('sqrt(3)')).coeffs()" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, x]" + ] + }, + "execution_count": 44, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x+sqrt(x)',S('sqrt(x)')).coeffs()" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py:38: SymPyDeprecationWarning: \n", + "\n", + "source has been deprecated since SymPy 1.3. Use ?? in IPython/Jupyter\n", + "or inspect.getsource instead. See\n", + "https://github.com/sympy/sympy/issues/14905 for more info.\n", + "\n", + " _warn_deprecation(wrapped, 3)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "In file: /home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polytools.py\n", + "class Poly(Expr):\n", + " \"\"\"\n", + " Generic class for representing and operating on polynomial expressions.\n", + " Subclasses Expr class.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " Create a univariate polynomial:\n", + "\n", + " >>> Poly(x*(x**2 + x - 1)**2)\n", + " Poly(x**5 + 2*x**4 - x**3 - 2*x**2 + x, x, domain='ZZ')\n", + "\n", + " Create a univariate polynomial with specific domain:\n", + "\n", + " >>> from sympy import sqrt\n", + " >>> Poly(x**2 + 2*x + sqrt(3), domain='R')\n", + " Poly(1.0*x**2 + 2.0*x + 1.73205080756888, x, domain='RR')\n", + "\n", + " Create a multivariate polynomial:\n", + "\n", + " >>> Poly(y*x**2 + x*y + 1)\n", + " Poly(x**2*y + x*y + 1, x, y, domain='ZZ')\n", + "\n", + " Create a univariate polynomial, where y is a constant:\n", + "\n", + " >>> Poly(y*x**2 + x*y + 1,x)\n", + " Poly(y*x**2 + y*x + 1, x, domain='ZZ[y]')\n", + "\n", + " You can evaluate the above polynomial as a function of y:\n", + "\n", + " >>> Poly(y*x**2 + x*y + 1,x).eval(2)\n", + " 6*y + 1\n", + "\n", + " See Also\n", + " ========\n", + "\n", + " sympy.core.expr.Expr\n", + "\n", + " \"\"\"\n", + "\n", + " __slots__ = ['rep', 'gens']\n", + "\n", + " is_commutative = True\n", + " is_Poly = True\n", + " _op_priority = 10.001\n", + "\n", + " def __new__(cls, rep, *gens, **args):\n", + " \"\"\"Create a new polynomial instance out of something useful. \"\"\"\n", + " opt = options.build_options(gens, args)\n", + "\n", + " if 'order' in opt:\n", + " raise NotImplementedError(\"'order' keyword is not implemented yet\")\n", + "\n", + " if iterable(rep, exclude=str):\n", + " if isinstance(rep, dict):\n", + " return cls._from_dict(rep, opt)\n", + " else:\n", + " return cls._from_list(list(rep), opt)\n", + " else:\n", + " rep = sympify(rep)\n", + "\n", + " if rep.is_Poly:\n", + " return cls._from_poly(rep, opt)\n", + " else:\n", + " return cls._from_expr(rep, opt)\n", + "\n", + " @classmethod\n", + " def new(cls, rep, *gens):\n", + " \"\"\"Construct :class:`Poly` instance from raw representation. \"\"\"\n", + " if not isinstance(rep, DMP):\n", + " raise PolynomialError(\n", + " \"invalid polynomial representation: %s\" % rep)\n", + " elif rep.lev != len(gens) - 1:\n", + " raise PolynomialError(\"invalid arguments: %s, %s\" % (rep, gens))\n", + "\n", + " obj = Basic.__new__(cls)\n", + "\n", + " obj.rep = rep\n", + " obj.gens = gens\n", + "\n", + " return obj\n", + "\n", + " @classmethod\n", + " def from_dict(cls, rep, *gens, **args):\n", + " \"\"\"Construct a polynomial from a ``dict``. \"\"\"\n", + " opt = options.build_options(gens, args)\n", + " return cls._from_dict(rep, opt)\n", + "\n", + " @classmethod\n", + " def from_list(cls, rep, *gens, **args):\n", + " \"\"\"Construct a polynomial from a ``list``. \"\"\"\n", + " opt = options.build_options(gens, args)\n", + " return cls._from_list(rep, opt)\n", + "\n", + " @classmethod\n", + " def from_poly(cls, rep, *gens, **args):\n", + " \"\"\"Construct a polynomial from a polynomial. \"\"\"\n", + " opt = options.build_options(gens, args)\n", + " return cls._from_poly(rep, opt)\n", + "\n", + " @classmethod\n", + " def from_expr(cls, rep, *gens, **args):\n", + " \"\"\"Construct a polynomial from an expression. \"\"\"\n", + " opt = options.build_options(gens, args)\n", + " return cls._from_expr(rep, opt)\n", + "\n", + " @classmethod\n", + " def _from_dict(cls, rep, opt):\n", + " \"\"\"Construct a polynomial from a ``dict``. \"\"\"\n", + " gens = opt.gens\n", + "\n", + " if not gens:\n", + " raise GeneratorsNeeded(\n", + " \"can't initialize from 'dict' without generators\")\n", + "\n", + " level = len(gens) - 1\n", + " domain = opt.domain\n", + "\n", + " if domain is None:\n", + " domain, rep = construct_domain(rep, opt=opt)\n", + " else:\n", + " for monom, coeff in rep.items():\n", + " rep[monom] = domain.convert(coeff)\n", + "\n", + " return cls.new(DMP.from_dict(rep, level, domain), *gens)\n", + "\n", + " @classmethod\n", + " def _from_list(cls, rep, opt):\n", + " \"\"\"Construct a polynomial from a ``list``. \"\"\"\n", + " gens = opt.gens\n", + "\n", + " if not gens:\n", + " raise GeneratorsNeeded(\n", + " \"can't initialize from 'list' without generators\")\n", + " elif len(gens) != 1:\n", + " raise MultivariatePolynomialError(\n", + " \"'list' representation not supported\")\n", + "\n", + " level = len(gens) - 1\n", + " domain = opt.domain\n", + "\n", + " if domain is None:\n", + " domain, rep = construct_domain(rep, opt=opt)\n", + " else:\n", + " rep = list(map(domain.convert, rep))\n", + "\n", + " return cls.new(DMP.from_list(rep, level, domain), *gens)\n", + "\n", + " @classmethod\n", + " def _from_poly(cls, rep, opt):\n", + " \"\"\"Construct a polynomial from a polynomial. \"\"\"\n", + " if cls != rep.__class__:\n", + " rep = cls.new(rep.rep, *rep.gens)\n", + "\n", + " gens = opt.gens\n", + " field = opt.field\n", + " domain = opt.domain\n", + "\n", + " if gens and rep.gens != gens:\n", + " if set(rep.gens) != set(gens):\n", + " return cls._from_expr(rep.as_expr(), opt)\n", + " else:\n", + " rep = rep.reorder(*gens)\n", + "\n", + " if 'domain' in opt and domain:\n", + " rep = rep.set_domain(domain)\n", + " elif field is True:\n", + " rep = rep.to_field()\n", + "\n", + " return rep\n", + "\n", + " @classmethod\n", + " def _from_expr(cls, rep, opt):\n", + " \"\"\"Construct a polynomial from an expression. \"\"\"\n", + " rep, opt = _dict_from_expr(rep, opt)\n", + " return cls._from_dict(rep, opt)\n", + "\n", + " def _hashable_content(self):\n", + " \"\"\"Allow SymPy to hash Poly instances. \"\"\"\n", + " return (self.rep, self.gens)\n", + "\n", + " def __hash__(self):\n", + " return super(Poly, self).__hash__()\n", + "\n", + " @property\n", + " def free_symbols(self):\n", + " \"\"\"\n", + " Free symbols of a polynomial expression.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> Poly(x**2 + 1).free_symbols\n", + " {x}\n", + " >>> Poly(x**2 + y).free_symbols\n", + " {x, y}\n", + " >>> Poly(x**2 + y, x).free_symbols\n", + " {x, y}\n", + " >>> Poly(x**2 + y, x, z).free_symbols\n", + " {x, y}\n", + "\n", + " \"\"\"\n", + " symbols = set()\n", + " gens = self.gens\n", + " for i in range(len(gens)):\n", + " for monom in self.monoms():\n", + " if monom[i]:\n", + " symbols |= gens[i].free_symbols\n", + " break\n", + "\n", + " return symbols | self.free_symbols_in_domain\n", + "\n", + " @property\n", + " def free_symbols_in_domain(self):\n", + " \"\"\"\n", + " Free symbols of the domain of ``self``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 1).free_symbols_in_domain\n", + " set()\n", + " >>> Poly(x**2 + y).free_symbols_in_domain\n", + " set()\n", + " >>> Poly(x**2 + y, x).free_symbols_in_domain\n", + " {y}\n", + "\n", + " \"\"\"\n", + " domain, symbols = self.rep.dom, set()\n", + "\n", + " if domain.is_Composite:\n", + " for gen in domain.symbols:\n", + " symbols |= gen.free_symbols\n", + " elif domain.is_EX:\n", + " for coeff in self.coeffs():\n", + " symbols |= coeff.free_symbols\n", + "\n", + " return symbols\n", + "\n", + " @property\n", + " def args(self):\n", + " \"\"\"\n", + " Don't mess up with the core.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).args\n", + " (x**2 + 1,)\n", + "\n", + " \"\"\"\n", + " return (self.as_expr(),)\n", + "\n", + " @property\n", + " def gen(self):\n", + " \"\"\"\n", + " Return the principal generator.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).gen\n", + " x\n", + "\n", + " \"\"\"\n", + " return self.gens[0]\n", + "\n", + " @property\n", + " def domain(self):\n", + " \"\"\"Get the ground domain of ``self``. \"\"\"\n", + " return self.get_domain()\n", + "\n", + " @property\n", + " def zero(self):\n", + " \"\"\"Return zero polynomial with ``self``'s properties. \"\"\"\n", + " return self.new(self.rep.zero(self.rep.lev, self.rep.dom), *self.gens)\n", + "\n", + " @property\n", + " def one(self):\n", + " \"\"\"Return one polynomial with ``self``'s properties. \"\"\"\n", + " return self.new(self.rep.one(self.rep.lev, self.rep.dom), *self.gens)\n", + "\n", + " @property\n", + " def unit(self):\n", + " \"\"\"Return unit polynomial with ``self``'s properties. \"\"\"\n", + " return self.new(self.rep.unit(self.rep.lev, self.rep.dom), *self.gens)\n", + "\n", + " def unify(f, g):\n", + " \"\"\"\n", + " Make ``f`` and ``g`` belong to the same domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f, g = Poly(x/2 + 1), Poly(2*x + 1)\n", + "\n", + " >>> f\n", + " Poly(1/2*x + 1, x, domain='QQ')\n", + " >>> g\n", + " Poly(2*x + 1, x, domain='ZZ')\n", + "\n", + " >>> F, G = f.unify(g)\n", + "\n", + " >>> F\n", + " Poly(1/2*x + 1, x, domain='QQ')\n", + " >>> G\n", + " Poly(2*x + 1, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + " return per(F), per(G)\n", + "\n", + " def _unify(f, g):\n", + " g = sympify(g)\n", + "\n", + " if not g.is_Poly:\n", + " try:\n", + " return f.rep.dom, f.per, f.rep, f.rep.per(f.rep.dom.from_sympy(g))\n", + " except CoercionFailed:\n", + " raise UnificationFailed(\"can't unify %s with %s\" % (f, g))\n", + "\n", + " if isinstance(f.rep, DMP) and isinstance(g.rep, DMP):\n", + " gens = _unify_gens(f.gens, g.gens)\n", + "\n", + " dom, lev = f.rep.dom.unify(g.rep.dom, gens), len(gens) - 1\n", + "\n", + " if f.gens != gens:\n", + " f_monoms, f_coeffs = _dict_reorder(\n", + " f.rep.to_dict(), f.gens, gens)\n", + "\n", + " if f.rep.dom != dom:\n", + " f_coeffs = [dom.convert(c, f.rep.dom) for c in f_coeffs]\n", + "\n", + " F = DMP(dict(list(zip(f_monoms, f_coeffs))), dom, lev)\n", + " else:\n", + " F = f.rep.convert(dom)\n", + "\n", + " if g.gens != gens:\n", + " g_monoms, g_coeffs = _dict_reorder(\n", + " g.rep.to_dict(), g.gens, gens)\n", + "\n", + " if g.rep.dom != dom:\n", + " g_coeffs = [dom.convert(c, g.rep.dom) for c in g_coeffs]\n", + "\n", + " G = DMP(dict(list(zip(g_monoms, g_coeffs))), dom, lev)\n", + " else:\n", + " G = g.rep.convert(dom)\n", + " else:\n", + " raise UnificationFailed(\"can't unify %s with %s\" % (f, g))\n", + "\n", + " cls = f.__class__\n", + "\n", + " def per(rep, dom=dom, gens=gens, remove=None):\n", + " if remove is not None:\n", + " gens = gens[:remove] + gens[remove + 1:]\n", + "\n", + " if not gens:\n", + " return dom.to_sympy(rep)\n", + "\n", + " return cls.new(rep, *gens)\n", + "\n", + " return dom, per, F, G\n", + "\n", + " def per(f, rep, gens=None, remove=None):\n", + " \"\"\"\n", + " Create a Poly out of the given representation.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, ZZ\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> from sympy.polys.polyclasses import DMP\n", + "\n", + " >>> a = Poly(x**2 + 1)\n", + "\n", + " >>> a.per(DMP([ZZ(1), ZZ(1)], ZZ), gens=[y])\n", + " Poly(y + 1, y, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if gens is None:\n", + " gens = f.gens\n", + "\n", + " if remove is not None:\n", + " gens = gens[:remove] + gens[remove + 1:]\n", + "\n", + " if not gens:\n", + " return f.rep.dom.to_sympy(rep)\n", + "\n", + " return f.__class__.new(rep, *gens)\n", + "\n", + " def set_domain(f, domain):\n", + " \"\"\"Set the ground domain of ``f``. \"\"\"\n", + " opt = options.build_options(f.gens, {'domain': domain})\n", + " return f.per(f.rep.convert(opt.domain))\n", + "\n", + " def get_domain(f):\n", + " \"\"\"Get the ground domain of ``f``. \"\"\"\n", + " return f.rep.dom\n", + "\n", + " def set_modulus(f, modulus):\n", + " \"\"\"\n", + " Set the modulus of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(5*x**2 + 2*x - 1, x).set_modulus(2)\n", + " Poly(x**2 + 1, x, modulus=2)\n", + "\n", + " \"\"\"\n", + " modulus = options.Modulus.preprocess(modulus)\n", + " return f.set_domain(FF(modulus))\n", + "\n", + " def get_modulus(f):\n", + " \"\"\"\n", + " Get the modulus of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, modulus=2).get_modulus()\n", + " 2\n", + "\n", + " \"\"\"\n", + " domain = f.get_domain()\n", + "\n", + " if domain.is_FiniteField:\n", + " return Integer(domain.characteristic())\n", + " else:\n", + " raise PolynomialError(\"not a polynomial over a Galois field\")\n", + "\n", + " def _eval_subs(f, old, new):\n", + " \"\"\"Internal implementation of :func:`subs`. \"\"\"\n", + " if old in f.gens:\n", + " if new.is_number:\n", + " return f.eval(old, new)\n", + " else:\n", + " try:\n", + " return f.replace(old, new)\n", + " except PolynomialError:\n", + " pass\n", + "\n", + " return f.as_expr().subs(old, new)\n", + "\n", + " def exclude(f):\n", + " \"\"\"\n", + " Remove unnecessary generators from ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import a, b, c, d, x\n", + "\n", + " >>> Poly(a + x, a, b, c, d, x).exclude()\n", + " Poly(a + x, a, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " J, new = f.rep.exclude()\n", + " gens = []\n", + "\n", + " for j in range(len(f.gens)):\n", + " if j not in J:\n", + " gens.append(f.gens[j])\n", + "\n", + " return f.per(new, gens=gens)\n", + "\n", + " def replace(f, x, y=None, *_ignore):\n", + " # XXX this does not match Basic's signature\n", + " \"\"\"\n", + " Replace ``x`` with ``y`` in generators list.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 1, x).replace(x, y)\n", + " Poly(y**2 + 1, y, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if y is None:\n", + " if f.is_univariate:\n", + " x, y = f.gen, x\n", + " else:\n", + " raise PolynomialError(\n", + " \"syntax supported only in univariate case\")\n", + "\n", + " if x == y or x not in f.gens:\n", + " return f\n", + "\n", + " if x in f.gens and y not in f.gens:\n", + " dom = f.get_domain()\n", + "\n", + " if not dom.is_Composite or y not in dom.symbols:\n", + " gens = list(f.gens)\n", + " gens[gens.index(x)] = y\n", + " return f.per(f.rep, gens=gens)\n", + "\n", + " raise PolynomialError(\"can't replace %s with %s in %s\" % (x, y, f))\n", + "\n", + " def reorder(f, *gens, **args):\n", + " \"\"\"\n", + " Efficiently apply new order of generators.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + x*y**2, x, y).reorder(y, x)\n", + " Poly(y**2*x + x**2, y, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " opt = options.Options((), args)\n", + "\n", + " if not gens:\n", + " gens = _sort_gens(f.gens, opt=opt)\n", + " elif set(f.gens) != set(gens):\n", + " raise PolynomialError(\n", + " \"generators list can differ only up to order of elements\")\n", + "\n", + " rep = dict(list(zip(*_dict_reorder(f.rep.to_dict(), f.gens, gens))))\n", + "\n", + " return f.per(DMP(rep, f.rep.dom, len(gens) - 1), gens=gens)\n", + "\n", + " def ltrim(f, gen):\n", + " \"\"\"\n", + " Remove dummy generators from ``f`` that are to the left of\n", + " specified ``gen`` in the generators as ordered. When ``gen``\n", + " is an integer, it refers to the generator located at that\n", + " position within the tuple of generators of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> Poly(y**2 + y*z**2, x, y, z).ltrim(y)\n", + " Poly(y**2 + y*z**2, y, z, domain='ZZ')\n", + " >>> Poly(z, x, y, z).ltrim(-1)\n", + " Poly(z, z, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " rep = f.as_dict(native=True)\n", + " j = f._gen_to_level(gen)\n", + "\n", + " terms = {}\n", + "\n", + " for monom, coeff in rep.items():\n", + "\n", + " if any(i for i in monom[:j]):\n", + " # some generator is used in the portion to be trimmed\n", + " raise PolynomialError(\"can't left trim %s\" % f)\n", + "\n", + " terms[monom[j:]] = coeff\n", + "\n", + " gens = f.gens[j:]\n", + "\n", + " return f.new(DMP.from_dict(terms, len(gens) - 1, f.rep.dom), *gens)\n", + "\n", + " def has_only_gens(f, *gens):\n", + " \"\"\"\n", + " Return ``True`` if ``Poly(f, *gens)`` retains ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> Poly(x*y + 1, x, y, z).has_only_gens(x, y)\n", + " True\n", + " >>> Poly(x*y + z, x, y, z).has_only_gens(x, y)\n", + " False\n", + "\n", + " \"\"\"\n", + " indices = set()\n", + "\n", + " for gen in gens:\n", + " try:\n", + " index = f.gens.index(gen)\n", + " except ValueError:\n", + " raise GeneratorsError(\n", + " \"%s doesn't have %s as generator\" % (f, gen))\n", + " else:\n", + " indices.add(index)\n", + "\n", + " for monom in f.monoms():\n", + " for i, elt in enumerate(monom):\n", + " if i not in indices and elt:\n", + " return False\n", + "\n", + " return True\n", + "\n", + " def to_ring(f):\n", + " \"\"\"\n", + " Make the ground domain a ring.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, QQ\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, domain=QQ).to_ring()\n", + " Poly(x**2 + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'to_ring'):\n", + " result = f.rep.to_ring()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'to_ring')\n", + "\n", + " return f.per(result)\n", + "\n", + " def to_field(f):\n", + " \"\"\"\n", + " Make the ground domain a field.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, ZZ\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x, domain=ZZ).to_field()\n", + " Poly(x**2 + 1, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'to_field'):\n", + " result = f.rep.to_field()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'to_field')\n", + "\n", + " return f.per(result)\n", + "\n", + " def to_exact(f):\n", + " \"\"\"\n", + " Make the ground domain exact.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, RR\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1.0, x, domain=RR).to_exact()\n", + " Poly(x**2 + 1, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'to_exact'):\n", + " result = f.rep.to_exact()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'to_exact')\n", + "\n", + " return f.per(result)\n", + "\n", + " def retract(f, field=None):\n", + " \"\"\"\n", + " Recalculate the ground domain of a polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = Poly(x**2 + 1, x, domain='QQ[y]')\n", + " >>> f\n", + " Poly(x**2 + 1, x, domain='QQ[y]')\n", + "\n", + " >>> f.retract()\n", + " Poly(x**2 + 1, x, domain='ZZ')\n", + " >>> f.retract(field=True)\n", + " Poly(x**2 + 1, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " dom, rep = construct_domain(f.as_dict(zero=True),\n", + " field=field, composite=f.domain.is_Composite or None)\n", + " return f.from_dict(rep, f.gens, domain=dom)\n", + "\n", + " def slice(f, x, m, n=None):\n", + " \"\"\"Take a continuous subsequence of terms of ``f``. \"\"\"\n", + " if n is None:\n", + " j, m, n = 0, x, m\n", + " else:\n", + " j = f._gen_to_level(x)\n", + "\n", + " m, n = int(m), int(n)\n", + "\n", + " if hasattr(f.rep, 'slice'):\n", + " result = f.rep.slice(m, n, j)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'slice')\n", + "\n", + " return f.per(result)\n", + "\n", + " def coeffs(f, order=None):\n", + " \"\"\"\n", + " Returns all non-zero coefficients from ``f`` in lex order.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x + 3, x).coeffs()\n", + " [1, 2, 3]\n", + "\n", + " See Also\n", + " ========\n", + " all_coeffs\n", + " coeff_monomial\n", + " nth\n", + "\n", + " \"\"\"\n", + " return [f.rep.dom.to_sympy(c) for c in f.rep.coeffs(order=order)]\n", + "\n", + " def monoms(f, order=None):\n", + " \"\"\"\n", + " Returns all non-zero monomials from ``f`` in lex order.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 2*x*y**2 + x*y + 3*y, x, y).monoms()\n", + " [(2, 0), (1, 2), (1, 1), (0, 1)]\n", + "\n", + " See Also\n", + " ========\n", + " all_monoms\n", + "\n", + " \"\"\"\n", + " return f.rep.monoms(order=order)\n", + "\n", + " def terms(f, order=None):\n", + " \"\"\"\n", + " Returns all non-zero terms from ``f`` in lex order.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 2*x*y**2 + x*y + 3*y, x, y).terms()\n", + " [((2, 0), 1), ((1, 2), 2), ((1, 1), 1), ((0, 1), 3)]\n", + "\n", + " See Also\n", + " ========\n", + " all_terms\n", + "\n", + " \"\"\"\n", + " return [(m, f.rep.dom.to_sympy(c)) for m, c in f.rep.terms(order=order)]\n", + "\n", + " def all_coeffs(f):\n", + " \"\"\"\n", + " Returns all coefficients from a univariate polynomial ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x - 1, x).all_coeffs()\n", + " [1, 0, 2, -1]\n", + "\n", + " \"\"\"\n", + " return [f.rep.dom.to_sympy(c) for c in f.rep.all_coeffs()]\n", + "\n", + " def all_monoms(f):\n", + " \"\"\"\n", + " Returns all monomials from a univariate polynomial ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x - 1, x).all_monoms()\n", + " [(3,), (2,), (1,), (0,)]\n", + "\n", + " See Also\n", + " ========\n", + " all_terms\n", + "\n", + " \"\"\"\n", + " return f.rep.all_monoms()\n", + "\n", + " def all_terms(f):\n", + " \"\"\"\n", + " Returns all terms from a univariate polynomial ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x - 1, x).all_terms()\n", + " [((3,), 1), ((2,), 0), ((1,), 2), ((0,), -1)]\n", + "\n", + " \"\"\"\n", + " return [(m, f.rep.dom.to_sympy(c)) for m, c in f.rep.all_terms()]\n", + "\n", + " def termwise(f, func, *gens, **args):\n", + " \"\"\"\n", + " Apply a function to all terms of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> def func(k, coeff):\n", + " ... k = k[0]\n", + " ... return coeff//10**(2-k)\n", + "\n", + " >>> Poly(x**2 + 20*x + 400).termwise(func)\n", + " Poly(x**2 + 2*x + 4, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " terms = {}\n", + "\n", + " for monom, coeff in f.terms():\n", + " result = func(monom, coeff)\n", + "\n", + " if isinstance(result, tuple):\n", + " monom, coeff = result\n", + " else:\n", + " coeff = result\n", + "\n", + " if coeff:\n", + " if monom not in terms:\n", + " terms[monom] = coeff\n", + " else:\n", + " raise PolynomialError(\n", + " \"%s monomial was generated twice\" % monom)\n", + "\n", + " return f.from_dict(terms, *(gens or f.gens), **args)\n", + "\n", + " def length(f):\n", + " \"\"\"\n", + " Returns the number of non-zero terms in ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 2*x - 1).length()\n", + " 3\n", + "\n", + " \"\"\"\n", + " return len(f.as_dict())\n", + "\n", + " def as_dict(f, native=False, zero=False):\n", + " \"\"\"\n", + " Switch to a ``dict`` representation.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 2*x*y**2 - y, x, y).as_dict()\n", + " {(0, 1): -1, (1, 2): 2, (2, 0): 1}\n", + "\n", + " \"\"\"\n", + " if native:\n", + " return f.rep.to_dict(zero=zero)\n", + " else:\n", + " return f.rep.to_sympy_dict(zero=zero)\n", + "\n", + " def as_list(f, native=False):\n", + " \"\"\"Switch to a ``list`` representation. \"\"\"\n", + " if native:\n", + " return f.rep.to_list()\n", + " else:\n", + " return f.rep.to_sympy_list()\n", + "\n", + " def as_expr(f, *gens):\n", + " \"\"\"\n", + " Convert a Poly instance to an Expr instance.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = Poly(x**2 + 2*x*y**2 - y, x, y)\n", + "\n", + " >>> f.as_expr()\n", + " x**2 + 2*x*y**2 - y\n", + " >>> f.as_expr({x: 5})\n", + " 10*y**2 - y + 25\n", + " >>> f.as_expr(5, 6)\n", + " 379\n", + "\n", + " \"\"\"\n", + " if not gens:\n", + " gens = f.gens\n", + " elif len(gens) == 1 and isinstance(gens[0], dict):\n", + " mapping = gens[0]\n", + " gens = list(f.gens)\n", + "\n", + " for gen, value in mapping.items():\n", + " try:\n", + " index = gens.index(gen)\n", + " except ValueError:\n", + " raise GeneratorsError(\n", + " \"%s doesn't have %s as generator\" % (f, gen))\n", + " else:\n", + " gens[index] = value\n", + "\n", + " return basic_from_dict(f.rep.to_sympy_dict(), *gens)\n", + "\n", + " def lift(f):\n", + " \"\"\"\n", + " Convert algebraic coefficients to rationals.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, I\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + I*x + 1, x, extension=I).lift()\n", + " Poly(x**4 + 3*x**2 + 1, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'lift'):\n", + " result = f.rep.lift()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'lift')\n", + "\n", + " return f.per(result)\n", + "\n", + " def deflate(f):\n", + " \"\"\"\n", + " Reduce degree of ``f`` by mapping ``x_i**m`` to ``y_i``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**6*y**2 + x**3 + 1, x, y).deflate()\n", + " ((3, 2), Poly(x**2*y + x + 1, x, y, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'deflate'):\n", + " J, result = f.rep.deflate()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'deflate')\n", + "\n", + " return J, f.per(result)\n", + "\n", + " def inject(f, front=False):\n", + " \"\"\"\n", + " Inject ground domain generators into ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = Poly(x**2*y + x*y**3 + x*y + 1, x)\n", + "\n", + " >>> f.inject()\n", + " Poly(x**2*y + x*y**3 + x*y + 1, x, y, domain='ZZ')\n", + " >>> f.inject(front=True)\n", + " Poly(y**3*x + y*x**2 + y*x + 1, y, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " dom = f.rep.dom\n", + "\n", + " if dom.is_Numerical:\n", + " return f\n", + " elif not dom.is_Poly:\n", + " raise DomainError(\"can't inject generators over %s\" % dom)\n", + "\n", + " if hasattr(f.rep, 'inject'):\n", + " result = f.rep.inject(front=front)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'inject')\n", + "\n", + " if front:\n", + " gens = dom.symbols + f.gens\n", + " else:\n", + " gens = f.gens + dom.symbols\n", + "\n", + " return f.new(result, *gens)\n", + "\n", + " def eject(f, *gens):\n", + " \"\"\"\n", + " Eject selected generators into the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = Poly(x**2*y + x*y**3 + x*y + 1, x, y)\n", + "\n", + " >>> f.eject(x)\n", + " Poly(x*y**3 + (x**2 + x)*y + 1, y, domain='ZZ[x]')\n", + " >>> f.eject(y)\n", + " Poly(y*x**2 + (y**3 + y)*x + 1, x, domain='ZZ[y]')\n", + "\n", + " \"\"\"\n", + " dom = f.rep.dom\n", + "\n", + " if not dom.is_Numerical:\n", + " raise DomainError(\"can't eject generators over %s\" % dom)\n", + "\n", + " k = len(gens)\n", + "\n", + " if f.gens[:k] == gens:\n", + " _gens, front = f.gens[k:], True\n", + " elif f.gens[-k:] == gens:\n", + " _gens, front = f.gens[:-k], False\n", + " else:\n", + " raise NotImplementedError(\n", + " \"can only eject front or back generators\")\n", + "\n", + " dom = dom.inject(*gens)\n", + "\n", + " if hasattr(f.rep, 'eject'):\n", + " result = f.rep.eject(dom, front=front)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'eject')\n", + "\n", + " return f.new(result, *_gens)\n", + "\n", + " def terms_gcd(f):\n", + " \"\"\"\n", + " Remove GCD of terms from the polynomial ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**6*y**2 + x**3*y, x, y).terms_gcd()\n", + " ((3, 1), Poly(x**3*y + 1, x, y, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'terms_gcd'):\n", + " J, result = f.rep.terms_gcd()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'terms_gcd')\n", + "\n", + " return J, f.per(result)\n", + "\n", + " def add_ground(f, coeff):\n", + " \"\"\"\n", + " Add an element of the ground domain to ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x + 1).add_ground(2)\n", + " Poly(x + 3, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'add_ground'):\n", + " result = f.rep.add_ground(coeff)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'add_ground')\n", + "\n", + " return f.per(result)\n", + "\n", + " def sub_ground(f, coeff):\n", + " \"\"\"\n", + " Subtract an element of the ground domain from ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x + 1).sub_ground(2)\n", + " Poly(x - 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sub_ground'):\n", + " result = f.rep.sub_ground(coeff)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sub_ground')\n", + "\n", + " return f.per(result)\n", + "\n", + " def mul_ground(f, coeff):\n", + " \"\"\"\n", + " Multiply ``f`` by a an element of the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x + 1).mul_ground(2)\n", + " Poly(2*x + 2, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'mul_ground'):\n", + " result = f.rep.mul_ground(coeff)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'mul_ground')\n", + "\n", + " return f.per(result)\n", + "\n", + " def quo_ground(f, coeff):\n", + " \"\"\"\n", + " Quotient of ``f`` by a an element of the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x + 4).quo_ground(2)\n", + " Poly(x + 2, x, domain='ZZ')\n", + "\n", + " >>> Poly(2*x + 3).quo_ground(2)\n", + " Poly(x + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'quo_ground'):\n", + " result = f.rep.quo_ground(coeff)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'quo_ground')\n", + "\n", + " return f.per(result)\n", + "\n", + " def exquo_ground(f, coeff):\n", + " \"\"\"\n", + " Exact quotient of ``f`` by a an element of the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x + 4).exquo_ground(2)\n", + " Poly(x + 2, x, domain='ZZ')\n", + "\n", + " >>> Poly(2*x + 3).exquo_ground(2)\n", + " Traceback (most recent call last):\n", + " ...\n", + " ExactQuotientFailed: 2 does not divide 3 in ZZ\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'exquo_ground'):\n", + " result = f.rep.exquo_ground(coeff)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'exquo_ground')\n", + "\n", + " return f.per(result)\n", + "\n", + " def abs(f):\n", + " \"\"\"\n", + " Make all coefficients in ``f`` positive.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).abs()\n", + " Poly(x**2 + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'abs'):\n", + " result = f.rep.abs()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'abs')\n", + "\n", + " return f.per(result)\n", + "\n", + " def neg(f):\n", + " \"\"\"\n", + " Negate all coefficients in ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).neg()\n", + " Poly(-x**2 + 1, x, domain='ZZ')\n", + "\n", + " >>> -Poly(x**2 - 1, x)\n", + " Poly(-x**2 + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'neg'):\n", + " result = f.rep.neg()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'neg')\n", + "\n", + " return f.per(result)\n", + "\n", + " def add(f, g):\n", + " \"\"\"\n", + " Add two polynomials ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).add(Poly(x - 2, x))\n", + " Poly(x**2 + x - 1, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x) + Poly(x - 2, x)\n", + " Poly(x**2 + x - 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " g = sympify(g)\n", + "\n", + " if not g.is_Poly:\n", + " return f.add_ground(g)\n", + "\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'add'):\n", + " result = F.add(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'add')\n", + "\n", + " return per(result)\n", + "\n", + " def sub(f, g):\n", + " \"\"\"\n", + " Subtract two polynomials ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).sub(Poly(x - 2, x))\n", + " Poly(x**2 - x + 3, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x) - Poly(x - 2, x)\n", + " Poly(x**2 - x + 3, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " g = sympify(g)\n", + "\n", + " if not g.is_Poly:\n", + " return f.sub_ground(g)\n", + "\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'sub'):\n", + " result = F.sub(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sub')\n", + "\n", + " return per(result)\n", + "\n", + " def mul(f, g):\n", + " \"\"\"\n", + " Multiply two polynomials ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).mul(Poly(x - 2, x))\n", + " Poly(x**3 - 2*x**2 + x - 2, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x)*Poly(x - 2, x)\n", + " Poly(x**3 - 2*x**2 + x - 2, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " g = sympify(g)\n", + "\n", + " if not g.is_Poly:\n", + " return f.mul_ground(g)\n", + "\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'mul'):\n", + " result = F.mul(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'mul')\n", + "\n", + " return per(result)\n", + "\n", + " def sqr(f):\n", + " \"\"\"\n", + " Square a polynomial ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x - 2, x).sqr()\n", + " Poly(x**2 - 4*x + 4, x, domain='ZZ')\n", + "\n", + " >>> Poly(x - 2, x)**2\n", + " Poly(x**2 - 4*x + 4, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sqr'):\n", + " result = f.rep.sqr()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sqr')\n", + "\n", + " return f.per(result)\n", + "\n", + " def pow(f, n):\n", + " \"\"\"\n", + " Raise ``f`` to a non-negative power ``n``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x - 2, x).pow(3)\n", + " Poly(x**3 - 6*x**2 + 12*x - 8, x, domain='ZZ')\n", + "\n", + " >>> Poly(x - 2, x)**3\n", + " Poly(x**3 - 6*x**2 + 12*x - 8, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " n = int(n)\n", + "\n", + " if hasattr(f.rep, 'pow'):\n", + " result = f.rep.pow(n)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'pow')\n", + "\n", + " return f.per(result)\n", + "\n", + " def pdiv(f, g):\n", + " \"\"\"\n", + " Polynomial pseudo-division of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).pdiv(Poly(2*x - 4, x))\n", + " (Poly(2*x + 4, x, domain='ZZ'), Poly(20, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'pdiv'):\n", + " q, r = F.pdiv(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'pdiv')\n", + "\n", + " return per(q), per(r)\n", + "\n", + " def prem(f, g):\n", + " \"\"\"\n", + " Polynomial pseudo-remainder of ``f`` by ``g``.\n", + "\n", + " Caveat: The function prem(f, g, x) can be safely used to compute\n", + " in Z[x] _only_ subresultant polynomial remainder sequences (prs's).\n", + "\n", + " To safely compute Euclidean and Sturmian prs's in Z[x]\n", + " employ anyone of the corresponding functions found in\n", + " the module sympy.polys.subresultants_qq_zz. The functions\n", + " in the module with suffix _pg compute prs's in Z[x] employing\n", + " rem(f, g, x), whereas the functions with suffix _amv\n", + " compute prs's in Z[x] employing rem_z(f, g, x).\n", + "\n", + " The function rem_z(f, g, x) differs from prem(f, g, x) in that\n", + " to compute the remainder polynomials in Z[x] it premultiplies\n", + " the divident times the absolute value of the leading coefficient\n", + " of the divisor raised to the power degree(f, x) - degree(g, x) + 1.\n", + "\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).prem(Poly(2*x - 4, x))\n", + " Poly(20, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'prem'):\n", + " result = F.prem(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'prem')\n", + "\n", + " return per(result)\n", + "\n", + " def pquo(f, g):\n", + " \"\"\"\n", + " Polynomial pseudo-quotient of ``f`` by ``g``.\n", + "\n", + " See the Caveat note in the function prem(f, g).\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).pquo(Poly(2*x - 4, x))\n", + " Poly(2*x + 4, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 - 1, x).pquo(Poly(2*x - 2, x))\n", + " Poly(2*x + 2, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'pquo'):\n", + " result = F.pquo(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'pquo')\n", + "\n", + " return per(result)\n", + "\n", + " def pexquo(f, g):\n", + " \"\"\"\n", + " Polynomial exact pseudo-quotient of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).pexquo(Poly(2*x - 2, x))\n", + " Poly(2*x + 2, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x).pexquo(Poly(2*x - 4, x))\n", + " Traceback (most recent call last):\n", + " ...\n", + " ExactQuotientFailed: 2*x - 4 does not divide x**2 + 1\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'pexquo'):\n", + " try:\n", + " result = F.pexquo(G)\n", + " except ExactQuotientFailed as exc:\n", + " raise exc.new(f.as_expr(), g.as_expr())\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'pexquo')\n", + "\n", + " return per(result)\n", + "\n", + " def div(f, g, auto=True):\n", + " \"\"\"\n", + " Polynomial division with remainder of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x))\n", + " (Poly(1/2*x + 1, x, domain='QQ'), Poly(5, x, domain='QQ'))\n", + "\n", + " >>> Poly(x**2 + 1, x).div(Poly(2*x - 4, x), auto=False)\n", + " (Poly(0, x, domain='ZZ'), Poly(x**2 + 1, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + " retract = False\n", + "\n", + " if auto and dom.is_Ring and not dom.is_Field:\n", + " F, G = F.to_field(), G.to_field()\n", + " retract = True\n", + "\n", + " if hasattr(f.rep, 'div'):\n", + " q, r = F.div(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'div')\n", + "\n", + " if retract:\n", + " try:\n", + " Q, R = q.to_ring(), r.to_ring()\n", + " except CoercionFailed:\n", + " pass\n", + " else:\n", + " q, r = Q, R\n", + "\n", + " return per(q), per(r)\n", + "\n", + " def rem(f, g, auto=True):\n", + " \"\"\"\n", + " Computes the polynomial remainder of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).rem(Poly(2*x - 4, x))\n", + " Poly(5, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x).rem(Poly(2*x - 4, x), auto=False)\n", + " Poly(x**2 + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + " retract = False\n", + "\n", + " if auto and dom.is_Ring and not dom.is_Field:\n", + " F, G = F.to_field(), G.to_field()\n", + " retract = True\n", + "\n", + " if hasattr(f.rep, 'rem'):\n", + " r = F.rem(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'rem')\n", + "\n", + " if retract:\n", + " try:\n", + " r = r.to_ring()\n", + " except CoercionFailed:\n", + " pass\n", + "\n", + " return per(r)\n", + "\n", + " def quo(f, g, auto=True):\n", + " \"\"\"\n", + " Computes polynomial quotient of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).quo(Poly(2*x - 4, x))\n", + " Poly(1/2*x + 1, x, domain='QQ')\n", + "\n", + " >>> Poly(x**2 - 1, x).quo(Poly(x - 1, x))\n", + " Poly(x + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + " retract = False\n", + "\n", + " if auto and dom.is_Ring and not dom.is_Field:\n", + " F, G = F.to_field(), G.to_field()\n", + " retract = True\n", + "\n", + " if hasattr(f.rep, 'quo'):\n", + " q = F.quo(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'quo')\n", + "\n", + " if retract:\n", + " try:\n", + " q = q.to_ring()\n", + " except CoercionFailed:\n", + " pass\n", + "\n", + " return per(q)\n", + "\n", + " def exquo(f, g, auto=True):\n", + " \"\"\"\n", + " Computes polynomial exact quotient of ``f`` by ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).exquo(Poly(x - 1, x))\n", + " Poly(x + 1, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 + 1, x).exquo(Poly(2*x - 4, x))\n", + " Traceback (most recent call last):\n", + " ...\n", + " ExactQuotientFailed: 2*x - 4 does not divide x**2 + 1\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + " retract = False\n", + "\n", + " if auto and dom.is_Ring and not dom.is_Field:\n", + " F, G = F.to_field(), G.to_field()\n", + " retract = True\n", + "\n", + " if hasattr(f.rep, 'exquo'):\n", + " try:\n", + " q = F.exquo(G)\n", + " except ExactQuotientFailed as exc:\n", + " raise exc.new(f.as_expr(), g.as_expr())\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'exquo')\n", + "\n", + " if retract:\n", + " try:\n", + " q = q.to_ring()\n", + " except CoercionFailed:\n", + " pass\n", + "\n", + " return per(q)\n", + "\n", + " def _gen_to_level(f, gen):\n", + " \"\"\"Returns level associated with the given generator. \"\"\"\n", + " if isinstance(gen, int):\n", + " length = len(f.gens)\n", + "\n", + " if -length <= gen < length:\n", + " if gen < 0:\n", + " return length + gen\n", + " else:\n", + " return gen\n", + " else:\n", + " raise PolynomialError(\"-%s <= gen < %s expected, got %s\" %\n", + " (length, length, gen))\n", + " else:\n", + " try:\n", + " return f.gens.index(sympify(gen))\n", + " except ValueError:\n", + " raise PolynomialError(\n", + " \"a valid generator expected, got %s\" % gen)\n", + "\n", + " def degree(f, gen=0):\n", + " \"\"\"\n", + " Returns degree of ``f`` in ``x_j``.\n", + "\n", + " The degree of 0 is negative infinity.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + y*x + 1, x, y).degree()\n", + " 2\n", + " >>> Poly(x**2 + y*x + y, x, y).degree(y)\n", + " 1\n", + " >>> Poly(0, x).degree()\n", + " -oo\n", + "\n", + " \"\"\"\n", + " j = f._gen_to_level(gen)\n", + "\n", + " if hasattr(f.rep, 'degree'):\n", + " return f.rep.degree(j)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'degree')\n", + "\n", + " def degree_list(f):\n", + " \"\"\"\n", + " Returns a list of degrees of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + y*x + 1, x, y).degree_list()\n", + " (2, 1)\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'degree_list'):\n", + " return f.rep.degree_list()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'degree_list')\n", + "\n", + " def total_degree(f):\n", + " \"\"\"\n", + " Returns the total degree of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + y*x + 1, x, y).total_degree()\n", + " 2\n", + " >>> Poly(x + y**5, x, y).total_degree()\n", + " 5\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'total_degree'):\n", + " return f.rep.total_degree()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'total_degree')\n", + "\n", + " def homogenize(f, s):\n", + " \"\"\"\n", + " Returns the homogeneous polynomial of ``f``.\n", + "\n", + " A homogeneous polynomial is a polynomial whose all monomials with\n", + " non-zero coefficients have the same total degree. If you only\n", + " want to check if a polynomial is homogeneous, then use\n", + " :func:`Poly.is_homogeneous`. If you want not only to check if a\n", + " polynomial is homogeneous but also compute its homogeneous order,\n", + " then use :func:`Poly.homogeneous_order`.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> f = Poly(x**5 + 2*x**2*y**2 + 9*x*y**3)\n", + " >>> f.homogenize(z)\n", + " Poly(x**5 + 2*x**2*y**2*z + 9*x*y**3*z, x, y, z, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if not isinstance(s, Symbol):\n", + " raise TypeError(\"``Symbol`` expected, got %s\" % type(s))\n", + " if s in f.gens:\n", + " i = f.gens.index(s)\n", + " gens = f.gens\n", + " else:\n", + " i = len(f.gens)\n", + " gens = f.gens + (s,)\n", + " if hasattr(f.rep, 'homogenize'):\n", + " return f.per(f.rep.homogenize(i), gens=gens)\n", + " raise OperationNotSupported(f, 'homogeneous_order')\n", + "\n", + " def homogeneous_order(f):\n", + " \"\"\"\n", + " Returns the homogeneous order of ``f``.\n", + "\n", + " A homogeneous polynomial is a polynomial whose all monomials with\n", + " non-zero coefficients have the same total degree. This degree is\n", + " the homogeneous order of ``f``. If you only want to check if a\n", + " polynomial is homogeneous, then use :func:`Poly.is_homogeneous`.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = Poly(x**5 + 2*x**3*y**2 + 9*x*y**4)\n", + " >>> f.homogeneous_order()\n", + " 5\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'homogeneous_order'):\n", + " return f.rep.homogeneous_order()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'homogeneous_order')\n", + "\n", + " def LC(f, order=None):\n", + " \"\"\"\n", + " Returns the leading coefficient of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(4*x**3 + 2*x**2 + 3*x, x).LC()\n", + " 4\n", + "\n", + " \"\"\"\n", + " if order is not None:\n", + " return f.coeffs(order)[0]\n", + "\n", + " if hasattr(f.rep, 'LC'):\n", + " result = f.rep.LC()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'LC')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def TC(f):\n", + " \"\"\"\n", + " Returns the trailing coefficient of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x**2 + 3*x, x).TC()\n", + " 0\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'TC'):\n", + " result = f.rep.TC()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'TC')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def EC(f, order=None):\n", + " \"\"\"\n", + " Returns the last non-zero coefficient of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 + 2*x**2 + 3*x, x).EC()\n", + " 3\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'coeffs'):\n", + " return f.coeffs(order)[-1]\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'EC')\n", + "\n", + " def coeff_monomial(f, monom):\n", + " \"\"\"\n", + " Returns the coefficient of ``monom`` in ``f`` if there, else None.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, exp\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> p = Poly(24*x*y*exp(8) + 23*x, x, y)\n", + "\n", + " >>> p.coeff_monomial(x)\n", + " 23\n", + " >>> p.coeff_monomial(y)\n", + " 0\n", + " >>> p.coeff_monomial(x*y)\n", + " 24*exp(8)\n", + "\n", + " Note that ``Expr.coeff()`` behaves differently, collecting terms\n", + " if possible; the Poly must be converted to an Expr to use that\n", + " method, however:\n", + "\n", + " >>> p.as_expr().coeff(x)\n", + " 24*y*exp(8) + 23\n", + " >>> p.as_expr().coeff(y)\n", + " 24*x*exp(8)\n", + " >>> p.as_expr().coeff(x*y)\n", + " 24*exp(8)\n", + "\n", + " See Also\n", + " ========\n", + " nth: more efficient query using exponents of the monomial's generators\n", + "\n", + " \"\"\"\n", + " return f.nth(*Monomial(monom, f.gens).exponents)\n", + "\n", + " def nth(f, *N):\n", + " \"\"\"\n", + " Returns the ``n``-th coefficient of ``f`` where ``N`` are the\n", + " exponents of the generators in the term of interest.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, sqrt\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**3 + 2*x**2 + 3*x, x).nth(2)\n", + " 2\n", + " >>> Poly(x**3 + 2*x*y**2 + y**2, x, y).nth(1, 2)\n", + " 2\n", + " >>> Poly(4*sqrt(x)*y)\n", + " Poly(4*y*(sqrt(x)), y, sqrt(x), domain='ZZ')\n", + " >>> _.nth(1, 1)\n", + " 4\n", + "\n", + " See Also\n", + " ========\n", + " coeff_monomial\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'nth'):\n", + " if len(N) != len(f.gens):\n", + " raise ValueError('exponent of each generator must be specified')\n", + " result = f.rep.nth(*list(map(int, N)))\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'nth')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def coeff(f, x, n=1, right=False):\n", + " # the semantics of coeff_monomial and Expr.coeff are different;\n", + " # if someone is working with a Poly, they should be aware of the\n", + " # differences and chose the method best suited for the query.\n", + " # Alternatively, a pure-polys method could be written here but\n", + " # at this time the ``right`` keyword would be ignored because Poly\n", + " # doesn't work with non-commutatives.\n", + " raise NotImplementedError(\n", + " 'Either convert to Expr with `as_expr` method '\n", + " 'to use Expr\\'s coeff method or else use the '\n", + " '`coeff_monomial` method of Polys.')\n", + "\n", + " def LM(f, order=None):\n", + " \"\"\"\n", + " Returns the leading monomial of ``f``.\n", + "\n", + " The Leading monomial signifies the monomial having\n", + " the highest power of the principal generator in the\n", + " expression f.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).LM()\n", + " x**2*y**0\n", + "\n", + " \"\"\"\n", + " return Monomial(f.monoms(order)[0], f.gens)\n", + "\n", + " def EM(f, order=None):\n", + " \"\"\"\n", + " Returns the last non-zero monomial of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).EM()\n", + " x**0*y**1\n", + "\n", + " \"\"\"\n", + " return Monomial(f.monoms(order)[-1], f.gens)\n", + "\n", + " def LT(f, order=None):\n", + " \"\"\"\n", + " Returns the leading term of ``f``.\n", + "\n", + " The Leading term signifies the term having\n", + " the highest power of the principal generator in the\n", + " expression f along with its coefficient.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).LT()\n", + " (x**2*y**0, 4)\n", + "\n", + " \"\"\"\n", + " monom, coeff = f.terms(order)[0]\n", + " return Monomial(monom, f.gens), coeff\n", + "\n", + " def ET(f, order=None):\n", + " \"\"\"\n", + " Returns the last non-zero term of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(4*x**2 + 2*x*y**2 + x*y + 3*y, x, y).ET()\n", + " (x**0*y**1, 3)\n", + "\n", + " \"\"\"\n", + " monom, coeff = f.terms(order)[-1]\n", + " return Monomial(monom, f.gens), coeff\n", + "\n", + " def max_norm(f):\n", + " \"\"\"\n", + " Returns maximum norm of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(-x**2 + 2*x - 3, x).max_norm()\n", + " 3\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'max_norm'):\n", + " result = f.rep.max_norm()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'max_norm')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def l1_norm(f):\n", + " \"\"\"\n", + " Returns l1 norm of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(-x**2 + 2*x - 3, x).l1_norm()\n", + " 6\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'l1_norm'):\n", + " result = f.rep.l1_norm()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'l1_norm')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def clear_denoms(self, convert=False):\n", + " \"\"\"\n", + " Clear denominators, but keep the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, S, QQ\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = Poly(x/2 + S(1)/3, x, domain=QQ)\n", + "\n", + " >>> f.clear_denoms()\n", + " (6, Poly(3*x + 2, x, domain='QQ'))\n", + " >>> f.clear_denoms(convert=True)\n", + " (6, Poly(3*x + 2, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " if not f.rep.dom.is_Field:\n", + " return S.One, f\n", + "\n", + " dom = f.get_domain()\n", + " if dom.has_assoc_Ring:\n", + " dom = f.rep.dom.get_ring()\n", + "\n", + " if hasattr(f.rep, 'clear_denoms'):\n", + " coeff, result = f.rep.clear_denoms()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'clear_denoms')\n", + "\n", + " coeff, f = dom.to_sympy(coeff), f.per(result)\n", + "\n", + " if not convert or not dom.has_assoc_Ring:\n", + " return coeff, f\n", + " else:\n", + " return coeff, f.to_ring()\n", + "\n", + " def rat_clear_denoms(self, g):\n", + " \"\"\"\n", + " Clear denominators in a rational function ``f/g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = Poly(x**2/y + 1, x)\n", + " >>> g = Poly(x**3 + y, x)\n", + "\n", + " >>> p, q = f.rat_clear_denoms(g)\n", + "\n", + " >>> p\n", + " Poly(x**2 + y, x, domain='ZZ[y]')\n", + " >>> q\n", + " Poly(y*x**3 + y**2, x, domain='ZZ[y]')\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " dom, per, f, g = f._unify(g)\n", + "\n", + " f = per(f)\n", + " g = per(g)\n", + "\n", + " if not (dom.is_Field and dom.has_assoc_Ring):\n", + " return f, g\n", + "\n", + " a, f = f.clear_denoms(convert=True)\n", + " b, g = g.clear_denoms(convert=True)\n", + "\n", + " f = f.mul_ground(b)\n", + " g = g.mul_ground(a)\n", + "\n", + " return f, g\n", + "\n", + " def integrate(self, *specs, **args):\n", + " \"\"\"\n", + " Computes indefinite integral of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 2*x + 1, x).integrate()\n", + " Poly(1/3*x**3 + x**2 + x, x, domain='QQ')\n", + "\n", + " >>> Poly(x*y**2 + x, x, y).integrate((0, 1), (1, 0))\n", + " Poly(1/2*x**2*y**2 + 1/2*x**2, x, y, domain='QQ')\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " if args.get('auto', True) and f.rep.dom.is_Ring:\n", + " f = f.to_field()\n", + "\n", + " if hasattr(f.rep, 'integrate'):\n", + " if not specs:\n", + " return f.per(f.rep.integrate(m=1))\n", + "\n", + " rep = f.rep\n", + "\n", + " for spec in specs:\n", + " if type(spec) is tuple:\n", + " gen, m = spec\n", + " else:\n", + " gen, m = spec, 1\n", + "\n", + " rep = rep.integrate(int(m), f._gen_to_level(gen))\n", + "\n", + " return f.per(rep)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'integrate')\n", + "\n", + " def diff(f, *specs, **kwargs):\n", + " \"\"\"\n", + " Computes partial derivative of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + 2*x + 1, x).diff()\n", + " Poly(2*x + 2, x, domain='ZZ')\n", + "\n", + " >>> Poly(x*y**2 + x, x, y).diff((0, 0), (1, 1))\n", + " Poly(2*x*y, x, y, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if not kwargs.get('evaluate', True):\n", + " return Derivative(f, *specs, **kwargs)\n", + "\n", + " if hasattr(f.rep, 'diff'):\n", + " if not specs:\n", + " return f.per(f.rep.diff(m=1))\n", + "\n", + " rep = f.rep\n", + "\n", + " for spec in specs:\n", + " if type(spec) is tuple:\n", + " gen, m = spec\n", + " else:\n", + " gen, m = spec, 1\n", + "\n", + " rep = rep.diff(int(m), f._gen_to_level(gen))\n", + "\n", + " return f.per(rep)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'diff')\n", + "\n", + " _eval_derivative = diff\n", + "\n", + " def eval(self, x, a=None, auto=True):\n", + " \"\"\"\n", + " Evaluate ``f`` at ``a`` in the given variable.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> Poly(x**2 + 2*x + 3, x).eval(2)\n", + " 11\n", + "\n", + " >>> Poly(2*x*y + 3*x + y + 2, x, y).eval(x, 2)\n", + " Poly(5*y + 8, y, domain='ZZ')\n", + "\n", + " >>> f = Poly(2*x*y + 3*x + y + 2*z, x, y, z)\n", + "\n", + " >>> f.eval({x: 2})\n", + " Poly(5*y + 2*z + 6, y, z, domain='ZZ')\n", + " >>> f.eval({x: 2, y: 5})\n", + " Poly(2*z + 31, z, domain='ZZ')\n", + " >>> f.eval({x: 2, y: 5, z: 7})\n", + " 45\n", + "\n", + " >>> f.eval((2, 5))\n", + " Poly(2*z + 31, z, domain='ZZ')\n", + " >>> f(2, 5)\n", + " Poly(2*z + 31, z, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " if a is None:\n", + " if isinstance(x, dict):\n", + " mapping = x\n", + "\n", + " for gen, value in mapping.items():\n", + " f = f.eval(gen, value)\n", + "\n", + " return f\n", + " elif isinstance(x, (tuple, list)):\n", + " values = x\n", + "\n", + " if len(values) > len(f.gens):\n", + " raise ValueError(\"too many values provided\")\n", + "\n", + " for gen, value in zip(f.gens, values):\n", + " f = f.eval(gen, value)\n", + "\n", + " return f\n", + " else:\n", + " j, a = 0, x\n", + " else:\n", + " j = f._gen_to_level(x)\n", + "\n", + " if not hasattr(f.rep, 'eval'): # pragma: no cover\n", + " raise OperationNotSupported(f, 'eval')\n", + "\n", + " try:\n", + " result = f.rep.eval(a, j)\n", + " except CoercionFailed:\n", + " if not auto:\n", + " raise DomainError(\"can't evaluate at %s in %s\" % (a, f.rep.dom))\n", + " else:\n", + " a_domain, [a] = construct_domain([a])\n", + " new_domain = f.get_domain().unify_with_symbols(a_domain, f.gens)\n", + "\n", + " f = f.set_domain(new_domain)\n", + " a = new_domain.convert(a, a_domain)\n", + "\n", + " result = f.rep.eval(a, j)\n", + "\n", + " return f.per(result, remove=j)\n", + "\n", + " def __call__(f, *values):\n", + " \"\"\"\n", + " Evaluate ``f`` at the give values.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y, z\n", + "\n", + " >>> f = Poly(2*x*y + 3*x + y + 2*z, x, y, z)\n", + "\n", + " >>> f(2)\n", + " Poly(5*y + 2*z + 6, y, z, domain='ZZ')\n", + " >>> f(2, 5)\n", + " Poly(2*z + 31, z, domain='ZZ')\n", + " >>> f(2, 5, 7)\n", + " 45\n", + "\n", + " \"\"\"\n", + " return f.eval(values)\n", + "\n", + " def half_gcdex(f, g, auto=True):\n", + " \"\"\"\n", + " Half extended Euclidean algorithm of ``f`` and ``g``.\n", + "\n", + " Returns ``(s, h)`` such that ``h = gcd(f, g)`` and ``s*f = h (mod g)``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15\n", + " >>> g = x**3 + x**2 - 4*x - 4\n", + "\n", + " >>> Poly(f).half_gcdex(Poly(g))\n", + " (Poly(-1/5*x + 3/5, x, domain='QQ'), Poly(x + 1, x, domain='QQ'))\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + "\n", + " if auto and dom.is_Ring:\n", + " F, G = F.to_field(), G.to_field()\n", + "\n", + " if hasattr(f.rep, 'half_gcdex'):\n", + " s, h = F.half_gcdex(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'half_gcdex')\n", + "\n", + " return per(s), per(h)\n", + "\n", + " def gcdex(f, g, auto=True):\n", + " \"\"\"\n", + " Extended Euclidean algorithm of ``f`` and ``g``.\n", + "\n", + " Returns ``(s, t, h)`` such that ``h = gcd(f, g)`` and ``s*f + t*g = h``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15\n", + " >>> g = x**3 + x**2 - 4*x - 4\n", + "\n", + " >>> Poly(f).gcdex(Poly(g))\n", + " (Poly(-1/5*x + 3/5, x, domain='QQ'),\n", + " Poly(1/5*x**2 - 6/5*x + 2, x, domain='QQ'),\n", + " Poly(x + 1, x, domain='QQ'))\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + "\n", + " if auto and dom.is_Ring:\n", + " F, G = F.to_field(), G.to_field()\n", + "\n", + " if hasattr(f.rep, 'gcdex'):\n", + " s, t, h = F.gcdex(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'gcdex')\n", + "\n", + " return per(s), per(t), per(h)\n", + "\n", + " def invert(f, g, auto=True):\n", + " \"\"\"\n", + " Invert ``f`` modulo ``g`` when possible.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).invert(Poly(2*x - 1, x))\n", + " Poly(-4/3, x, domain='QQ')\n", + "\n", + " >>> Poly(x**2 - 1, x).invert(Poly(x - 1, x))\n", + " Traceback (most recent call last):\n", + " ...\n", + " NotInvertible: zero divisor\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + "\n", + " if auto and dom.is_Ring:\n", + " F, G = F.to_field(), G.to_field()\n", + "\n", + " if hasattr(f.rep, 'invert'):\n", + " result = F.invert(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'invert')\n", + "\n", + " return per(result)\n", + "\n", + " def revert(f, n):\n", + " \"\"\"\n", + " Compute ``f**(-1)`` mod ``x**n``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(1, x).revert(2)\n", + " Poly(1, x, domain='ZZ')\n", + "\n", + " >>> Poly(1 + x, x).revert(1)\n", + " Poly(1, x, domain='ZZ')\n", + "\n", + " >>> Poly(x**2 - 1, x).revert(1)\n", + " Traceback (most recent call last):\n", + " ...\n", + " NotReversible: only unity is reversible in a ring\n", + "\n", + " >>> Poly(1/x, x).revert(1)\n", + " Traceback (most recent call last):\n", + " ...\n", + " PolynomialError: 1/x contains an element of the generators set\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'revert'):\n", + " result = f.rep.revert(int(n))\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'revert')\n", + "\n", + " return f.per(result)\n", + "\n", + " def subresultants(f, g):\n", + " \"\"\"\n", + " Computes the subresultant PRS of ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 1, x).subresultants(Poly(x**2 - 1, x))\n", + " [Poly(x**2 + 1, x, domain='ZZ'),\n", + " Poly(x**2 - 1, x, domain='ZZ'),\n", + " Poly(-2, x, domain='ZZ')]\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'subresultants'):\n", + " result = F.subresultants(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'subresultants')\n", + "\n", + " return list(map(per, result))\n", + "\n", + " def resultant(f, g, includePRS=False):\n", + " \"\"\"\n", + " Computes the resultant of ``f`` and ``g`` via PRS.\n", + "\n", + " If includePRS=True, it includes the subresultant PRS in the result.\n", + " Because the PRS is used to calculate the resultant, this is more\n", + " efficient than calling :func:`subresultants` separately.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = Poly(x**2 + 1, x)\n", + "\n", + " >>> f.resultant(Poly(x**2 - 1, x))\n", + " 4\n", + " >>> f.resultant(Poly(x**2 - 1, x), includePRS=True)\n", + " (4, [Poly(x**2 + 1, x, domain='ZZ'), Poly(x**2 - 1, x, domain='ZZ'),\n", + " Poly(-2, x, domain='ZZ')])\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'resultant'):\n", + " if includePRS:\n", + " result, R = F.resultant(G, includePRS=includePRS)\n", + " else:\n", + " result = F.resultant(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'resultant')\n", + "\n", + " if includePRS:\n", + " return (per(result, remove=0), list(map(per, R)))\n", + " return per(result, remove=0)\n", + "\n", + " def discriminant(f):\n", + " \"\"\"\n", + " Computes the discriminant of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + 2*x + 3, x).discriminant()\n", + " -8\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'discriminant'):\n", + " result = f.rep.discriminant()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'discriminant')\n", + "\n", + " return f.per(result, remove=0)\n", + "\n", + " def dispersionset(f, g=None):\n", + " r\"\"\"Compute the *dispersion set* of two polynomials.\n", + "\n", + " For two polynomials `f(x)` and `g(x)` with `\\deg f > 0`\n", + " and `\\deg g > 0` the dispersion set `\\operatorname{J}(f, g)` is defined as:\n", + "\n", + " .. math::\n", + " \\operatorname{J}(f, g)\n", + " & := \\{a \\in \\mathbb{N}_0 | \\gcd(f(x), g(x+a)) \\neq 1\\} \\\\\n", + " & = \\{a \\in \\mathbb{N}_0 | \\deg \\gcd(f(x), g(x+a)) \\geq 1\\}\n", + "\n", + " For a single polynomial one defines `\\operatorname{J}(f) := \\operatorname{J}(f, f)`.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import poly\n", + " >>> from sympy.polys.dispersion import dispersion, dispersionset\n", + " >>> from sympy.abc import x\n", + "\n", + " Dispersion set and dispersion of a simple polynomial:\n", + "\n", + " >>> fp = poly((x - 3)*(x + 3), x)\n", + " >>> sorted(dispersionset(fp))\n", + " [0, 6]\n", + " >>> dispersion(fp)\n", + " 6\n", + "\n", + " Note that the definition of the dispersion is not symmetric:\n", + "\n", + " >>> fp = poly(x**4 - 3*x**2 + 1, x)\n", + " >>> gp = fp.shift(-3)\n", + " >>> sorted(dispersionset(fp, gp))\n", + " [2, 3, 4]\n", + " >>> dispersion(fp, gp)\n", + " 4\n", + " >>> sorted(dispersionset(gp, fp))\n", + " []\n", + " >>> dispersion(gp, fp)\n", + " -oo\n", + "\n", + " Computing the dispersion also works over field extensions:\n", + "\n", + " >>> from sympy import sqrt\n", + " >>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ')\n", + " >>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ')\n", + " >>> sorted(dispersionset(fp, gp))\n", + " [2]\n", + " >>> sorted(dispersionset(gp, fp))\n", + " [1, 4]\n", + "\n", + " We can even perform the computations for polynomials\n", + " having symbolic coefficients:\n", + "\n", + " >>> from sympy.abc import a\n", + " >>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)\n", + " >>> sorted(dispersionset(fp))\n", + " [0, 1]\n", + "\n", + " See Also\n", + " ========\n", + "\n", + " dispersion\n", + "\n", + " References\n", + " ==========\n", + "\n", + " 1. [ManWright94]_\n", + " 2. [Koepf98]_\n", + " 3. [Abramov71]_\n", + " 4. [Man93]_\n", + " \"\"\"\n", + " from sympy.polys.dispersion import dispersionset\n", + " return dispersionset(f, g)\n", + "\n", + " def dispersion(f, g=None):\n", + " r\"\"\"Compute the *dispersion* of polynomials.\n", + "\n", + " For two polynomials `f(x)` and `g(x)` with `\\deg f > 0`\n", + " and `\\deg g > 0` the dispersion `\\operatorname{dis}(f, g)` is defined as:\n", + "\n", + " .. math::\n", + " \\operatorname{dis}(f, g)\n", + " & := \\max\\{ J(f,g) \\cup \\{0\\} \\} \\\\\n", + " & = \\max\\{ \\{a \\in \\mathbb{N} | \\gcd(f(x), g(x+a)) \\neq 1\\} \\cup \\{0\\} \\}\n", + "\n", + " and for a single polynomial `\\operatorname{dis}(f) := \\operatorname{dis}(f, f)`.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import poly\n", + " >>> from sympy.polys.dispersion import dispersion, dispersionset\n", + " >>> from sympy.abc import x\n", + "\n", + " Dispersion set and dispersion of a simple polynomial:\n", + "\n", + " >>> fp = poly((x - 3)*(x + 3), x)\n", + " >>> sorted(dispersionset(fp))\n", + " [0, 6]\n", + " >>> dispersion(fp)\n", + " 6\n", + "\n", + " Note that the definition of the dispersion is not symmetric:\n", + "\n", + " >>> fp = poly(x**4 - 3*x**2 + 1, x)\n", + " >>> gp = fp.shift(-3)\n", + " >>> sorted(dispersionset(fp, gp))\n", + " [2, 3, 4]\n", + " >>> dispersion(fp, gp)\n", + " 4\n", + " >>> sorted(dispersionset(gp, fp))\n", + " []\n", + " >>> dispersion(gp, fp)\n", + " -oo\n", + "\n", + " Computing the dispersion also works over field extensions:\n", + "\n", + " >>> from sympy import sqrt\n", + " >>> fp = poly(x**2 + sqrt(5)*x - 1, x, domain='QQ')\n", + " >>> gp = poly(x**2 + (2 + sqrt(5))*x + sqrt(5), x, domain='QQ')\n", + " >>> sorted(dispersionset(fp, gp))\n", + " [2]\n", + " >>> sorted(dispersionset(gp, fp))\n", + " [1, 4]\n", + "\n", + " We can even perform the computations for polynomials\n", + " having symbolic coefficients:\n", + "\n", + " >>> from sympy.abc import a\n", + " >>> fp = poly(4*x**4 + (4*a + 8)*x**3 + (a**2 + 6*a + 4)*x**2 + (a**2 + 2*a)*x, x)\n", + " >>> sorted(dispersionset(fp))\n", + " [0, 1]\n", + "\n", + " See Also\n", + " ========\n", + "\n", + " dispersionset\n", + "\n", + " References\n", + " ==========\n", + "\n", + " 1. [ManWright94]_\n", + " 2. [Koepf98]_\n", + " 3. [Abramov71]_\n", + " 4. [Man93]_\n", + " \"\"\"\n", + " from sympy.polys.dispersion import dispersion\n", + " return dispersion(f, g)\n", + "\n", + " def cofactors(f, g):\n", + " \"\"\"\n", + " Returns the GCD of ``f`` and ``g`` and their cofactors.\n", + "\n", + " Returns polynomials ``(h, cff, cfg)`` such that ``h = gcd(f, g)``, and\n", + " ``cff = quo(f, h)`` and ``cfg = quo(g, h)`` are, so called, cofactors\n", + " of ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).cofactors(Poly(x**2 - 3*x + 2, x))\n", + " (Poly(x - 1, x, domain='ZZ'),\n", + " Poly(x + 1, x, domain='ZZ'),\n", + " Poly(x - 2, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'cofactors'):\n", + " h, cff, cfg = F.cofactors(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'cofactors')\n", + "\n", + " return per(h), per(cff), per(cfg)\n", + "\n", + " def gcd(f, g):\n", + " \"\"\"\n", + " Returns the polynomial GCD of ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).gcd(Poly(x**2 - 3*x + 2, x))\n", + " Poly(x - 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'gcd'):\n", + " result = F.gcd(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'gcd')\n", + "\n", + " return per(result)\n", + "\n", + " def lcm(f, g):\n", + " \"\"\"\n", + " Returns polynomial LCM of ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 1, x).lcm(Poly(x**2 - 3*x + 2, x))\n", + " Poly(x**3 - 2*x**2 - x + 2, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'lcm'):\n", + " result = F.lcm(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'lcm')\n", + "\n", + " return per(result)\n", + "\n", + " def trunc(f, p):\n", + " \"\"\"\n", + " Reduce ``f`` modulo a constant ``p``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**3 + 3*x**2 + 5*x + 7, x).trunc(3)\n", + " Poly(-x**3 - x + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " p = f.rep.dom.convert(p)\n", + "\n", + " if hasattr(f.rep, 'trunc'):\n", + " result = f.rep.trunc(p)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'trunc')\n", + "\n", + " return f.per(result)\n", + "\n", + " def monic(self, auto=True):\n", + " \"\"\"\n", + " Divides all coefficients by ``LC(f)``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, ZZ\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(3*x**2 + 6*x + 9, x, domain=ZZ).monic()\n", + " Poly(x**2 + 2*x + 3, x, domain='QQ')\n", + "\n", + " >>> Poly(3*x**2 + 4*x + 2, x, domain=ZZ).monic()\n", + " Poly(x**2 + 4/3*x + 2/3, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " if auto and f.rep.dom.is_Ring:\n", + " f = f.to_field()\n", + "\n", + " if hasattr(f.rep, 'monic'):\n", + " result = f.rep.monic()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'monic')\n", + "\n", + " return f.per(result)\n", + "\n", + " def content(f):\n", + " \"\"\"\n", + " Returns the GCD of polynomial coefficients.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(6*x**2 + 8*x + 12, x).content()\n", + " 2\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'content'):\n", + " result = f.rep.content()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'content')\n", + "\n", + " return f.rep.dom.to_sympy(result)\n", + "\n", + " def primitive(f):\n", + " \"\"\"\n", + " Returns the content and a primitive form of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**2 + 8*x + 12, x).primitive()\n", + " (2, Poly(x**2 + 4*x + 6, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'primitive'):\n", + " cont, result = f.rep.primitive()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'primitive')\n", + "\n", + " return f.rep.dom.to_sympy(cont), f.per(result)\n", + "\n", + " def compose(f, g):\n", + " \"\"\"\n", + " Computes the functional composition of ``f`` and ``g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + x, x).compose(Poly(x - 1, x))\n", + " Poly(x**2 - x, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " _, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(f.rep, 'compose'):\n", + " result = F.compose(G)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'compose')\n", + "\n", + " return per(result)\n", + "\n", + " def decompose(f):\n", + " \"\"\"\n", + " Computes a functional decomposition of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**4 + 2*x**3 - x - 1, x, domain='ZZ').decompose()\n", + " [Poly(x**2 - x - 1, x, domain='ZZ'), Poly(x**2 + x, x, domain='ZZ')]\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'decompose'):\n", + " result = f.rep.decompose()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'decompose')\n", + "\n", + " return list(map(f.per, result))\n", + "\n", + " def shift(f, a):\n", + " \"\"\"\n", + " Efficiently compute Taylor shift ``f(x + a)``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 2*x + 1, x).shift(2)\n", + " Poly(x**2 + 2*x + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'shift'):\n", + " result = f.rep.shift(a)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'shift')\n", + "\n", + " return f.per(result)\n", + "\n", + " def transform(f, p, q):\n", + " \"\"\"\n", + " Efficiently evaluate the functional transformation ``q**n * f(p/q)``.\n", + "\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 2*x + 1, x).transform(Poly(x + 1, x), Poly(x - 1, x))\n", + " Poly(4, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " P, Q = p.unify(q)\n", + " F, P = f.unify(P)\n", + " F, Q = F.unify(Q)\n", + "\n", + " if hasattr(F.rep, 'transform'):\n", + " result = F.rep.transform(P.rep, Q.rep)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(F, 'transform')\n", + "\n", + " return F.per(result)\n", + "\n", + " def sturm(self, auto=True):\n", + " \"\"\"\n", + " Computes the Sturm sequence of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 - 2*x**2 + x - 3, x).sturm()\n", + " [Poly(x**3 - 2*x**2 + x - 3, x, domain='QQ'),\n", + " Poly(3*x**2 - 4*x + 1, x, domain='QQ'),\n", + " Poly(2/9*x + 25/9, x, domain='QQ'),\n", + " Poly(-2079/4, x, domain='QQ')]\n", + "\n", + " \"\"\"\n", + " f = self\n", + "\n", + " if auto and f.rep.dom.is_Ring:\n", + " f = f.to_field()\n", + "\n", + " if hasattr(f.rep, 'sturm'):\n", + " result = f.rep.sturm()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sturm')\n", + "\n", + " return list(map(f.per, result))\n", + "\n", + " def gff_list(f):\n", + " \"\"\"\n", + " Computes greatest factorial factorization of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = x**5 + 2*x**4 - x**3 - 2*x**2\n", + "\n", + " >>> Poly(f).gff_list()\n", + " [(Poly(x, x, domain='ZZ'), 1), (Poly(x + 2, x, domain='ZZ'), 4)]\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'gff_list'):\n", + " result = f.rep.gff_list()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'gff_list')\n", + "\n", + " return [(f.per(g), k) for g, k in result]\n", + "\n", + " def norm(f):\n", + " \"\"\"\n", + " Computes the product, ``Norm(f)``, of the conjugates of\n", + " a polynomial ``f`` defined over a number field ``K``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, sqrt\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> a, b = sqrt(2), sqrt(3)\n", + "\n", + " A polynomial over a quadratic extension.\n", + " Two conjugates x - a and x + a.\n", + "\n", + " >>> f = Poly(x - a, x, extension=a)\n", + " >>> f.norm()\n", + " Poly(x**2 - 2, x, domain='QQ')\n", + "\n", + " A polynomial over a quartic extension.\n", + " Four conjugates x - a, x - a, x + a and x + a.\n", + "\n", + " >>> f = Poly(x - a, x, extension=(a, b))\n", + " >>> f.norm()\n", + " Poly(x**4 - 4*x**2 + 4, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'norm'):\n", + " r = f.rep.norm()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'norm')\n", + "\n", + " return f.per(r)\n", + "\n", + " def sqf_norm(f):\n", + " \"\"\"\n", + " Computes square-free norm of ``f``.\n", + "\n", + " Returns ``s``, ``f``, ``r``, such that ``g(x) = f(x-sa)`` and\n", + " ``r(x) = Norm(g(x))`` is a square-free polynomial over ``K``,\n", + " where ``a`` is the algebraic extension of the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, sqrt\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> s, f, r = Poly(x**2 + 1, x, extension=[sqrt(3)]).sqf_norm()\n", + "\n", + " >>> s\n", + " 1\n", + " >>> f\n", + " Poly(x**2 - 2*sqrt(3)*x + 4, x, domain='QQ')\n", + " >>> r\n", + " Poly(x**4 - 4*x**2 + 16, x, domain='QQ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sqf_norm'):\n", + " s, g, r = f.rep.sqf_norm()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sqf_norm')\n", + "\n", + " return s, f.per(g), f.per(r)\n", + "\n", + " def sqf_part(f):\n", + " \"\"\"\n", + " Computes square-free part of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**3 - 3*x - 2, x).sqf_part()\n", + " Poly(x**2 - x - 2, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sqf_part'):\n", + " result = f.rep.sqf_part()\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sqf_part')\n", + "\n", + " return f.per(result)\n", + "\n", + " def sqf_list(f, all=False):\n", + " \"\"\"\n", + " Returns a list of square-free factors of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = 2*x**5 + 16*x**4 + 50*x**3 + 76*x**2 + 56*x + 16\n", + "\n", + " >>> Poly(f).sqf_list()\n", + " (2, [(Poly(x + 1, x, domain='ZZ'), 2),\n", + " (Poly(x + 2, x, domain='ZZ'), 3)])\n", + "\n", + " >>> Poly(f).sqf_list(all=True)\n", + " (2, [(Poly(1, x, domain='ZZ'), 1),\n", + " (Poly(x + 1, x, domain='ZZ'), 2),\n", + " (Poly(x + 2, x, domain='ZZ'), 3)])\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sqf_list'):\n", + " coeff, factors = f.rep.sqf_list(all)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sqf_list')\n", + "\n", + " return f.rep.dom.to_sympy(coeff), [(f.per(g), k) for g, k in factors]\n", + "\n", + " def sqf_list_include(f, all=False):\n", + " \"\"\"\n", + " Returns a list of square-free factors of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, expand\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = expand(2*(x + 1)**3*x**4)\n", + " >>> f\n", + " 2*x**7 + 6*x**6 + 6*x**5 + 2*x**4\n", + "\n", + " >>> Poly(f).sqf_list_include()\n", + " [(Poly(2, x, domain='ZZ'), 1),\n", + " (Poly(x + 1, x, domain='ZZ'), 3),\n", + " (Poly(x, x, domain='ZZ'), 4)]\n", + "\n", + " >>> Poly(f).sqf_list_include(all=True)\n", + " [(Poly(2, x, domain='ZZ'), 1),\n", + " (Poly(1, x, domain='ZZ'), 2),\n", + " (Poly(x + 1, x, domain='ZZ'), 3),\n", + " (Poly(x, x, domain='ZZ'), 4)]\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'sqf_list_include'):\n", + " factors = f.rep.sqf_list_include(all)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'sqf_list_include')\n", + "\n", + " return [(f.per(g), k) for g, k in factors]\n", + "\n", + " def factor_list(f):\n", + " \"\"\"\n", + " Returns a list of irreducible factors of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = 2*x**5 + 2*x**4*y + 4*x**3 + 4*x**2*y + 2*x + 2*y\n", + "\n", + " >>> Poly(f).factor_list()\n", + " (2, [(Poly(x + y, x, y, domain='ZZ'), 1),\n", + " (Poly(x**2 + 1, x, y, domain='ZZ'), 2)])\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'factor_list'):\n", + " try:\n", + " coeff, factors = f.rep.factor_list()\n", + " except DomainError:\n", + " return S.One, [(f, 1)]\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'factor_list')\n", + "\n", + " return f.rep.dom.to_sympy(coeff), [(f.per(g), k) for g, k in factors]\n", + "\n", + " def factor_list_include(f):\n", + " \"\"\"\n", + " Returns a list of irreducible factors of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> f = 2*x**5 + 2*x**4*y + 4*x**3 + 4*x**2*y + 2*x + 2*y\n", + "\n", + " >>> Poly(f).factor_list_include()\n", + " [(Poly(2*x + 2*y, x, y, domain='ZZ'), 1),\n", + " (Poly(x**2 + 1, x, y, domain='ZZ'), 2)]\n", + "\n", + " \"\"\"\n", + " if hasattr(f.rep, 'factor_list_include'):\n", + " try:\n", + " factors = f.rep.factor_list_include()\n", + " except DomainError:\n", + " return [(f, 1)]\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'factor_list_include')\n", + "\n", + " return [(f.per(g), k) for g, k in factors]\n", + "\n", + " def intervals(f, all=False, eps=None, inf=None, sup=None, fast=False, sqf=False):\n", + " \"\"\"\n", + " Compute isolating intervals for roots of ``f``.\n", + "\n", + " For real roots the Vincent-Akritas-Strzebonski (VAS) continued fractions method is used.\n", + "\n", + " References\n", + " ==========\n", + " .. [#] Alkiviadis G. Akritas and Adam W. Strzebonski: A Comparative Study of Two Real Root\n", + " Isolation Methods . Nonlinear Analysis: Modelling and Control, Vol. 10, No. 4, 297-304, 2005.\n", + " .. [#] Alkiviadis G. Akritas, Adam W. Strzebonski and Panagiotis S. Vigklas: Improving the\n", + " Performance of the Continued Fractions Method Using new Bounds of Positive Roots. Nonlinear\n", + " Analysis: Modelling and Control, Vol. 13, No. 3, 265-279, 2008.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 3, x).intervals()\n", + " [((-2, -1), 1), ((1, 2), 1)]\n", + " >>> Poly(x**2 - 3, x).intervals(eps=1e-2)\n", + " [((-26/15, -19/11), 1), ((19/11, 26/15), 1)]\n", + "\n", + " \"\"\"\n", + " if eps is not None:\n", + " eps = QQ.convert(eps)\n", + "\n", + " if eps <= 0:\n", + " raise ValueError(\"'eps' must be a positive rational\")\n", + "\n", + " if inf is not None:\n", + " inf = QQ.convert(inf)\n", + " if sup is not None:\n", + " sup = QQ.convert(sup)\n", + "\n", + " if hasattr(f.rep, 'intervals'):\n", + " result = f.rep.intervals(\n", + " all=all, eps=eps, inf=inf, sup=sup, fast=fast, sqf=sqf)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'intervals')\n", + "\n", + " if sqf:\n", + " def _real(interval):\n", + " s, t = interval\n", + " return (QQ.to_sympy(s), QQ.to_sympy(t))\n", + "\n", + " if not all:\n", + " return list(map(_real, result))\n", + "\n", + " def _complex(rectangle):\n", + " (u, v), (s, t) = rectangle\n", + " return (QQ.to_sympy(u) + I*QQ.to_sympy(v),\n", + " QQ.to_sympy(s) + I*QQ.to_sympy(t))\n", + "\n", + " real_part, complex_part = result\n", + "\n", + " return list(map(_real, real_part)), list(map(_complex, complex_part))\n", + " else:\n", + " def _real(interval):\n", + " (s, t), k = interval\n", + " return ((QQ.to_sympy(s), QQ.to_sympy(t)), k)\n", + "\n", + " if not all:\n", + " return list(map(_real, result))\n", + "\n", + " def _complex(rectangle):\n", + " ((u, v), (s, t)), k = rectangle\n", + " return ((QQ.to_sympy(u) + I*QQ.to_sympy(v),\n", + " QQ.to_sympy(s) + I*QQ.to_sympy(t)), k)\n", + "\n", + " real_part, complex_part = result\n", + "\n", + " return list(map(_real, real_part)), list(map(_complex, complex_part))\n", + "\n", + " def refine_root(f, s, t, eps=None, steps=None, fast=False, check_sqf=False):\n", + " \"\"\"\n", + " Refine an isolating interval of a root to the given precision.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 3, x).refine_root(1, 2, eps=1e-2)\n", + " (19/11, 26/15)\n", + "\n", + " \"\"\"\n", + " if check_sqf and not f.is_sqf:\n", + " raise PolynomialError(\"only square-free polynomials supported\")\n", + "\n", + " s, t = QQ.convert(s), QQ.convert(t)\n", + "\n", + " if eps is not None:\n", + " eps = QQ.convert(eps)\n", + "\n", + " if eps <= 0:\n", + " raise ValueError(\"'eps' must be a positive rational\")\n", + "\n", + " if steps is not None:\n", + " steps = int(steps)\n", + " elif eps is None:\n", + " steps = 1\n", + "\n", + " if hasattr(f.rep, 'refine_root'):\n", + " S, T = f.rep.refine_root(s, t, eps=eps, steps=steps, fast=fast)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'refine_root')\n", + "\n", + " return QQ.to_sympy(S), QQ.to_sympy(T)\n", + "\n", + " def count_roots(f, inf=None, sup=None):\n", + " \"\"\"\n", + " Return the number of roots of ``f`` in ``[inf, sup]`` interval.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly, I\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**4 - 4, x).count_roots(-3, 3)\n", + " 2\n", + " >>> Poly(x**4 - 4, x).count_roots(0, 1 + 3*I)\n", + " 1\n", + "\n", + " \"\"\"\n", + " inf_real, sup_real = True, True\n", + "\n", + " if inf is not None:\n", + " inf = sympify(inf)\n", + "\n", + " if inf is S.NegativeInfinity:\n", + " inf = None\n", + " else:\n", + " re, im = inf.as_real_imag()\n", + "\n", + " if not im:\n", + " inf = QQ.convert(inf)\n", + " else:\n", + " inf, inf_real = list(map(QQ.convert, (re, im))), False\n", + "\n", + " if sup is not None:\n", + " sup = sympify(sup)\n", + "\n", + " if sup is S.Infinity:\n", + " sup = None\n", + " else:\n", + " re, im = sup.as_real_imag()\n", + "\n", + " if not im:\n", + " sup = QQ.convert(sup)\n", + " else:\n", + " sup, sup_real = list(map(QQ.convert, (re, im))), False\n", + "\n", + " if inf_real and sup_real:\n", + " if hasattr(f.rep, 'count_real_roots'):\n", + " count = f.rep.count_real_roots(inf=inf, sup=sup)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'count_real_roots')\n", + " else:\n", + " if inf_real and inf is not None:\n", + " inf = (inf, QQ.zero)\n", + "\n", + " if sup_real and sup is not None:\n", + " sup = (sup, QQ.zero)\n", + "\n", + " if hasattr(f.rep, 'count_complex_roots'):\n", + " count = f.rep.count_complex_roots(inf=inf, sup=sup)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'count_complex_roots')\n", + "\n", + " return Integer(count)\n", + "\n", + " def root(f, index, radicals=True):\n", + " \"\"\"\n", + " Get an indexed root of a polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = Poly(2*x**3 - 7*x**2 + 4*x + 4)\n", + "\n", + " >>> f.root(0)\n", + " -1/2\n", + " >>> f.root(1)\n", + " 2\n", + " >>> f.root(2)\n", + " 2\n", + " >>> f.root(3)\n", + " Traceback (most recent call last):\n", + " ...\n", + " IndexError: root index out of [-3, 2] range, got 3\n", + "\n", + " >>> Poly(x**5 + x + 1).root(0)\n", + " CRootOf(x**3 - x**2 + 1, 0)\n", + "\n", + " \"\"\"\n", + " return sympy.polys.rootoftools.rootof(f, index, radicals=radicals)\n", + "\n", + " def real_roots(f, multiple=True, radicals=True):\n", + " \"\"\"\n", + " Return a list of real roots with multiplicities.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**3 - 7*x**2 + 4*x + 4).real_roots()\n", + " [-1/2, 2, 2]\n", + " >>> Poly(x**3 + x + 1).real_roots()\n", + " [CRootOf(x**3 + x + 1, 0)]\n", + "\n", + " \"\"\"\n", + " reals = sympy.polys.rootoftools.CRootOf.real_roots(f, radicals=radicals)\n", + "\n", + " if multiple:\n", + " return reals\n", + " else:\n", + " return group(reals, multiple=False)\n", + "\n", + " def all_roots(f, multiple=True, radicals=True):\n", + " \"\"\"\n", + " Return a list of real and complex roots with multiplicities.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**3 - 7*x**2 + 4*x + 4).all_roots()\n", + " [-1/2, 2, 2]\n", + " >>> Poly(x**3 + x + 1).all_roots()\n", + " [CRootOf(x**3 + x + 1, 0),\n", + " CRootOf(x**3 + x + 1, 1),\n", + " CRootOf(x**3 + x + 1, 2)]\n", + "\n", + " \"\"\"\n", + " roots = sympy.polys.rootoftools.CRootOf.all_roots(f, radicals=radicals)\n", + "\n", + " if multiple:\n", + " return roots\n", + " else:\n", + " return group(roots, multiple=False)\n", + "\n", + " def nroots(f, n=15, maxsteps=50, cleanup=True):\n", + " \"\"\"\n", + " Compute numerical approximations of roots of ``f``.\n", + "\n", + " Parameters\n", + " ==========\n", + "\n", + " n ... the number of digits to calculate\n", + " maxsteps ... the maximum number of iterations to do\n", + "\n", + " If the accuracy `n` cannot be reached in `maxsteps`, it will raise an\n", + " exception. You need to rerun with higher maxsteps.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 3).nroots(n=15)\n", + " [-1.73205080756888, 1.73205080756888]\n", + " >>> Poly(x**2 - 3).nroots(n=30)\n", + " [-1.73205080756887729352744634151, 1.73205080756887729352744634151]\n", + "\n", + " \"\"\"\n", + " from sympy.functions.elementary.complexes import sign\n", + " if f.is_multivariate:\n", + " raise MultivariatePolynomialError(\n", + " \"can't compute numerical roots of %s\" % f)\n", + "\n", + " if f.degree() <= 0:\n", + " return []\n", + "\n", + " # For integer and rational coefficients, convert them to integers only\n", + " # (for accuracy). Otherwise just try to convert the coefficients to\n", + " # mpmath.mpc and raise an exception if the conversion fails.\n", + " if f.rep.dom is ZZ:\n", + " coeffs = [int(coeff) for coeff in f.all_coeffs()]\n", + " elif f.rep.dom is QQ:\n", + " denoms = [coeff.q for coeff in f.all_coeffs()]\n", + " from sympy.core.numbers import ilcm\n", + " fac = ilcm(*denoms)\n", + " coeffs = [int(coeff*fac) for coeff in f.all_coeffs()]\n", + " else:\n", + " coeffs = [coeff.evalf(n=n).as_real_imag()\n", + " for coeff in f.all_coeffs()]\n", + " try:\n", + " coeffs = [mpmath.mpc(*coeff) for coeff in coeffs]\n", + " except TypeError:\n", + " raise DomainError(\"Numerical domain expected, got %s\" % \\\n", + " f.rep.dom)\n", + "\n", + " dps = mpmath.mp.dps\n", + " mpmath.mp.dps = n\n", + "\n", + " try:\n", + " # We need to add extra precision to guard against losing accuracy.\n", + " # 10 times the degree of the polynomial seems to work well.\n", + " roots = mpmath.polyroots(coeffs, maxsteps=maxsteps,\n", + " cleanup=cleanup, error=False, extraprec=f.degree()*10)\n", + "\n", + " # Mpmath puts real roots first, then complex ones (as does all_roots)\n", + " # so we make sure this convention holds here, too.\n", + " roots = list(map(sympify,\n", + " sorted(roots, key=lambda r: (1 if r.imag else 0, r.real, abs(r.imag), sign(r.imag)))))\n", + " except NoConvergence:\n", + " raise NoConvergence(\n", + " 'convergence to root failed; try n < %s or maxsteps > %s' % (\n", + " n, maxsteps))\n", + " finally:\n", + " mpmath.mp.dps = dps\n", + "\n", + " return roots\n", + "\n", + " def ground_roots(f):\n", + " \"\"\"\n", + " Compute roots of ``f`` by factorization in the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**6 - 4*x**4 + 4*x**3 - x**2).ground_roots()\n", + " {0: 2, 1: 2}\n", + "\n", + " \"\"\"\n", + " if f.is_multivariate:\n", + " raise MultivariatePolynomialError(\n", + " \"can't compute ground roots of %s\" % f)\n", + "\n", + " roots = {}\n", + "\n", + " for factor, k in f.factor_list()[1]:\n", + " if factor.is_linear:\n", + " a, b = factor.all_coeffs()\n", + " roots[-b/a] = k\n", + "\n", + " return roots\n", + "\n", + " def nth_power_roots_poly(f, n):\n", + " \"\"\"\n", + " Construct a polynomial with n-th powers of roots of ``f``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = Poly(x**4 - x**2 + 1)\n", + "\n", + " >>> f.nth_power_roots_poly(2)\n", + " Poly(x**4 - 2*x**3 + 3*x**2 - 2*x + 1, x, domain='ZZ')\n", + " >>> f.nth_power_roots_poly(3)\n", + " Poly(x**4 + 2*x**2 + 1, x, domain='ZZ')\n", + " >>> f.nth_power_roots_poly(4)\n", + " Poly(x**4 + 2*x**3 + 3*x**2 + 2*x + 1, x, domain='ZZ')\n", + " >>> f.nth_power_roots_poly(12)\n", + " Poly(x**4 - 4*x**3 + 6*x**2 - 4*x + 1, x, domain='ZZ')\n", + "\n", + " \"\"\"\n", + " if f.is_multivariate:\n", + " raise MultivariatePolynomialError(\n", + " \"must be a univariate polynomial\")\n", + "\n", + " N = sympify(n)\n", + "\n", + " if N.is_Integer and N >= 1:\n", + " n = int(N)\n", + " else:\n", + " raise ValueError(\"'n' must an integer and n >= 1, got %s\" % n)\n", + "\n", + " x = f.gen\n", + " t = Dummy('t')\n", + "\n", + " r = f.resultant(f.__class__.from_expr(x**n - t, x, t))\n", + "\n", + " return r.replace(t, x)\n", + "\n", + " def cancel(f, g, include=False):\n", + " \"\"\"\n", + " Cancel common factors in a rational function ``f/g``.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**2 - 2, x).cancel(Poly(x**2 - 2*x + 1, x))\n", + " (1, Poly(2*x + 2, x, domain='ZZ'), Poly(x - 1, x, domain='ZZ'))\n", + "\n", + " >>> Poly(2*x**2 - 2, x).cancel(Poly(x**2 - 2*x + 1, x), include=True)\n", + " (Poly(2*x + 2, x, domain='ZZ'), Poly(x - 1, x, domain='ZZ'))\n", + "\n", + " \"\"\"\n", + " dom, per, F, G = f._unify(g)\n", + "\n", + " if hasattr(F, 'cancel'):\n", + " result = F.cancel(G, include=include)\n", + " else: # pragma: no cover\n", + " raise OperationNotSupported(f, 'cancel')\n", + "\n", + " if not include:\n", + " if dom.has_assoc_Ring:\n", + " dom = dom.get_ring()\n", + "\n", + " cp, cq, p, q = result\n", + "\n", + " cp = dom.to_sympy(cp)\n", + " cq = dom.to_sympy(cq)\n", + "\n", + " return cp/cq, per(p), per(q)\n", + " else:\n", + " return tuple(map(per, result))\n", + "\n", + " @property\n", + " def is_zero(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a zero polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(0, x).is_zero\n", + " True\n", + " >>> Poly(1, x).is_zero\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_zero\n", + "\n", + " @property\n", + " def is_one(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a unit polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(0, x).is_one\n", + " False\n", + " >>> Poly(1, x).is_one\n", + " True\n", + "\n", + " \"\"\"\n", + " return f.rep.is_one\n", + "\n", + " @property\n", + " def is_sqf(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a square-free polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 - 2*x + 1, x).is_sqf\n", + " False\n", + " >>> Poly(x**2 - 1, x).is_sqf\n", + " True\n", + "\n", + " \"\"\"\n", + " return f.rep.is_sqf\n", + "\n", + " @property\n", + " def is_monic(f):\n", + " \"\"\"\n", + " Returns ``True`` if the leading coefficient of ``f`` is one.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x + 2, x).is_monic\n", + " True\n", + " >>> Poly(2*x + 2, x).is_monic\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_monic\n", + "\n", + " @property\n", + " def is_primitive(f):\n", + " \"\"\"\n", + " Returns ``True`` if GCD of the coefficients of ``f`` is one.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(2*x**2 + 6*x + 12, x).is_primitive\n", + " False\n", + " >>> Poly(x**2 + 3*x + 6, x).is_primitive\n", + " True\n", + "\n", + " \"\"\"\n", + " return f.rep.is_primitive\n", + "\n", + " @property\n", + " def is_ground(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is an element of the ground domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x, x).is_ground\n", + " False\n", + " >>> Poly(2, x).is_ground\n", + " True\n", + " >>> Poly(y, x).is_ground\n", + " True\n", + "\n", + " \"\"\"\n", + " return f.rep.is_ground\n", + "\n", + " @property\n", + " def is_linear(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is linear in all its variables.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x + y + 2, x, y).is_linear\n", + " True\n", + " >>> Poly(x*y + 2, x, y).is_linear\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_linear\n", + "\n", + " @property\n", + " def is_quadratic(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is quadratic in all its variables.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x*y + 2, x, y).is_quadratic\n", + " True\n", + " >>> Poly(x*y**2 + 2, x, y).is_quadratic\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_quadratic\n", + "\n", + " @property\n", + " def is_monomial(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is zero or has only one term.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(3*x**2, x).is_monomial\n", + " True\n", + " >>> Poly(3*x**2 + 1, x).is_monomial\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_monomial\n", + "\n", + " @property\n", + " def is_homogeneous(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a homogeneous polynomial.\n", + "\n", + " A homogeneous polynomial is a polynomial whose all monomials with\n", + " non-zero coefficients have the same total degree. If you want not\n", + " only to check if a polynomial is homogeneous but also compute its\n", + " homogeneous order, then use :func:`Poly.homogeneous_order`.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + x*y, x, y).is_homogeneous\n", + " True\n", + " >>> Poly(x**3 + x*y, x, y).is_homogeneous\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_homogeneous\n", + "\n", + " @property\n", + " def is_irreducible(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` has no factors over its domain.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> Poly(x**2 + x + 1, x, modulus=2).is_irreducible\n", + " True\n", + " >>> Poly(x**2 + 1, x, modulus=2).is_irreducible\n", + " False\n", + "\n", + " \"\"\"\n", + " return f.rep.is_irreducible\n", + "\n", + " @property\n", + " def is_univariate(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a univariate polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + x + 1, x).is_univariate\n", + " True\n", + " >>> Poly(x*y**2 + x*y + 1, x, y).is_univariate\n", + " False\n", + " >>> Poly(x*y**2 + x*y + 1, x).is_univariate\n", + " True\n", + " >>> Poly(x**2 + x + 1, x, y).is_univariate\n", + " False\n", + "\n", + " \"\"\"\n", + " return len(f.gens) == 1\n", + "\n", + " @property\n", + " def is_multivariate(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a multivariate polynomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x, y\n", + "\n", + " >>> Poly(x**2 + x + 1, x).is_multivariate\n", + " False\n", + " >>> Poly(x*y**2 + x*y + 1, x, y).is_multivariate\n", + " True\n", + " >>> Poly(x*y**2 + x*y + 1, x).is_multivariate\n", + " False\n", + " >>> Poly(x**2 + x + 1, x, y).is_multivariate\n", + " True\n", + "\n", + " \"\"\"\n", + " return len(f.gens) != 1\n", + "\n", + " @property\n", + " def is_cyclotomic(f):\n", + " \"\"\"\n", + " Returns ``True`` if ``f`` is a cyclotomic polnomial.\n", + "\n", + " Examples\n", + " ========\n", + "\n", + " >>> from sympy import Poly\n", + " >>> from sympy.abc import x\n", + "\n", + " >>> f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1\n", + "\n", + " >>> Poly(f).is_cyclotomic\n", + " False\n", + "\n", + " >>> g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1\n", + "\n", + " >>> Poly(g).is_cyclotomic\n", + " True\n", + "\n", + " \"\"\"\n", + " return f.rep.is_cyclotomic\n", + "\n", + " def __abs__(f):\n", + " return f.abs()\n", + "\n", + " def __neg__(f):\n", + " return f.neg()\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __add__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return f.as_expr() + g\n", + "\n", + " return f.add(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __radd__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return g + f.as_expr()\n", + "\n", + " return g.add(f)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __sub__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return f.as_expr() - g\n", + "\n", + " return f.sub(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rsub__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return g - f.as_expr()\n", + "\n", + " return g.sub(f)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __mul__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return f.as_expr()*g\n", + "\n", + " return f.mul(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rmul__(f, g):\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, *f.gens)\n", + " except PolynomialError:\n", + " return g*f.as_expr()\n", + "\n", + " return g.mul(f)\n", + "\n", + " @_sympifyit('n', NotImplemented)\n", + " def __pow__(f, n):\n", + " if n.is_Integer and n >= 0:\n", + " return f.pow(n)\n", + " else:\n", + " return f.as_expr()**n\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __divmod__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return f.div(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rdivmod__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return g.div(f)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __mod__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return f.rem(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rmod__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return g.rem(f)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __floordiv__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return f.quo(g)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rfloordiv__(f, g):\n", + " if not g.is_Poly:\n", + " g = f.__class__(g, *f.gens)\n", + "\n", + " return g.quo(f)\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __div__(f, g):\n", + " return f.as_expr()/g.as_expr()\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __rdiv__(f, g):\n", + " return g.as_expr()/f.as_expr()\n", + "\n", + " __truediv__ = __div__\n", + " __rtruediv__ = __rdiv__\n", + "\n", + " @_sympifyit('other', NotImplemented)\n", + " def __eq__(self, other):\n", + " f, g = self, other\n", + "\n", + " if not g.is_Poly:\n", + " try:\n", + " g = f.__class__(g, f.gens, domain=f.get_domain())\n", + " except (PolynomialError, DomainError, CoercionFailed):\n", + " return False\n", + "\n", + " if f.gens != g.gens:\n", + " return False\n", + "\n", + " if f.rep.dom != g.rep.dom:\n", + " try:\n", + " dom = f.rep.dom.unify(g.rep.dom, f.gens)\n", + " except UnificationFailed:\n", + " return False\n", + "\n", + " f = f.set_domain(dom)\n", + " g = g.set_domain(dom)\n", + "\n", + " return f.rep == g.rep\n", + "\n", + " @_sympifyit('g', NotImplemented)\n", + " def __ne__(f, g):\n", + " return not f == g\n", + "\n", + " def __nonzero__(f):\n", + " return not f.is_zero\n", + "\n", + " __bool__ = __nonzero__\n", + "\n", + " def eq(f, g, strict=False):\n", + " if not strict:\n", + " return f == g\n", + " else:\n", + " return f._strict_eq(sympify(g))\n", + "\n", + " def ne(f, g, strict=False):\n", + " return not f.eq(g, strict=strict)\n", + "\n", + " def _strict_eq(f, g):\n", + " return isinstance(g, f.__class__) and f.gens == g.gens and f.rep.eq(g.rep, strict=True)\n", + "\n" + ] + } + ], + "source": [ + "source(Poly)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x + \\sqrt{x}, \\sqrt{x}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly({1:1,2:1},gens=S('sqrt(x)'))" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle - x + \\sqrt{x^{2}}$" + ], + "text/plain": [ + "-x + sqrt(x**2)" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x=symbols('x', positive=True)\n", + "S('sqrt(x^2)-x')" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"Poly((sqrt(x))**4 + (sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')\"" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "str(Poly({1:1,2:1,4:1},gens=S('sqrt(x)')))" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\"Poly(x**2 + x + (sqrt(x)), x, sqrt(x), domain='ZZ')\"" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "str(Poly('x^2+x+sqrt(x)'))" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $a\\to b+y_{1}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $b\\to c+z_{1}$" ], "text/plain": [ "" @@ -2001,7 +6407,7 @@ { "data": { "text/plain": [ - "(2.5326984818340415e-10, 7.129450063690368, 1.7908873553542452e-10)" + "(1.7908873553542452e-10, 2.5326984818340415e-10, 7.129450063690368)" ] }, "metadata": {}, @@ -2010,10 +6416,10 @@ { "data": { "text/plain": [ - "1.4142142855953455" + "2.5119572187973787e-11" ] }, - "execution_count": 36, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } @@ -2043,9 +6449,53 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $a\\to b+e_{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "Substitute $b\\to c+f_{2}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n", + "100 loops, best of 5: 8.66 ms per loop\n", + "1000 loops, best of 5: 1.31 ms per loop\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from random import random\n", "formula=cyclize(Sm('((a-b)/c)^2-8**(1/2)*(a-b)/c'))\n", @@ -2060,7 +6510,7 @@ "def evaluate(x):\n", " return newformula.evalf(subs=dict(zip(fs,(1,1,1))))\n", "def evaluate2(x):\n", - " return num1.evalf(dict(zip(fs,x)))/num2.eval(dict(zip(fs,x)))\n", + " return num1.eval(dict(zip(fs,x)))/num2.eval(dict(zip(fs,x)))\n", "#display(num2.eval(dict(zip(fs,(1,1,1)))))\n", "print('ok')\n", "%timeit evaluate((random(),random(),random()))\n", @@ -2095,18 +6545,43 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\sqrt{x} + x$" + ], + "text/plain": [ + "sqrt(x) + x" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "(Poly({1:1,2:1,4:1},gens=S('sqrt(x)'))-Poly('x^2')).as_expr()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(x*(1 - x), [])" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from sympy.solvers.solvers import unrad\n", "unrad('sqrt(x)+x')" @@ -2114,9 +6589,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 56, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "formula=('x^(2/3)+x^(3/4)+sqrt(x+y)')\n", "type((Poly(formula).gens[1]).args[0])==Symbol" @@ -2124,18 +6610,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(x, 1/2)" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "S('sqrt(x)').args" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "invalid syntax (, line 12)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m12\u001b[0m\n\u001b[0;31m newgens[gen[0]]=\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n" + ] + } + ], "source": [ "def _powr(formula):\n", "\tif formula.func==Pow:\n", @@ -2155,27 +6661,63 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 59, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "isinstance(S('1'),Rational)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 60, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "6 in {3:4,5:6}" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 1$" + ], + "text/plain": [ + "1" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "from math import *\n", "from sympy import *\n", @@ -2184,36 +6726,88 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x^{2 \\pi}, x^{\\pi}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((x**pi)**2, x**pi, domain='ZZ')" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "Poly('x^(2*pi)')" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 63, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{1}{8}$" + ], + "text/plain": [ + "1/8" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "gcd(S('1/8'),S('1/4'))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(3, (x, sqrt(2)))" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "S('sqrt(2)*3*x').as_coeff_mul()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Poly((sqrt(x))**4 + (sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ')\n", + "Poly((x**(1/6))**12 + (x**(1/6))**3 + (x**(1/6))**2 + y**2, x**(1/6), y, domain='ZZ')\n", + "Poly((sqrt(x)) + (sqrt(x*z)) + (sqrt(z)), sqrt(x), sqrt(x*z), sqrt(z), domain='ZZ')\n", + "Poly((sqrt(x))*(sqrt(z)) + (sqrt(x)) + (sqrt(z)), sqrt(x), sqrt(z), domain='ZZ')\n", + "Poly((sqrt(t + z)) + (sqrt(t*x + t*y + x*z + y*z)) + (sqrt(x + y)), sqrt(t + z), sqrt(t*x + t*y + x*z + y*z), sqrt(x + y), domain='ZZ')\n", + "Poly((sqrt(2)) + (sqrt(3)) + (sqrt(6)), sqrt(2), sqrt(3), sqrt(6), domain='ZZ')\n" + ] + } + ], "source": [ "def _powr(formula):\n", "\tif formula.func==Pow:\n", @@ -2355,13 +6949,419 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from shiroindev import *\n", + "formula=S('(a+b-c)^2')\n", + "prove(makesubs(formula,'[c,oo]'))\n", + "prove(makesubs(formula,'[a,oo]',variables='c'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=S('(a+b-d)^2+(a+b-c)^2')\n", + "prove(makesubs(formula,'[a+b,oo],[a+b,oo]',variables='c,d'))\n", + "prove(makesubs(formula,'[0,a+b],[a+b,oo]',variables='c,d'))\n", + "prove(makesubs(formula,'[0,a+b],[0,a+b]',variables='c,d'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "findvalues(formula)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "display(cyclize('((a-b)/c)^2'))\n", + "display(S('sqrt(8)')*cyclize('(a-b)/c'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", + "display(Latex('Case $a\\ge c\\ge b$'))\n", + "formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')\n", + "prove(formula1)\n", + "display(Latex('Case $a\\ge b\\ge c$'))\n", + "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", + "prove(formula2*4,values='2**(1/2),1,1')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", + "formula2=makesubs(formula,'[c,oo],[c,oo]')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "findvalues(formula2,values=[5,2,7])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x,y=symbols('x,y')\n", + "ask(Q.positive(x**2+1),Q.real(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "formula=Sm('(a^2+b^2+c^2)^2- 3(a^3b+b^3c+c^3a)')\n", + "formula1=makesubs(formula,'[b,oo],[c,oo]',variables='a,b')\n", + "formula2=makesubs(formula,'[c,oo],[b,oo]',variables='a,c')\n", + "prove(formula2)\n", + "print(findvalues(formula1))\n", + "#prove(formula1,values='4*b*(1-b)-1,4*c*(1-c)-1,1')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "makesubs(Sm('a^2-2ab+bc-c^2+ca'),'[c,oo],[a,oo]',variables='b,c')" + ] + }, + { + "cell_type": "code", + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "$\\displaystyle - \\sqrt{x} \\sqrt{y} + \\sqrt{x y}$" + ], + "text/plain": [ + "-sqrt(x)*sqrt(y) + sqrt(x*y)" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 0$" + ], + "text/plain": [ + "0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "\n", + "formula=S('sqrt(x*y)-sqrt(x)*sqrt(y)')\n", + "display(formula)\n", + "def assumeall(formula,**kwargs):\n", + " formula=S(formula)\n", + " fs=formula.free_symbols\n", + " for x in fs:\n", + " y=Symbol(str(x),**kwargs)\n", + " formula=formula.subs(x,y)\n", + " return formula\n", + "display(assumeall(formula,positive=True))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Poly(assumeall('x+sqrt(x)',positive=True))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "str(type(S('f1(x,y,z)')))=='f1'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ReprPrinter?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "srepr(S('x^2+f(x)+f(x,y)+f()+sqrt(y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sympy import Function,srepr,S\n", + "import re\n", + "f=Function('f')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def allsymbols(formula):\n", + " formula=S(formula)\n", + " funcsymbols=[x[10:-2] for x in re.findall(r\"Function\\(\\'.*?\\'\\)\",srepr(formula))]\n", + " return set(funcsymbols)|set(map(str,formula.free_symbols))\n", + "def vargen(n):\n", + " x='abcdefghijklmnopqrstuvwxyz'[n%26]\n", + " if n>=26:\n", + " x+=str(n//26)\n", + " return x\n", + "allsymbols(S('f(5,7)+f(5)+g(8)+sqrt(x*y)'))\n", + "vargen(36)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from sympy import *\n", + "from sympy.printing.repr import *\n", + "ReprPrinter??" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "{5,7} | {8,7}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "[x[10:-2] for x in re.findall(r\"Function\\(\\'.*?\\'\\)\",srepr(S('x^2')))]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "S('f(5,7)+f(5)+g(8)+sqrt(x*y)')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "srepr(S('f(5,7)+f(5)+g(8)+sqrt(x*y)'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "display(Latex('$'+str(S('z12345'))+'$'))" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: ''", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;34m'xyz'\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m''\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: ''" + ] + } + ], + "source": [ + "'xyz'[-2::]" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": {}, + "outputs": [], + "source": [ + "def sortkey(x):\n", + " x=str(x)\n", + " i=len(x)-1\n", + " while i>=0:\n", + " if x[i] not in '0123456789':\n", + " break\n", + " i-=1\n", + " if i==len(x)-1:\n", + " return (-1,x)\n", + " return (int(x[i+1:]),x[:i+1])" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[x, y, x0, qq1, z1, t2]" + ] + }, + "execution_count": 85, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sorted(S('x,y,z1,t2,qq1,x0'),key=sortkey)" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.154701\n", + " Iterations: 85\n", + " Function evaluations: 152\n" + ] + }, + { + "data": { + "text/plain": [ + "[1.0,\n", + " 3.000209557356011,\n", + " 3.9998018341331227,\n", + " 2.9997236704279775,\n", + " 0.999903278712487]" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2')\n", + "formula=S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2- (x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')\n", + "values=findvalues(formula)\n", + "values=[value/values[0] for value in values]\n", + "[value**2 for value in values]" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{2 \\sqrt{3}}{3}$" + ], + "text/plain": [ + "2*sqrt(3)/3" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "formula1=S('(x_1^2+x_2^2+x_3^2+x_4^2+x_5^2)/(x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')\n", + "formula1.subs(S('[[x_1,1],[x_2,sqrt(3)],[x_3,2],[x_4,sqrt(3)],[x_5,1]]'))" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "formula2=S('x_1^2+x_2^2+x_3^2+x_4^2+x_5^2- (2/sqrt(3))*(x_1*x_2+x_2*x_3+x_3*x_4+x_4*x_5)')" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "Substitute $x_{2}\\to \\sqrt{3} g$" ], "text/plain": [ "" @@ -2373,7 +7373,7 @@ { "data": { "text/latex": [ - "numerator: $a^2+2ab+b^2$" + "Substitute $x_{3}\\to 2 h$" ], "text/plain": [ "" @@ -2385,7 +7385,7 @@ { "data": { "text/latex": [ - "denominator: $1$" + "Substitute $x_{4}\\to \\sqrt{3} i$" ], "text/plain": [ "" @@ -2397,55 +7397,7 @@ { "data": { "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le a^2+2ab+b^2 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $c\\to a+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "numerator: $b^2-2bc+c^2$" + "numerator: $3 g^{2} - 4 g h - 2 g x_{1} + 4 h^{2} - 4 h i + 3 i^{2} - 2 i x_{5} + x_{1}^{2} + x_{5}^{2}$" ], "text/plain": [ "" @@ -2493,7 +7445,43 @@ { "data": { "text/latex": [ - "$$2bc \\le b^2+c^2$$" + "$$4 g h \\le 2 g^{2}+2 h^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 g x_{1} \\le g^{2}+x_{1}^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$4 h i \\le 2 h^{2}+2 i^{2}$$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$2 i x_{5} \\le i^{2}+x_{5}^{2}$$" ], "text/plain": [ "" @@ -2532,51 +7520,108 @@ "0" ] }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "prove(formula2,values='1,sqrt(3),2,sqrt(3),1')" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{k}a^{n}, a^{k}, a^{n}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((a**k)*(a**n), a**k, a**n, domain='ZZ')" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('a^(n+k)')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'FiniteSet' object has no attribute 'as_coeff_Mul'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'a^{n+k}/{b^n}+{b^{n+k}}/{c^n}+{c^{n+k}}/{a^n}-( a^k+b^k+c^k)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/sympify.py\u001b[0m in \u001b[0;36msympify\u001b[0;34m(a, locals, convert_xor, strict, rational, evaluate)\u001b[0m\n\u001b[1;32m 382\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 383\u001b[0m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreplace\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'\\n'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 384\u001b[0;31m \u001b[0mexpr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparse_expr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_dict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mlocals\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtransformations\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtransformations\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mevaluate\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mevaluate\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 385\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mTokenError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mSyntaxError\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 386\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mSympifyError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'could not parse %r'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/parsing/sympy_parser.py\u001b[0m in \u001b[0;36mparse_expr\u001b[0;34m(s, local_dict, transformations, global_dict, evaluate)\u001b[0m\n\u001b[1;32m 964\u001b[0m \u001b[0mcode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcompile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mevaluateFalse\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'eval'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 965\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 966\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0meval_expr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_dict\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mglobal_dict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 967\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 968\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/parsing/sympy_parser.py\u001b[0m in \u001b[0;36meval_expr\u001b[0;34m(code, local_dict, global_dict)\u001b[0m\n\u001b[1;32m 877\u001b[0m \"\"\"\n\u001b[1;32m 878\u001b[0m expr = eval(\n\u001b[0;32m--> 879\u001b[0;31m code, global_dict, local_dict) # take local objects in preference\n\u001b[0m\u001b[1;32m 880\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 881\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mexpr\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/expr.py\u001b[0m in \u001b[0;36m__pow__\u001b[0;34m(self, other, mod)\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmod\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_pow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 166\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[0m_self\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mas_int\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmod\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py\u001b[0m in \u001b[0;36m__sympifyit_wrapper\u001b[0;34m(a, b)\u001b[0m\n\u001b[1;32m 89\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'_op_priority'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 90\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msympify\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstrict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 91\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 92\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mSympifyError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mretval\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/decorators.py\u001b[0m in \u001b[0;36mbinary_op_wrapper\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 127\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mf\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 128\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 129\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 130\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mbinary_op_wrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 131\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mpriority_decorator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/expr.py\u001b[0m in \u001b[0;36m_pow\u001b[0;34m(self, other)\u001b[0m\n\u001b[1;32m 159\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mcall_highest_priority\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'__rpow__'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 160\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_pow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 161\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mPow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 162\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__pow__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mother\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmod\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/cache.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 93\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 94\u001b[0;31m \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 95\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 96\u001b[0m \u001b[0mretval\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/core/power.py\u001b[0m in \u001b[0;36m__new__\u001b[0;34m(cls, b, e, evaluate)\u001b[0m\n\u001b[1;32m 274\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_Atom\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mb\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mS\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mExp1\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexp_polar\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 275\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0msympy\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdenom\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlog\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msign\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mim\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfactor_terms\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 276\u001b[0;31m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mex\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfactor_terms\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msign\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mas_coeff_Mul\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 277\u001b[0m \u001b[0mden\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdenom\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mex\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 278\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mden\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlog\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mden\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0mb\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: 'FiniteSet' object has no attribute 'as_coeff_Mul'" + ] + } + ], + "source": [ + "S('a^{n+k}/{b^n}+{b^(n+k)/(c^n)+c^(n+k)/{a^n}-( a^k+b^k+c^k)')" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'767980716'" + ] + }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "from shiroindev import *\n", - "formula=S('(a+b-c)^2')\n", - "prove(makesubs(formula,'[c,oo]'))\n", - "prove(makesubs(formula,'[a,oo]',variables='c'))" + "import re\n", + "s=r\"\"\"99-my-name-is-John-Smith-6376827-%^-1-2-767980716\"\"\"\n", + "re.compile(r\"^(.*?)-\").search(str(s[::-1])).group(1)[::-1]" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 3, "metadata": {}, "outputs": [ { - "data": { - "text/latex": [ - "Substitute $c\\to a+b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] }, { "data": { "text/latex": [ - "Substitute $d\\to a+b+d$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "numerator: $c^2+d^2$" + "numerator: $a^{k} a^{2 n} c^{n} - a^{k} a^{n} b^{n} c^{n} + a^{n} b^{k} b^{2 n} - a^{n} b^{k} b^{n} c^{n} - a^{n} b^{n} c^{k} c^{n} + b^{n} c^{k} c^{2 n}$" ], "text/plain": [ "" @@ -2600,7 +7645,7 @@ { "data": { "text/latex": [ - "status: 0" + "status: 2" ], "text/plain": [ "" @@ -2612,7 +7657,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le c^2+d^2 $$" + "Program couldn't find any proof." ], "text/plain": [ "" @@ -2624,7 +7669,7 @@ { "data": { "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." + "$$ a^{k} a^{n} b^{n} c^{n}+a^{n} b^{k} b^{n} c^{n}+a^{n} b^{n} c^{k} c^{n} \\le a^{k} a^{2 n} c^{n}+a^{n} b^{k} b^{2 n}+b^{n} c^{k} c^{2 n} $$" ], "text/plain": [ "" @@ -2636,7 +7681,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to a+b+(-a-b)/(c+1)$" + "Substitute $n\\to d + k$" ], "text/plain": [ "" @@ -2648,7 +7693,7 @@ { "data": { "text/latex": [ - "Substitute $d\\to a+b+d$" + "numerator: $a^{2 d} a^{3 k} c^{d} c^{k} - a^{d} a^{2 k} b^{d} b^{k} c^{d} c^{k} + a^{d} a^{k} b^{2 d} b^{3 k} - a^{d} a^{k} b^{d} b^{2 k} c^{d} c^{k} - a^{d} a^{k} b^{d} b^{k} c^{d} c^{2 k} + b^{d} b^{k} c^{2 d} c^{3 k}$" ], "text/plain": [ "" @@ -2660,7 +7705,7 @@ { "data": { "text/latex": [ - "numerator: $a^2+2ab+b^2+c^2d^2+2cd^2+d^2$" + "denominator: $1$" ], "text/plain": [ "" @@ -2672,7 +7717,7 @@ { "data": { "text/latex": [ - "denominator: $c^2+2c+1$" + "status: 2" ], "text/plain": [ "" @@ -2681,6 +7726,230 @@ "metadata": {}, "output_type": "display_data" }, + { + "data": { + "text/latex": [ + "Program couldn't find any proof." + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "$$ a^{d} a^{2 k} b^{d} b^{k} c^{d} c^{k}+a^{d} a^{k} b^{d} b^{2 k} c^{d} c^{k}+a^{d} a^{k} b^{d} b^{k} c^{d} c^{2 k} \\le a^{2 d} a^{3 k} c^{d} c^{k}+a^{d} a^{k} b^{2 d} b^{3 k}+b^{d} b^{k} c^{2 d} c^{3 k} $$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from sympy import *\n", + "from sympy.parsing.latex import parse_latex\n", + "from shiroindev import *\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))\n", + "formula=expand(parse_latex(r'(\\frac{a^{n+k}}{b^n}+\\frac{b^{n+k}}{c^n}+\\frac{c^{n+k}}{a^n}-( a^k+b^k+c^k))*a^nb^nc^n'))\n", + "newproof()\n", + "prove(formula)\n", + "prove(makesubs(formula,['k',oo],variables='n'))" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 6 x^{3}y^{9} + 5 x^{2}y^{7} + 4 xy^{8}, x, y, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(6*x**3*y**9 + 5*x**2*y**7 + 4*x*y**8, x, y, domain='ZZ')" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly(dict(zip([(1,8),(2,7),(3,9)],[4,5,6])),gens=S('x,y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\sqrt{x} + x^{2} + x$" + ], + "text/plain": [ + "sqrt(x) + x**2 + x" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly({1:1,2:1,4:1},gens=S('sqrt(x)')).as_expr()" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [], + "source": [ + "def _writ2(coef,fun,variables):\n", + "\treturn latex(Poly(dict(zip(fun,coef)),gens=variables).as_expr())" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'8 x^{3} y^{4} + 7 x y^{2}'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "_writ2([7,8],[(1,2),(3,4)],S('x,y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle 2 a b$" + ], + "text/plain": [ + "2*(a*b)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse_latex(r' a^2+b^2\\geq 2ab').rhs" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n", + "ANTLR runtime and generated code versions disagree: 4.8!=4.7.1\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle a^{2} + b^{2}$" + ], + "text/plain": [ + "a**2 + b**2" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "parse_latex(r'2ab \\geq a^2+b^2').rhs" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "numerator: $a d + a f + b c + b e + c f + d e - 2 \\sqrt{a b} \\sqrt{c d} - 2 \\sqrt{a b} \\sqrt{e f} - 2 \\sqrt{c d} \\sqrt{e f}$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/latex": [ + "denominator: $1$" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Poly((sqrt(a))**2*(sqrt(d))**2 + (sqrt(a))**2*(sqrt(f))**2 - 2*(sqrt(a))*(sqrt(b))*(sqrt(c))*(sqrt(d)) - 2*(sqrt(a))*(sqrt(b))*(sqrt(e))*(sqrt(f)) + (sqrt(b))**2*(sqrt(c))**2 + (sqrt(b))**2*(sqrt(e))**2 + (sqrt(c))**2*(sqrt(f))**2 - 2*(sqrt(c))*(sqrt(d))*(sqrt(e))*(sqrt(f)) + (sqrt(d))**2*(sqrt(e))**2, sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='ZZ')\n", + "Poly((sqrt(a))**2*(sqrt(d))**2 + (sqrt(a))**2*(sqrt(f))**2 + (sqrt(b))**2*(sqrt(c))**2 + (sqrt(b))**2*(sqrt(e))**2 + (sqrt(c))**2*(sqrt(f))**2 + (sqrt(d))**2*(sqrt(e))**2, sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='QQ')\n", + "Poly(2*(sqrt(a))*(sqrt(b))*(sqrt(c))*(sqrt(d)) + 2*(sqrt(a))*(sqrt(b))*(sqrt(e))*(sqrt(f)) + 2*(sqrt(c))*(sqrt(d))*(sqrt(e))*(sqrt(f)), sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='QQ')\n" + ] + }, { "data": { "text/latex": [ @@ -2696,7 +7965,7 @@ { "data": { "text/latex": [ - "$$ 0 \\le a^2+2ab+b^2+c^2d^2+2cd^2+d^2 $$" + "From weighted AM-GM inequality:" ], "text/plain": [ "" @@ -2708,7 +7977,7 @@ { "data": { "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." + "$$2 \\sqrt{a} \\sqrt{b} \\sqrt{c} \\sqrt{d} \\le a d+b c$$" ], "text/plain": [ "" @@ -2720,7 +7989,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to a+b+(-a-b)/(c+1)$" + "$$2 \\sqrt{a} \\sqrt{b} \\sqrt{e} \\sqrt{f} \\le a f+b e$$" ], "text/plain": [ "" @@ -2732,7 +8001,7 @@ { "data": { "text/latex": [ - "Substitute $d\\to a+b+(-a-b)/(d+1)$" + "$$2 \\sqrt{c} \\sqrt{d} \\sqrt{e} \\sqrt{f} \\le c f+d e$$" ], "text/plain": [ "" @@ -2744,43 +8013,7 @@ { "data": { "text/latex": [ - "numerator: $a^2c^2+2a^2c+a^2d^2+2a^2d+2a^2+2abc^2+4abc+2abd^2+4abd+4ab+b^2c^2+2b^2c+b^2d^2+2b^2d+2b^2$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $c^2d^2+2c^2d+c^2+2cd^2+4cd+2c+d^2+2d+1$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le a^2c^2+2a^2c+a^2d^2+2a^2d+2a^2+2abc^2+4abc+2abd^2+4abd+4ab+b^2c^2+2b^2c+b^2d^2+2b^2d+2b^2 $$" + "$$ 0 \\le 0 $$" ], "text/plain": [ "" @@ -2807,95 +8040,355 @@ "0" ] }, - "execution_count": 34, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "formula=S('(a+b-d)^2+(a+b-c)^2')\n", - "prove(makesubs(formula,'[a+b,oo],[a+b,oo]',variables='c,d'))\n", - "prove(makesubs(formula,'[0,a+b],[a+b,oo]',variables='c,d'))\n", - "prove(makesubs(formula,'[0,a+b],[0,a+b]',variables='c,d'))" + "fr=parse_latex(r'\\sqrt{ab}+\\sqrt{cd}+\\sqrt{ef}\\leq\\sqrt{(a+c+e)(b+d+f)}')\n", + "prove(fr.rhs**2-fr.lhs**2)" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle 0$" + ], + "text/plain": [ + "0" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "assumeall(S('sqrt(x*y)-sqrt(x)*sqrt(y)'),positive=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "ename": "GeneratorsError", + "evalue": "duplicated generators: [sqrt(x), sqrt(x)]", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mGeneratorsError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mreducegens\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'x+sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mq\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'x+sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPoly\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mp\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mPoly\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mq\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mS\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sqrt(x)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polytools.py\u001b[0m in \u001b[0;36m__new__\u001b[0;34m(cls, rep, *gens, **args)\u001b[0m\n\u001b[1;32m 107\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__new__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcls\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mrep\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 108\u001b[0m \u001b[0;34m\"\"\"Create a new polynomial instance out of something useful. \"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 109\u001b[0;31m \u001b[0mopt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0moptions\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuild_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 110\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 111\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;34m'order'\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mopt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mbuild_options\u001b[0;34m(gens, args)\u001b[0m\n\u001b[1;32m 729\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 730\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;36m1\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0;34m'opt'\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32min\u001b[0m \u001b[0margs\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mgens\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 731\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mOptions\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 732\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 733\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'opt'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, gens, args, flags, strict)\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0moption\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpreprocess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 154\u001b[0;31m \u001b[0mpreprocess_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 155\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 156\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mkey\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdefaults\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mpreprocess_options\u001b[0;34m(args)\u001b[0m\n\u001b[1;32m 150\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 151\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mvalue\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 152\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0moption\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcls\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpreprocess\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 153\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[0mpreprocess_options\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/home/grzegorz/Pobrane/SageMath/local/lib/python3.7/site-packages/sympy/polys/polyoptions.py\u001b[0m in \u001b[0;36mpreprocess\u001b[0;34m(cls, gens)\u001b[0m\n\u001b[1;32m 289\u001b[0m \u001b[0mgens\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 290\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mhas_dups\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 291\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mGeneratorsError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"duplicated generators: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 292\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0many\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgen\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_commutative\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mFalse\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mgen\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 293\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mGeneratorsError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"non-commutative generators: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgens\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mGeneratorsError\u001b[0m: duplicated generators: [sqrt(x), sqrt(x)]" + ] + } + ], + "source": [ + "p=reducegens('x+sqrt(x)')\n", + "q=S('x+sqrt(x)')\n", + "print(Poly(p,gens=[S('sqrt(x)'),S('sqrt(x)')]))\n", + "print(Poly(q,gens=S('sqrt(x)')))" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [], + "source": [ + "from importlib import reload\n", + "from sympy import *\n", + "import shiroindev\n", + "reload(shiroindev)\n", + "from shiroindev import *\n", + "from sympy.parsing.latex import parse_latex\n", + "from itertools import permutations, combinations\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x, \\sqrt{x}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((sqrt(x))**2, sqrt(x), domain='ZZ')" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('sqrt(x)')*Poly('sqrt(x)')" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 0, x, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(0, x, domain='ZZ')" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "Poly('x')-Poly('x').abs()" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( x, x, y, domain=\\mathbb{Q} \\right)}$" + ], + "text/plain": [ + "Poly(x, x, y, domain='QQ')" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "fr=Poly('x-y')\n", + "(fr+fr.abs())*(S('1/2'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from itertools import permutations \n", + "t5=[]\n", + "for ineq in ineqs2:\n", + " u=0\n", + " for vars in permutations(ineq.free_symbols):\n", + " ineqp=makesubs(ineq,list(zip(vars[1:],[oo]*len(vars[1:]))),variables=vars[:-1])\n", + " u=max(u,prove(ineqp))\n", + " print(u,end=',')\n", + " t5+=[u]\n", + "Counter(t5)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Optimization terminated successfully.\n", - " Current function value: 1.000000\n", - " Iterations: 65\n", - " Function evaluations: 124\n" + "pvalue 4.43444926375551e-06\n", + "statistic 59.0\n" ] - }, + } + ], + "source": [ + "from statsmodels.stats.contingency_tables import mcnemar\n", + "print(mcnemar([[101,121],[59,33]]))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [], + "source": [ + "nsimplify?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shiro.display=lambda x:display(Latex(x))\n", + "newproof()\n", + "fr=makesubs(ineqs2[15],'[c,oo],[a,oo]',variables='b,c')\n", + "display(fr)\n", + "fr2=fractioncancel(fr.subs(S('[[e,(sqrt(5)-1)/2*f]]')))[0]\n", + "display(fr2)\n", + "prove(makesubs(fr2,'11/5,9/4',variables=[S('sqrt(5)')]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def makesubs(formula,intervals,values=None,variables=None,numden=False):\n", + "#This function generates a new formula which satisfies this condition:\n", + "#for all positive variables new formula is nonnegative iff\n", + "#for all variables in corresponding intervals old formula is nonnegative\n", + "\tformula=S(formula)\n", + "\taddsymbols(formula)\n", + "\tintervals=_smakeiterable2(intervals)\n", + "\tif variables: variables=_smakeiterable(variables)\n", + "\telse: variables=sorted(formula.free_symbols,key=str)\n", + "\tif values!=None:\n", + "\t\tvalues=_smakeiterable(values)\n", + "\t\tequations=[var-value for var,value in zip(variables,values)]\n", + "\telse:\n", + "\t\tequations=[]\n", + "\tnewvars=[]\n", + "\tusedvars=set()\n", + "\tfor var,interval in zip(variables,intervals):\n", + "\t\tend1,end2=interval\n", + "\t\tz=newvar()\n", + "\t\tnewvars+=[z]\n", + "\t\tusedvars|={z}\n", + "\t\tif (end1.free_symbols|end2.free_symbols)&usedvars:\n", + "\t\t\tshiro.warning(shiro.translation[\n", + "\t\t\t'Warning: intervals contain backwards dependencies. Consider changing order of variables'])\n", + "\t\tif end1 in {S('-oo'),S('oo')}:\n", + "\t\t\tend1,end2=end2,end1\n", + "\t\tif {end1,end2}=={S('-oo'),S('oo')}:\n", + "\t\t\tsub1=sub2=(z-1/z)\n", + "\t\telif end2==S('oo'):\n", + "\t\t\tsub1=sub2=(end1+z)\n", + "\t\telif end2==S('-oo'):\n", + "\t\t\tsub1=sub2=end1-z\n", + "\t\telse:\n", + "\t\t\tsub1=end2+(end1-end2)/z\n", + "\t\t\tsub2=end2+(end1-end2)/(1+z)\n", + "\t\tformula=formula.subs(var,sub1)\n", + "\t\tshiro.display(shiro.translation['Substitute']+\" $\"+latex(var)+'\\\\to '+latex(sub2)+'$')\n", + "\t\tequations=[equation.subs(var,sub1) for equation in equations]\n", + "\tnum,den=fractioncancel(formula)\n", + "\tfor var,interval in zip(newvars,intervals):\n", + "\t\tif {interval[0],interval[1]} & {S('oo'),S('-oo')}==set():\n", + "\t\t\tnum=num.subs(var,var+1)\n", + "\t\t\tden=den.subs(var,var+1)\n", + "\t\t\tequations=[equation.subs(var,var+1) for equation in equations]\n", + "\tif values:\n", + "\t\tvalues=ssolve(equations,newvars)\n", + "\t\tif len(values):\n", + "\t\t\tvalues=values[0]\n", + "\tnum,den=expand(num),expand(den)\n", + "\t#shiro.display(shiro.translation[\"Formula after substitution:\"],\"$$\",latex(num/den),'$$')\n", + "\tif values and numden:\n", + "\t\treturn num,den,values\n", + "\telif values:\n", + "\t\treturn num/den,values\n", + "\telif numden:\n", + "\t\treturn num,den\n", + "\telse:\n", + "\t\treturn num/den" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ { "data": { "text/plain": [ - "(0.8742272651582828,\n", - " 0.45912361618095604,\n", - " 1.3333325089656345,\n", - " 1.3333771594633597)" + "{3, 5, 7, 8}" ] }, - "execution_count": 27, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "findvalues(formula)" + "x={5,7,8}\n", + "x|={3}\n", + "x" ] }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { - "text/latex": [ - "$\\displaystyle \\frac{\\left(a - b\\right)^{2}}{c^{2}} + \\frac{\\left(- a + c\\right)^{2}}{b^{2}} + \\frac{\\left(b - c\\right)^{2}}{a^{2}}$" - ], "text/plain": [ - "(a - b)**2/c**2 + (-a + c)**2/b**2 + (b - c)**2/a**2" + "{x}" ] }, + "execution_count": 12, "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$\\displaystyle 2 \\sqrt{2} \\left(\\frac{a - b}{c} + \\frac{- a + c}{b} + \\frac{b - c}{a}\\right)$" - ], - "text/plain": [ - "2*sqrt(2)*((a - b)/c + (-a + c)/b + (b - c)/a)" - ] - }, - "metadata": {}, - "output_type": "display_data" + "output_type": "execute_result" } ], "source": [ - "display(cyclize('((a-b)/c)^2'))\n", - "display(S('sqrt(8)')*cyclize('(a-b)/c'))" + "from shiroindev import *\n", + "S('x+7').free_symbols" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bool(set())" + ] + }, + { + "cell_type": "code", + "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/latex": [ - "Case $a\\ge c\\ge b$" + "Substitute $x\\to - y + 1 + \\frac{y - 1}{a + 1}$" ], "text/plain": [ "" @@ -2907,7 +8400,7 @@ { "data": { "text/latex": [ - "Substitute $a\\to a+c$" + "Substitute $y\\to 1 - \\frac{1}{b + 1}$" ], "text/plain": [ "" @@ -2919,7 +8412,7 @@ { "data": { "text/latex": [ - "Substitute $c\\to b+c$" + "Substitute $b\\to \\frac{c}{2}$" ], "text/plain": [ "" @@ -2931,7 +8424,7 @@ { "data": { "text/latex": [ - "numerator: $2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4a^2bc^3+4\\sqrt{2}a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4ab^2c^3+4\\sqrt{2}ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4$" + "numerator: $a^{4} c^{2} + a^{3} c^{2} - 2 a^{3} c - 4 a^{2} c + 4 a^{2} + a c^{2} - 2 a c + c^{2}$" ], "text/plain": [ "" @@ -2943,115 +8436,7 @@ { "data": { "text/latex": [ - "denominator: $a^2b^4+2a^2b^3c+a^2b^2c^2+2ab^5+6ab^4c+6ab^3c^2+2ab^2c^3+b^6+4b^5c+6b^4c^2+4b^3c^3+b^2c^4$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "status: 0" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 2a^4b^2+2a^4bc+a^4c^2+4a^3b^3+2\\sqrt{2}a^3b^2c+10a^3b^2c+2\\sqrt{2}a^3bc^2+6a^3bc^2+2a^3c^3+2a^2b^4+2\\sqrt{2}a^2b^3c+10a^2b^3c+6\\sqrt{2}a^2b^2c^2+12a^2b^2c^2+4\\sqrt{2}a^2bc^3+4a^2bc^3+a^2c^4+2ab^4c+2\\sqrt{2}ab^3c^2+6ab^3c^2+4\\sqrt{2}ab^2c^3+4ab^2c^3+2\\sqrt{2}abc^4+2b^4c^2+4b^3c^3+2b^2c^4 $$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "The sum of all inequalities gives us a proof of the inequality." - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Case $a\\ge b\\ge c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $a\\to a+b$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $b\\to b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $a\\to \\sqrt{2}a$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "numerator: $16a^4b^2+32a^4bc+32a^4c^2+16\\sqrt{2}a^3b^3-32a^3b^2c+48\\sqrt{2}a^3b^2c-32a^3bc^2+80\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+8a^2b^4-32\\sqrt{2}a^2b^3c+32a^2b^3c-48\\sqrt{2}a^2b^2c^2+96a^2b^2c^2-16\\sqrt{2}a^2bc^3+80a^2bc^3+16a^2c^4-16ab^4c-32ab^3c^2+16\\sqrt{2}ab^3c^2-16ab^2c^3+24\\sqrt{2}ab^2c^3+8\\sqrt{2}abc^4+8b^4c^2+16b^3c^3+8b^2c^4$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "denominator: $2a^2b^2c^2+4a^2bc^3+2a^2c^4+2\\sqrt{2}ab^3c^2+6\\sqrt{2}ab^2c^3+6\\sqrt{2}abc^4+2\\sqrt{2}ac^5+b^4c^2+4b^3c^3+6b^2c^4+4bc^5+c^6$" + "denominator: $a^{3} c^{2} + 2 a^{3} c + 2 a^{2} c^{2} + 4 a^{2} c + a c^{2} + 2 a c$" ], "text/plain": [ "" @@ -3087,7 +8472,7 @@ { "data": { "text/latex": [ - "$$32a^3b^2c \\le 16a^4b^2+16a^2b^2c^2$$" + "$$2 a^{3} c \\le a^{4} c^{2}+a^{2}$$" ], "text/plain": [ "" @@ -3099,7 +8484,7 @@ { "data": { "text/latex": [ - "$$32\\sqrt{2}a^2b^3c \\le 16\\sqrt{2}a^3b^3+16\\sqrt{2}ab^3c^2$$" + "$$4 a^{2} c \\le a^{3} c^{2}+2 a^{2}+a c^{2}$$" ], "text/plain": [ "" @@ -3111,7 +8496,7 @@ { "data": { "text/latex": [ - "$$48\\sqrt{2}a^2b^2c^2 \\le 24\\sqrt{2}a^3b^2c+24\\sqrt{2}ab^2c^3$$" + "$$2 a c \\le a^{2}+c^{2}$$" ], "text/plain": [ "" @@ -3123,67 +8508,7 @@ { "data": { "text/latex": [ - "$$16\\sqrt{2}a^2bc^3 \\le 8\\sqrt{2}a^3bc^2+8\\sqrt{2}abc^4$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$16ab^4c \\le 8a^2b^4+8b^4c^2$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$32ab^3c^2 \\le 16a^2b^3c+16b^3c^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$32a^3bc^2 \\le 16a^4bc+16a^2bc^3$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$16ab^2c^3 \\le 8a^2b^2c^2+8b^2c^4$$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$$ 0 \\le 16a^4bc+32a^4c^2+24\\sqrt{2}a^3b^2c+72\\sqrt{2}a^3bc^2+32\\sqrt{2}a^3c^3+16a^2b^3c+72a^2b^2c^2+64a^2bc^3+16a^2c^4 $$" + "$$ 0 \\le 0 $$" ], "text/plain": [ "" @@ -3206,102 +8531,8 @@ }, { "data": { - "text/latex": [ - "$\\displaystyle - \\frac{2 \\sqrt{2} \\left(a - b\\right)}{c} + \\frac{\\left(a - b\\right)^{2}}{c^{2}} - \\frac{2 \\sqrt{2} \\left(- a + c\\right)}{b} + \\frac{\\left(- a + c\\right)^{2}}{b^{2}} - \\frac{2 \\sqrt{2} \\left(b - c\\right)}{a} + \\frac{\\left(b - c\\right)^{2}}{a^{2}}$" - ], "text/plain": [ - "-2*sqrt(2)*(a - b)/c + (a - b)**2/c**2 - 2*sqrt(2)*(-a + c)/b + (-a + c)**2/b**2 - 2*sqrt(2)*(b - c)/a + (b - c)**2/a**2" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", - "display(Latex('Case $a\\ge c\\ge b$'))\n", - "formula1=makesubs(formula,'[c,oo],[b,oo]',variables='a,c,b')\n", - "prove(formula1)\n", - "display(Latex('Case $a\\ge b\\ge c$'))\n", - "formula2=makesubs(formula,'[b,oo],[c,oo]')\n", - "prove(formula2*4,values='2**(1/2),1,1')" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": {}, - "outputs": [ - { - "data": { - "text/latex": [ - "Substitute $a\\to a+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "Substitute $b\\to b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "formula=cyclize('((a-b)/c)^2-8**(1/2)*(a-b)/c')\n", - "formula2=makesubs(formula,'[c,oo],[c,oo]')" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Optimization terminated successfully.\n", - " Current function value: 1.000000\n", - " Iterations: 271\n", - " Function evaluations: 485\n" - ] - }, - { - "data": { - "text/plain": [ - "(12.42960536989153, 12.429310393555546, 0.00020878153950706037)" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "findvalues(formula2,values=[5,2,7])" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" + "0" ] }, "execution_count": 16, @@ -3310,81 +8541,92 @@ } ], "source": [ - "x,y=symbols('x,y')\n", - "ask(Q.positive(x**2+1),Q.real(x))" + "from importlib import reload\n", + "newproof()\n", + "import shiroindev\n", + "reload(shiroindev)\n", + "from shiroindev import *\n", + "shiro.display=lambda x:display(Latex(x))\n", + "formula=Sm('xy/z+yz/x+zx/y-1').subs('z',S('1-x-y'))\n", + "newformula,values=makesubs(formula,'[0,1-y],[0,1]','1/3,1/3')\n", + "prove(newformula,values)" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 33, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'Sm' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mformula\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mSm\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'(a^2+b^2+c^2)^2- 3(a^3b+b^3c+c^3a)'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mformula1\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmakesubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'[b,oo],[c,oo]'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mvariables\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'a,b'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mformula2\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmakesubs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'[c,oo],[b,oo]'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mvariables\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'a,c'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mprove\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfindvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mformula1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'Sm' is not defined" - ] - } - ], + "outputs": [], "source": [ - "formula=Sm('(a^2+b^2+c^2)^2- 3(a^3b+b^3c+c^3a)')\n", - "formula1=makesubs(formula,'[b,oo],[c,oo]',variables='a,b')\n", - "formula2=makesubs(formula,'[c,oo],[b,oo]',variables='a,c')\n", - "prove(formula2)\n", - "print(findvalues(formula1))\n", - "#prove(formula1,values='4*b*(1-b)-1,4*c*(1-c)-1,1')" + "def findvalues(formula,values=None,variables=None,**kwargs):\n", + "\t\"\"\"finds a candidate for parameter \"values\" in \"prove\" function\n", + "\tblabla\"\"\"\n", + "\tformula=S(formula)\n", + "\taddsymbols(formula)\n", + "\tnum,den=fractioncancel(formula)\n", + "\tif variables==None:\n", + "\t\tvariables=sorted(formula.free_symbols,key=str)\n", + "\tnum=num.subs(zip(variables,list(map(lambda x:x**2,variables))))\n", + "\tnum=Poly(num)\n", + "\tnewformula=S((num.abs()+num)/(num.abs()-num))\n", + "\tf=lambdify(variables,newformula)\n", + "\tf2=lambda x:f(*x)\n", + "\tif values==None:\n", + "\t\tvalues=[1.0]*len(variables)\n", + "\telse:\n", + "\t\tvalues=S(values)\n", + "\ttup=tuple(fmin(f2,values,**kwargs))\n", + "\treturn tuple([x*x for x in tup])" ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 34, "metadata": {}, "outputs": [ { - "data": { - "text/latex": [ - "Substitute $b\\to b+c$" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" + "name": "stdout", + "output_type": "stream", + "text": [ + "Optimization terminated successfully.\n", + " Current function value: 1.000000\n", + " Iterations: 51\n", + " Function evaluations: 109\n" + ] }, { "data": { - "text/latex": [ - "Substitute $c\\to a+c$" - ], "text/plain": [ - "" + "(1.9999999989778676, 0.6689493176765962)" ] }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/latex": [ - "$\\displaystyle - a b - a c + b c$" - ], - "text/plain": [ - "-a*b - a*c + b*c" - ] - }, - "execution_count": 28, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "makesubs(Sm('a^2-2ab+bc-c^2+ca'),'[c,oo],[a,oo]',variables='b,c')" + "findvalues(Sm('(x^2-4x+4)/y'))" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [], + "source": [ + "shiroindev._remzero?" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [], + "source": [ + "import shiroindev\n", + "reload(shiroindev)\n", + "from shiroindev import *" ] }, { diff --git a/shiroindev.py b/shiroindev.py index 106ed66..0a4dddb 100644 --- a/shiroindev.py +++ b/shiroindev.py @@ -2,14 +2,28 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) import warnings,operator warnings.filterwarnings("ignore") -#Seed is needed to select the weights in linprog function. -#None means that the seed is random. +def vargen(n): + """default function generating names for variables""" + q=len(shiro.alphabet) + x=shiro.alphabet[n%q] + if n>=q: + x+=str(n//q) + return x class Vars: pass -sVars=Vars() -sVars.display=print -sVars.seed=None -sVars.translation={} +shiro=Vars() +shiro.display=shiro.warning=print +shiro.seed=None +"""Seed is needed to select the weights in linprog function. +None means that the seed is random""" +shiro.translation={} +shiro.varind=0 +shiro.varset=set() +"""set of used symbols in the proof""" +shiro.vargen=vargen +"""function generating names for variables""" +shiro.alphabet='abcdefghijklmnopqrstuvwxyz' +"""list of names for variables""" translationList=['numerator:','denominator:','status:', 'Substitute',"Formula after substitution:", "Numerator after substitutions:","From weighted AM-GM inequality:", @@ -19,22 +33,38 @@ translationList=['numerator:','denominator:','status:', "Program couldn't find any proof.", "Try to set higher linprogiter parameter.", "It looks like the formula is symmetric. You can assume without loss of"+ -" generality that ","Try", 'From Jensen inequality:' +" generality that ","Try", 'From Jensen inequality:', +'Warning: intervals contain backwards dependencies. Consider changing order of variables and intervals.' ] #Initialize english-english dictionary. for phrase in translationList: - sVars.translation[phrase]=phrase + shiro.translation[phrase]=phrase from scipy.optimize import linprog,fmin import random -from sympy import S,cancel,fraction,Pow,expand,solve,latex,oo,Poly,lambdify +from sympy import S,cancel,fraction,Pow,expand,solve,latex,oo,Poly,lambdify,srepr,gcd,Symbol +from sympy.parsing.sympy_parser import parse_expr, standard_transformations,\ +implicit_multiplication_application, convert_xor from collections import Counter import re +def addsymbols(formula): + formula=S(formula) + funcsymbols=[x[10:-2] for x in re.findall(r"Function\(\'.*?\'\)",srepr(formula))] + shiro.varset|=set(funcsymbols)|set(map(str,formula.free_symbols)) +def newvar(): + while 1: + x=shiro.vargen(shiro.varind) + shiro.varind+=1 + if x not in shiro.varset: + return S(x) +def newproof(): + shiro.varset=set() + shiro.varind=0 def _remzero(coef,fun): -#coef, fun represents an expression. -#For example, if expression=5f(2,3)+0f(4,6)+8f(1,4) -#then coef=[5,0,8], fun=[[2,3],[4,6],[1,4]] -#_remzero removes addends with coefficient equal to zero. -#In this example ncoef=[5,8], nfun=[[2,3],[1,4]] + """coef, fun represents an expression. + For example, if expression=5f(2,3)+0f(4,6)+8f(1,4) + then coef=[5,0,8], fun=[[2,3],[4,6],[1,4]] + _remzero removes addends with coefficient equal to zero. + In this example ncoef=[5,8], nfun=[[2,3],[1,4]]""" ncoef=[] nfun=[] for c,f in zip(coef,fun): @@ -42,11 +72,11 @@ def _remzero(coef,fun): ncoef+=[c] nfun+=[f] return ncoef,nfun -def slatex(formula): #fancy function which makes latex code more readable, but still correct - formula=re.sub(r'\^{(.)}',r'^\1',latex(formula,fold_short_frac=True).replace(' ','').replace('\\left(','(').replace('\\right)',')')) - return re.sub(r'\{(\(.+?\))\}',r'\1',formula) +# ~ def slatex(formula): #fancy function which makes latex code more readable, but still correct + # ~ formula=re.sub(r'\^{(.)}',r'^\1',latex(formula,fold_short_frac=True).replace(' ','').replace('\\left(','(').replace('\\right)',')')) + # ~ return re.sub(r'\{(\(.+?\))\}',r'\1',formula) def _writ2(coef,fun,variables): - return slatex(S((str(coef)+'*'+'*'.join([str(x)+'^'+str(y) for x,y in zip(variables,fun)])))) + return latex(Poly({fun:coef},gens=variables).as_expr()) def _writ(coef,fun,nullvar): return str(coef)+'f('+str(fun)[1:-1-(len(fun)==1)]+')' def _check(coef,fun,res,rfun): @@ -61,19 +91,35 @@ def _powr(formula): else: return [formula,S('1')] def fractioncancel(formula): -#workaround for buggy cancel function + """workaround for buggy cancel function""" num,den=fraction(cancel(formula/S('tmp'))) den=den.subs(S('tmp'),S('1')) return num,den def ssolve(formula,variables): -#workaround for inconsistent solve function + """workaround for inconsistent solve function""" result=solve(formula,variables) if type(result)==dict: result=[[result[var] for var in variables]] return result -def sstr(formula): - return str(formula).replace('**','^').replace('*','').replace(' ','') +#def sstr(formula): +# return str(formula).replace('**','^').replace('*','').replace(' ','') +def assumeall(formula,**kwargs): + """Adds assumptions to all free symbols in formula. + >>> assumeall('sqrt(x*y)-sqrt(x)*sqrt(y)',positive=True) + 0 + """ + formula=S(formula) + fs=formula.free_symbols + for x in fs: + y=Symbol(str(x),**kwargs) + formula=formula.subs(x,y) + return formula def reducegens(formula): + """Reduces size of the generator of the polynomial + >>>Poly('x+sqrt(x)') + Poly(x + (sqrt(x)), x, sqrt(x), domain='ZZ') + >>>reducegens('x+sqrt(x)') + Poly((sqrt(x))**2 + (sqrt(x)), sqrt(x), domain='ZZ') """ pol=Poly(formula) newgens={} ind={} @@ -96,82 +142,90 @@ def reducegens(formula): newpol=newpol.replace(ind[gen],gen**newgens[gen]) return newpol def Sm(formula): -#Adds multiplication signs and sympifies a formula. -#For example, Sm('(2x+y)(7+5xz)') -> S('(2*x+y)*(7+5*x*z)') - if type(formula)==str: - formula=formula.replace(' ','') - for i in range(2): - formula=re.sub(r'([0-9a-zA-Z)])([(a-zA-Z])',r'\1*\2',formula) - formula=S(formula) - return formula + """Adds multiplication signs and sympifies a formula. + For example, Sm('(2x+y)(7+5xz)') -> S('(2*x+y)*(7+5*x*z)')""" + if type(formula)!=str: + if _isiterable(formula): return type(formula)(map(Sm,formula)) + else: return S(formula) + formula=formula.translate({ord('{'):None,ord('}'):' '}) + transformations = (standard_transformations +(implicit_multiplication_application,convert_xor)) + return parse_expr(formula, transformations=transformations) +# ~ def Sm(formula): +# ~ #Adds multiplication signs and sympifies a formula. +# ~ #For example, Sm('(2x+y)(7+5xz)') -> S('(2*x+y)*(7+5*x*z)') + # ~ if type(formula)==str: + # ~ formula=formula.replace(' ','') + # ~ for i in range(2): + # ~ formula=re.sub(r'([0-9a-zA-Z)])([(a-zA-Z])',r'\1*\2',formula) + # ~ formula=S(formula) + # ~ return formula def _input2fraction(formula,variables,values): -#makes some substitutions and converts formula to a fraction -#with expanded numerator and denominator + """makes some substitutions and converts formula to a fraction + with expanded numerator and denominator""" formula=S(formula) subst=[] for x,y in zip(variables,values): if y!=1: - sVars.display(sVars.translation['Substitute']+' $'+str(x)+'\\to '+slatex(S(y)*S(x))+'$') - subst+=[(x,x*y)] + z=newvar() + shiro.display(shiro.translation['Substitute']+' $'+latex(x)+'\\to '+latex(S(y)*S(z))+'$') + subst+=[(x,z*y)] formula=formula.subs(subst) numerator,denominator=fractioncancel(formula) - sVars.display(sVars.translation['numerator:']+' $'+slatex(numerator)+'$') - sVars.display(sVars.translation['denominator:']+' $'+slatex(denominator)+'$') + shiro.display(shiro.translation['numerator:']+' $'+latex(numerator)+'$') + shiro.display(shiro.translation['denominator:']+' $'+latex(denominator)+'$') return (numerator,denominator) def _formula2list(formula): -#Splits a polynomial to a difference of two polynomials with positive -#coefficients and extracts coefficients and powers of both polynomials. -#'variables' is used to set order of powers -#For example, If formula=5x^2-4xy+8y^3, variables=[x,y], then -#the program tries to prove that -#0<=5x^2-4xy+8y^3 -#4xy<=5x^2+8y^3 -#returns [4],[(1,1)], [5,8],[(2,0),(0,3)], (x,y) - formula=reducegens(formula) - neg=(formula.abs()-formula)/2 - pos=(formula.abs()+formula)/2 - neg=Poly(neg,gens=formula.gens) - pos=Poly(pos,gens=formula.gens) + """Splits a polynomial to a difference of two polynomials with positive + coefficients and extracts coefficients and powers of both polynomials. + 'variables' is used to set order of powers + For example, If formula=5x^2-4xy+8y^3, variables=[x,y], then + the program tries to prove that + 0<=5x^2-4xy+8y^3 + 4xy<=5x^2+8y^3 + returns [4],[(1,1)], [5,8],[(2,0),(0,3)], (x,y)""" + formula=reducegens(assumeall(formula,positive=True)) + neg=(formula.abs()-formula)*S('1/2') + pos=(formula.abs()+formula)*S('1/2') return neg.coeffs(),neg.monoms(),pos.coeffs(),pos.monoms(),Poly(formula).gens def _list2proof(lcoef,lfun,rcoef,rfun,variables,itermax,linprogiter,_writ2=_writ2,theorem="From weighted AM-GM inequality:"): -#Now the formula is splitted on two polynomials with positive coefficients. -#we will call them LHS and RHS and our inequality to prove would -#be LHS<=RHS (instead of 0<=RHS-LHS). + """Now the formula is splitted on two polynomials with positive coefficients. + we will call them LHS and RHS and our inequality to prove would + be LHS<=RHS (instead of 0<=RHS-LHS). + + Suppose we are trying to prove that + 30x^2y^2+60xy^4<=48x^3+56y^6 (assuming x,y>0). + Program will try to find some a,b,c,d such that + 30x^2y^2<=ax^3+by^6 + 60xy^4<=cx^3+dy^6 + where a+c<=48 and b+d<=56 (assumption 1). + We need some additional equalities to meet assumptions + of the weighted AM-GM inequality. + a+b=30 and c+d=60 (assumption 2) + 3a+0b=30*2, 0a+6b=30*2, 3c+0d=60*1, 0c+6d=60*4 (assumption 3) -#suppose we are trying to prove that -#30x^2y^2+60xy^4<=48x^3+56y^6 (assuming x,y>0) -#program will try to find some a,b,c,d such that -#30x^2y^2<=ax^3+by^6 -#60xy^4<=cx^3+dy^6 -#where a+c<=48 and b+d<=56 (assumption 1) -#We need some additional equalities to meet assumptions -#of the weighted AM-GM inequality. -#a+b=30 and c+d=60 (assumption 2) -#3a+0b=30*2, 0a+6b=30*2, 3c+0d=60*1, 0c+6d=60*4 (assumption 3) - -#The sketch of the algorithm. -# for i in range(itermax): - #1. Create a vector of random numbers (weights). - #2. Try to find real solution of the problem (with linprog). - #3. If there is no solution (status: 2) - #3a. If the solution was never found, break. - #3b. Else, step back (to the bigger inequality) - #4. If the soltuion was found (status: 0) - #Check out which of variables (in example: a,b,c,d) looks like integer. - #If there are some inequalities with all integer coefficients, subtract - #them from the original one. - #If LHS is empty, then break. - localseed=sVars.seed + The sketch of the algorithm. + for i in range(itermax): + 1. Create a vector of random numbers (weights). + 2. Try to find real solution of the problem (with linprog). + 3. If there is no solution (status: 2) + 3a. If the solution was never found, break. + 3b. Else, step back (to the bigger inequality) + 4. If the soltuion was found (status: 0) + Check out which of variables (in example: a,b,c,d) looks like integer. + If there are some inequalities with all integer coefficients, subtract + them from the original one. + If LHS is empty, then break.""" + localseed=shiro.seed bufer=[] lcoef,lfun=_remzero(lcoef,lfun) rcoef,rfun=_remzero(rcoef,rfun) itern=0 if len(lcoef)==0: #if LHS is empty - sVars.display(sVars.translation['status:']+' 0') + shiro.display(shiro.translation['status:']+' 0') status=0 elif len(rcoef)==0: #if RHS is empty, but LHS is not - sVars.display(sVars.translation['status:']+' 2') + shiro.display(shiro.translation['status:']+' 2') status=2 itermax=0 foundreal=0 @@ -208,9 +262,9 @@ def _list2proof(lcoef,lfun,rcoef,rfun,variables,itermax,linprogiter,_writ2=_writ res=linprog(vecc,A_eq=A,b_eq=b,A_ub=A_ub,b_ub=b_ub,options={'maxiter':linprogiter}) status=res.status if itern==1: - sVars.display(sVars.translation['status:']+' '+str(status)) + shiro.display(shiro.translation['status:']+' '+str(status)) if status==0: - sVars.display(sVars.translation[theorem]) + shiro.display(shiro.translation[theorem]) if status==2: #if real solution of current inequality doesn't exist if foundreal==0: #if this is the first inequality, then break break @@ -222,7 +276,7 @@ def _list2proof(lcoef,lfun,rcoef,rfun,variables,itermax,linprogiter,_writ2=_writ continue if status==0:#if found a solution with real coefficients for ineq in bufer: - sVars.display(ineq) + shiro.display(ineq) foundreal=1 bufer=[] oldlfun,oldrfun=lfun,rfun @@ -254,25 +308,25 @@ def _list2proof(lcoef,lfun,rcoef,rfun,variables,itermax,linprogiter,_writ2=_writ lcoef,lfun=_remzero(lcoef,lfun) rcoef,rfun=_remzero(rcoef,rfun) for ineq in bufer: - sVars.display(ineq) + shiro.display(ineq) lhs='+'.join([_writ2(c,f,variables) for c,f in zip(lcoef,lfun)]) if lhs=='': lhs='0' elif status==0: - sVars.display(sVars.translation[ + shiro.display(shiro.translation[ "Program couldn't find a solution with integer coefficients. Try "+ "to multiple the formula by some integer and run this function again."]) elif(status==2): - sVars.display(sVars.translation["Program couldn't find any proof."]) + shiro.display(shiro.translation["Program couldn't find any proof."]) #return res.status elif status==1: - sVars.display(sVars.translation["Try to set higher linprogiter parameter."]) + shiro.display(shiro.translation["Try to set higher linprogiter parameter."]) rhs='+'.join([_writ2(c,f,variables) for c,f in zip(rcoef,rfun)]) if rhs=='': rhs='0' - sVars.display('$$ '+slatex(lhs)+' \\le '+slatex(rhs)+' $$') + shiro.display('$$ '+latex(lhs)+' \\le '+latex(rhs)+' $$') if lhs=='0': - sVars.display(sVars.translation['The sum of all inequalities gives us a proof of the inequality.']) + shiro.display(shiro.translation['The sum of all inequalities gives us a proof of the inequality.']) return status def _isiterable(obj): try: @@ -281,18 +335,25 @@ def _isiterable(obj): except TypeError: return False def _smakeiterable(x): + if x=='': + return [] x=S(x) if _isiterable(x): return x return (x,) def _smakeiterable2(x): + if x=='': + return [] x=S(x) + if len(x)==0: + return [] if _isiterable(x[0]): return x return (x,) def prove(formula,values=None,variables=None,niter=200,linprogiter=10000): -#tries to prove that formula>=0 assuming all variables are positive + """tries to prove that formula>=0 assuming all variables are positive""" formula=S(formula) + addsymbols(formula) if variables: variables=_smakeiterable(variables) else: variables=sorted(formula.free_symbols,key=str) if values: values=_smakeiterable(values) @@ -301,46 +362,50 @@ def prove(formula,values=None,variables=None,niter=200,linprogiter=10000): st=_list2proof(*(_formula2list(num)+(niter,linprogiter))) if st==2 and issymetric(num): fs=sorted([str(x) for x in num.free_symbols]) - sVars.display(sVars.translation["It looks like the formula is symmetric. "+ + shiro.display(shiro.translation["It looks like the formula is symmetric. "+ "You can assume without loss of generality that "]+ - ' >= '.join([str(x) for x in fs])+'. '+sVars.translation['Try']) - sVars.display('prove(makesubs(S("'+str(num)+'"),'+ + ' >= '.join([str(x) for x in fs])+'. '+shiro.translation['Try']) + shiro.display('prove(makesubs(S("'+str(num)+'"),'+ str([(str(x),'oo') for x in variables[1:]])+')') return st def powerprove(formula,values=None,variables=None,niter=200,linprogiter=10000): -#This is a bruteforce and ineffective function for proving inequalities. -#It can be used as the last resort. + """This is a bruteforce and ineffective function for proving inequalities. + It can be used as the last resort.""" formula=S(formula) + addsymbols(formula) if variables: variables=_smakeiterable(variables) else: variables=sorted(formula.free_symbols,key=str) if values: values=_smakeiterable(values) else: values=[1]*len(variables) num,den=_input2fraction(formula,variables,values) - subst2=[] statusses=[] - for j in range(len(variables)): - subst2+=[(variables[j],1+variables[j])] + for i in range(1<R instead of a polynomial. provef checks if a formula -#is nonnegative for any nonnegative and convex function f. If so, it -#provides a proof of nonnegativity. + """This function is similar to prove, formula is a linear combination of + values of f:R^k->R instead of a polynomial. provef checks if a formula + is nonnegative for any nonnegative and convex function f. If so, it + provides a proof of nonnegativity.""" formula=S(formula) + addsymbols(formula) num,den=_input2fraction(formula,[],[]) return _list2proof(*(_formula2listf(num)+(niter,linprogiter,_writ,'From Jensen inequality:'))) -def issymetric(formula): #checks if formula is symmetric -#and has at least two variables +def issymetric(formula): + """checks if formula is symmetric + and has at least two variables""" + formula=S(formula) + addsymbols(formula) if len(formula.free_symbols)<2: return False ls=list(formula.free_symbols) @@ -425,9 +501,10 @@ def issymetric(formula): #checks if formula is symmetric return False return True def cyclize(formula,oper=operator.add,variables=None,init=None): -#cyclize('a^2*b')=S('a^2*b+b^2*a') -#cyclize('a^2*b',variables='a,b,c')=S('a^2*b+b^2*c+c^2*a') + """cyclize('a^2*b')=S('a^2*b+b^2*a') + cyclize('a^2*b',variables='a,b,c')=S('a^2*b+b^2*c+c^2*a')""" formula=S(formula) + addsymbols(formula) if variables==None: variables=sorted(formula.free_symbols,key=str) else: @@ -446,10 +523,11 @@ def cyclize(formula,oper=operator.add,variables=None,init=None): init=oper(init,formula) return init def symmetrize(formula,oper=operator.add,variables=None,init=None): -#symmetrize('a^2*b')=S('a^2*b+b^2*a') -#symmetrize('a^2*b',variables='a,b,c')= -#=S('a^2*b+a^2*c+b^2*a+b^2*c+c^2*a+c^2*b') + """symmetrize('a^2*b')=S('a^2*b+b^2*a') + symmetrize('a^2*b',variables='a,b,c')= + =S('a^2*b+a^2*c+b^2*a+b^2*c+c^2*a+c^2*b')""" formula=S(formula) + addsymbols(formula) if variables==None: variables=sorted(formula.free_symbols,key=str) else: @@ -457,8 +535,10 @@ def symmetrize(formula,oper=operator.add,variables=None,init=None): for i in range(1,len(variables)): formula=cyclize(formula,oper,variables[:i+1]) return formula -def findvalues(formula,values=None,variables=None): +def findvalues(formula,values=None,variables=None,**kwargs): + """finds a candidate for parameter "values" in "prove" function""" formula=S(formula) + addsymbols(formula) num,den=fractioncancel(formula) if variables==None: variables=sorted(num.free_symbols,key=str) @@ -471,5 +551,5 @@ def findvalues(formula,values=None,variables=None): values=[1.0]*len(variables) else: values=S(values) - tup=tuple(fmin(f2,values)) + tup=tuple(fmin(f2,values,**kwargs)) return tuple([x*x for x in tup]) diff --git a/statistics.ipynb b/statistics.ipynb new file mode 100644 index 0000000..fe47221 --- /dev/null +++ b/statistics.ipynb @@ -0,0 +1,1563 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In this notebook several methods for proving inequalities have been compared.\n", + "\n", + "First of all we need a dataset. 35 inequalities were selected from https://www.imomath.com/index.php?options=592&lmm=0. Each inequality is represented by a tuple: inequality (in LaTeX), inequality constraints (for example: $a\\in [0,1]$, equality constraints (for example: $abc=1$) and a function which converts inequality to a formula which we want to prove it's nonnegativity. In most cases when this function is simply a difference between left and right-hand side, but sometimes it's better to use difference between squares of sides (to get rid of square roots). These tuples are used as parameters in `parser` function which converts them to equivalent inequalities with default constraints (i.e. all variables are positive).\n", + "\n", + "Some tuples have less than 4 elements. In this case `parser` use default arguments." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from importlib import reload\n", + "from sympy import *\n", + "import shiroindev\n", + "from shiroindev import *\n", + "from sympy.parsing.latex import parse_latex\n", + "shiro.seed=1\n", + "from IPython.display import Latex\n", + "shiro.display=lambda x:display(Latex(x))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "`sympy` has a `parse_latex` function which converts LaTeX formula to a `sympy` one. Unfortunately it doesn't deal with missing braces in the way that LaTeX do. For example `\\frac12` generates $\\frac12$ which is the same as `\\frac{1}{2}`, but `parse_latex` accepts only the second version. So here there is a boring function which adds missing braces." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\\frac{ \\sqrt {3}}{2}\n", + "a^2+b^2+c^2\\geq ab+bc+ca\n" + ] + } + ], + "source": [ + "def addbraces(s):\n", + " arg={r'\\frac':2,r'\\sqrt':1}\n", + " s2=''\n", + " p=0\n", + " while 1:\n", + " m=re.search(r\"\\\\[a-zA-Z]+\", s[p:])\n", + " if not m:\n", + " break\n", + " s2+=s[p:p+m.end()]\n", + " #print('a',s[p:m.end()],p)\n", + " p+=m.end()\n", + " if m.group() in arg:\n", + " for i in range(arg[m.group()]):\n", + " sp=re.search('^ *',s[p:])\n", + " s2+=sp.group()\n", + " #print('b',sp.group(),p)\n", + " p+=sp.end()\n", + " if s[p]=='{':\n", + " cb=re.search(r'^\\{.*?\\}',s[p:])\n", + " ab=addbraces(cb.group())\n", + " s2+=ab\n", + " #print('c',ab,p)\n", + " p+=cb.end()\n", + " else:\n", + " s2+='{'+s[p]+'}'\n", + " #print('d','{'+s[p]+'}',p)\n", + " p+=1\n", + " #print('e',p)\n", + " s2+=s[p:]\n", + " return s2\n", + "print(addbraces(r'\\frac{ \\sqrt 3}2'))\n", + "print(addbraces(r'a^2+b^2+c^2\\geq ab+bc+ca'))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "#(formula,intervals,subs,function)\n", + "dif=lambda b,s:b-s\n", + "dif2=lambda b,s:b*b-s*s\n", + "ineqs=[\n", + " (r'a^2+b^2+c^2\\geq ab+bc+ca',),\n", + " (r'a^2+b^2+c^2+d^2\\geq a(b+c+d)',),\n", + " (r'1\\leq\\frac{a^2b^2}{c^2}+\\frac{b^2c^2}{a^2}+\\frac{c^2a^2}{b^2}',\n", + " '[0,1-f],[0,1]','[a,sqrt(1-e-f)],[b,sqrt(e)],[c,sqrt(f)]',),\n", + " (r'\\frac1{1-x^2}+\\frac1{1-y^2}\\geq \\frac2{1-xy}','[0,1],[0,1]'),\n", + " (r'a^3+b^3\\geq a^2b+ab^2',),\n", + " (r'\\frac a{b+c}+\\frac b{c+a}+\\frac c{a+b}\\geq \\frac32',),\n", + " (r'2a^3+b^3\\geq 3a^2b',),\n", + " (r'a^3+b^3+c^3\\geq a^2b+b^2c+c^2a',),\n", + " (r'\\frac a{b+c}+\\frac b{c+d}+ \\frac c{d+a}+ \\frac d{a+b}\\geq 2',),\n", + " (r'\\frac{a^3}{a^2+ab+b^2}+ \\frac{b^3}{b^2+bc+c^2}+ \\frac{c^3}{c^2+ca+a^2} \\geq \\frac{a+b+c}3',),\n", + " (r'\\sqrt{ab}+\\sqrt{cd}+\\sqrt{ef}\\leq\\sqrt{(a+c+e)(b+d+f)}','','',dif2),\n", + " (r'\\frac{5a^3-ab^2}{a+b}+\\frac{5b^3-bc^2}{b+c}+\\frac{5c^3-ca^2}{c+a}\\geq 2(a^2+b^2+c^2)',),\n", + " #(r'\\frac{a^2}{(1+b)(1-c)}+\\frac{b^3}{(1+c)(1-d)}+\\frac{c^3}{(1+d)(1-a)}+\\frac{d^3}{(1+a)(1-b)}\\geq\\frac1{15}',\n", + " # '[0,1-c-d],[0,1-d],[0,1]','[a,1-b-c-d]'),\n", + " (r'\\frac{x^3}{(1+y)(1+z)}+\\frac{y^3}{(1+z)(1+x)}+\\frac{z^3}{(1+x)(1+y)}\\geq\\frac{3}{4}','','[z,1/(x*y)]'),\n", + " (r'\\frac ab+\\frac bc+\\frac ca\\geq \\frac{(a+b+c)^2}{ab+bc+ca}',),\n", + " (r'\\frac{a^2}b+\\frac{b^2}c+\\frac{c^2}a\\geq \\frac{a^2+b^2+c^2}{a+b+c}',),\n", + " (r'\\frac{a^2}b+\\frac{b^2}c+\\frac{c^2}a\\geq a+b+c+\\frac{4(a-b)^2}{a+b+c}',),\n", + " (r'\\frac1{a^3+b^3+abc}+ \\frac1{b^3+c^3+abc} +\\frac1{c^3+a^3+ abc} \\leq \\frac1{abc}',),\n", + " (r'\\frac1{a^3(b+c)}+ \\frac1{b^3(c+a)}+ \\frac1{c^3(a+b)} \\geq \\frac32','','[c,1/(a*b)]'),\n", + " (r'\\frac{a^3}{b^2-bc+c^2}+\\frac{b^3}{c^2-ca+a^2} + \\frac{c^3}{a^2-ab+b^2} \\geq 3 \\cdot\\frac{ab+bc+ca}{a+b+c}',),\n", + " (r'\\frac{x^5-x^2}{x^5+y^2+z^2}+\\frac{y^5-y^2}{y^5+z^2+x^2}+\\frac{z^5-z^2}{z^5+x^2+y^2}\\geq0','','[x,1/(y*z)]'),\n", + " (r'(a+b-c)(b+c-a)(c+a-b)\\leq abc',),\n", + " (r'\\frac1{1+xy}+\\frac1{1+yz}+\\frac1{1+zx}\\leq \\frac34','','[x,(y+z)/(y*z-1)]'),\n", + " (r'\\frac{x\\sqrt x}{y+z}+\\frac{y\\sqrt y}{z+x}+\\frac{z\\sqrt z}{x+y}\\geq\\frac{ \\sqrt 3}2',\n", + " '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'a^4+b^4+c^4+d^4\\geq 4abcd',),\n", + " (r'\\frac{ab}{a+b}+\\frac{bc}{b+c}+\\frac{ca}{c+a}\\leq\\frac{3(ab+bc+ca)}{2(a+b+c)}',),\n", + " (r'\\sqrt{a-1}+\\sqrt{b-1}+ \\sqrt{c-1} \\leq \\sqrt{c(ab+1)}','[1,oo],[1,oo],[1,oo]','',dif2),\n", + " (r'(x-1)(y-1)(z-1)\\geq 8','[0,1-b-c],[0,1-c],[0,1]','[x,1/a],[y,1/b],[z,1/c]'),\n", + " (r'ay+bz+cx\\leq s^2','[0,s],[0,s],[0,s]','[x,s-a],[y,s-b],[z,s-c]'),\n", + " (r'x_1^2+x_2^2+x_3^2+x_4^2+x_5^2\\geq 2 (x_1x_2+x_2x_3+x_3x_4+x_4x_5)/\\sqrt{3}',),\n", + " (r' xy+yz+zx - 2xyz \\leq \\frac7{27}', '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'0 \\leq xy+yz+zx - 2xyz', '[0,1-z],[0,1]','[x,1-y-z]'),\n", + " (r'\\sqrt{3+a+b+c}\\geq\\sqrt a+\\sqrt b+\\sqrt c','[1-z,1],[0,1]','[a,1/x-1],[b,1/y-1],[c,1/z-1],[x,2-y-z]',\n", + " dif2),\n", + " (r'\\frac{2a^3}{a^2+b^2}+\\frac{2b^3}{b^2+c^2}+\\frac{2c^3}{c^2+a^2}\\geq a+b+c',),\n", + " (r'\\frac{a^2}{b+c}+\\frac{b^2}{c+a}+\\frac{c^2}{a+b}\\geq \\frac12','[0,1-c],[0,1]','[a,1-b-c]'),\n", + " (r'\\frac{a+b}{2b+c}+\\frac{b+c}{2c+a}+\\frac{c+a}{2a+b}\\geq 2',),\n", + " #(r'\\frac x{5-y^2}+\\frac y{5-z^2}+\\frac z{5-x^2}\\geq \\frac34','[0,sqrt(5)],[0,sqrt(5)]','[x,1/(y*z)]')\n", + "]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "def parser(formula,intervals='[]',subs='[]',func=dif):\n", + " newproof()\n", + " shiro.display=lambda x:None\n", + " #display=lambda x:None\n", + " if intervals=='':\n", + " intervals='[]'\n", + " if subs=='':\n", + " subs='[]'\n", + " formula=addbraces(formula)\n", + " formula=Sm(str(parse_latex(formula)))\n", + " formula,_=fractioncancel(formula)\n", + " formula=formula.subs(shiroindev._smakeiterable2(subs))\n", + " formula=makesubs(formula,intervals)\n", + " b,s=formula.lhs,formula.rhs\n", + " if type(formula)==LessThan:\n", + " b,s=s,b\n", + " formula=func(b,s)\n", + " formula=simplify(formula)\n", + " num,den=fractioncancel(formula)\n", + " return num" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "100%|██████████| 35/35 [00:46<00:00, 1.32s/it]\n" + ] + } + ], + "source": [ + "from tqdm import tqdm\n", + "ineqs2=[]\n", + "for ineq in tqdm(ineqs):\n", + " ineqs2+=[parser(*ineq)]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now let's look at the formulas when converted to polynomials." + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{2} - ab - ac + b^{2} - bc + c^{2}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**2 - a*b - a*c + b**2 - b*c + c**2, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{2} - ab - ac - ad + b^{2} + c^{2} + d^{2}, a, b, c, d, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**2 - a*b - a*c - a*d + b**2 + c**2 + d**2, a, b, c, d, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{4}b^{2} + a^{3}b^{2} - a^{3}b - 2 a^{2}b + a^{2} + ab^{2} - ab + b^{2}, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**4*b**2 + a**3*b**2 - a**3*b - 2*a**2*b + a**2 + a*b**2 - a*b + b**2, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{3}b + a^{3} - 4 a^{2}b^{2} - a^{2}b + a^{2} + 2 ab^{3} - ab^{2} - 2 ab + b^{3} + b^{2}, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**3*b + a**3 - 4*a**2*b**2 - a**2*b + a**2 + 2*a*b**3 - a*b**2 - 2*a*b + b**3 + b**2, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "4\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3} - a^{2}b - ab^{2} + b^{3}, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3 - a**2*b - a*b**2 + b**3, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "5\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{3} - a^{2}b - a^{2}c - ab^{2} - ac^{2} + 2 b^{3} - b^{2}c - bc^{2} + 2 c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**3 - a**2*b - a**2*c - a*b**2 - a*c**2 + 2*b**3 - b**2*c - b*c**2 + 2*c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "6\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{3} - 3 a^{2}b + b^{3}, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**3 - 3*a**2*b + b**3, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3} - a^{2}b - ac^{2} + b^{3} - b^{2}c + c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3 - a**2*b - a*c**2 + b**3 - b**2*c + c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "8\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3}c + a^{3}d + a^{2}b^{2} - a^{2}bd - 2 a^{2}c^{2} - a^{2}cd + a^{2}d^{2} + ab^{3} - ab^{2}c - ab^{2}d - abc^{2} + ac^{3} - acd^{2} + b^{3}d + b^{2}c^{2} - 2 b^{2}d^{2} + bc^{3} - bc^{2}d - bcd^{2} + bd^{3} + c^{2}d^{2} + cd^{3}, a, b, c, d, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3*c + a**3*d + a**2*b**2 - a**2*b*d - 2*a**2*c**2 - a**2*c*d + a**2*d**2 + a*b**3 - a*b**2*c - a*b**2*d - a*b*c**2 + a*c**3 - a*c*d**2 + b**3*d + b**2*c**2 - 2*b**2*d**2 + b*c**3 - b*c**2*d - b*c*d**2 + b*d**3 + c**2*d**2 + c*d**3, a, b, c, d, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{5}b^{2} + 2 a^{5}bc + 2 a^{5}c^{2} + a^{4}b^{3} - a^{4}b^{2}c - a^{4}bc^{2} + a^{4}c^{3} + a^{3}b^{4} - 2 a^{3}b^{3}c - 4 a^{3}b^{2}c^{2} - 2 a^{3}bc^{3} + a^{3}c^{4} + 2 a^{2}b^{5} - a^{2}b^{4}c - 4 a^{2}b^{3}c^{2} - 4 a^{2}b^{2}c^{3} - a^{2}bc^{4} + 2 a^{2}c^{5} + 2 ab^{5}c - ab^{4}c^{2} - 2 ab^{3}c^{3} - ab^{2}c^{4} + 2 abc^{5} + 2 b^{5}c^{2} + b^{4}c^{3} + b^{3}c^{4} + 2 b^{2}c^{5}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**5*b**2 + 2*a**5*b*c + 2*a**5*c**2 + a**4*b**3 - a**4*b**2*c - a**4*b*c**2 + a**4*c**3 + a**3*b**4 - 2*a**3*b**3*c - 4*a**3*b**2*c**2 - 2*a**3*b*c**3 + a**3*c**4 + 2*a**2*b**5 - a**2*b**4*c - 4*a**2*b**3*c**2 - 4*a**2*b**2*c**3 - a**2*b*c**4 + 2*a**2*c**5 + 2*a*b**5*c - a*b**4*c**2 - 2*a*b**3*c**3 - a*b**2*c**4 + 2*a*b*c**5 + 2*b**5*c**2 + b**4*c**3 + b**3*c**4 + 2*b**2*c**5, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( ad + af - 2 \\sqrt{a}\\sqrt{b}\\sqrt{c}\\sqrt{d} - 2 \\sqrt{a}\\sqrt{b}\\sqrt{e}\\sqrt{f} + bc + be + cf - 2 \\sqrt{c}\\sqrt{d}\\sqrt{e}\\sqrt{f} + de, \\sqrt{a}, \\sqrt{b}, \\sqrt{c}, \\sqrt{d}, \\sqrt{e}, \\sqrt{f}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((sqrt(a))**2*(sqrt(d))**2 + (sqrt(a))**2*(sqrt(f))**2 - 2*(sqrt(a))*(sqrt(b))*(sqrt(c))*(sqrt(d)) - 2*(sqrt(a))*(sqrt(b))*(sqrt(e))*(sqrt(f)) + (sqrt(b))**2*(sqrt(c))**2 + (sqrt(b))**2*(sqrt(e))**2 + (sqrt(c))**2*(sqrt(f))**2 - 2*(sqrt(c))*(sqrt(d))*(sqrt(e))*(sqrt(f)) + (sqrt(d))**2*(sqrt(e))**2, sqrt(a), sqrt(b), sqrt(c), sqrt(d), sqrt(e), sqrt(f), domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "11\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 3 a^{4}b + 3 a^{4}c - 2 a^{3}b^{2} + 2 a^{3}c^{2} + 2 a^{2}b^{3} - 6 a^{2}b^{2}c - 6 a^{2}bc^{2} - 2 a^{2}c^{3} + 3 ab^{4} - 6 ab^{2}c^{2} + 3 ac^{4} + 3 b^{4}c - 2 b^{3}c^{2} + 2 b^{2}c^{3} + 3 bc^{4}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(3*a**4*b + 3*a**4*c - 2*a**3*b**2 + 2*a**3*c**2 + 2*a**2*b**3 - 6*a**2*b**2*c - 6*a**2*b*c**2 - 2*a**2*c**3 + 3*a*b**4 - 6*a*b**2*c**2 + 3*a*c**4 + 3*b**4*c - 2*b**3*c**2 + 2*b**2*c**3 + 3*b*c**4, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 4 x^{8}y^{4} + 4 x^{7}y^{4} - 3 x^{5}y^{5} - 3 x^{5}y^{4} + 4 x^{4}y^{8} + 4 x^{4}y^{7} - 3 x^{4}y^{5} - 6 x^{4}y^{4} - 3 x^{4}y^{3} - 3 x^{3}y^{4} - 3 x^{3}y^{3} + 4 xy + 4, x, y, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(4*x**8*y**4 + 4*x**7*y**4 - 3*x**5*y**5 - 3*x**5*y**4 + 4*x**4*y**8 + 4*x**4*y**7 - 3*x**4*y**5 - 6*x**4*y**4 - 3*x**4*y**3 - 3*x**3*y**4 - 3*x**3*y**3 + 4*x*y + 4, x, y, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "13\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3}c^{2} + a^{2}b^{3} - a^{2}b^{2}c - a^{2}bc^{2} - ab^{2}c^{2} + b^{2}c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3*c**2 + a**2*b**3 - a**2*b**2*c - a**2*b*c**2 - a*b**2*c**2 + b**2*c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "14\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{4}c + a^{3}c^{2} + a^{2}b^{3} + ab^{4} + b^{2}c^{3} + bc^{4}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**4*c + a**3*c**2 + a**2*b**3 + a*b**4 + b**2*c**3 + b*c**4, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "15\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{4}c - 4 a^{3}bc + a^{3}c^{2} + a^{2}b^{3} + 6 a^{2}b^{2}c - 2 a^{2}bc^{2} + ab^{4} - 4 ab^{3}c - 2 ab^{2}c^{2} + b^{2}c^{3} + bc^{4}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**4*c - 4*a**3*b*c + a**3*c**2 + a**2*b**3 + 6*a**2*b**2*c - 2*a**2*b*c**2 + a*b**4 - 4*a*b**3*c - 2*a*b**2*c**2 + b**2*c**3 + b*c**4, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "16\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{6}b^{3} + a^{6}c^{3} - 2 a^{5}b^{2}c^{2} + a^{3}b^{6} + a^{3}c^{6} - 2 a^{2}b^{5}c^{2} - 2 a^{2}b^{2}c^{5} + b^{6}c^{3} + b^{3}c^{6}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**6*b**3 + a**6*c**3 - 2*a**5*b**2*c**2 + a**3*b**6 + a**3*c**6 - 2*a**2*b**5*c**2 - 2*a**2*b**2*c**5 + b**6*c**3 + b**3*c**6, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "17\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{8}b^{8} + 2 a^{7}b^{6} + 2 a^{6}b^{7} - 3 a^{6}b^{5} - 3 a^{5}b^{6} + 2 a^{5}b^{5} - 3 a^{5}b^{3} + 2 a^{5}b^{2} - 6 a^{4}b^{4} + 2 a^{4}b^{3} + 2 a^{4} - 3 a^{3}b^{5} + 2 a^{3}b^{4} - 3 a^{3}b^{2} + 2 a^{3}b + 2 a^{2}b^{5} - 3 a^{2}b^{3} + 2 ab^{3} + 2 b^{4}, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**8*b**8 + 2*a**7*b**6 + 2*a**6*b**7 - 3*a**6*b**5 - 3*a**5*b**6 + 2*a**5*b**5 - 3*a**5*b**3 + 2*a**5*b**2 - 6*a**4*b**4 + 2*a**4*b**3 + 2*a**4 - 3*a**3*b**5 + 2*a**3*b**4 - 3*a**3*b**2 + 2*a**3*b + 2*a**2*b**5 - 3*a**2*b**3 + 2*a*b**3 + 2*b**4, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "18\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{8} - a^{6}bc - 2 a^{5}b^{3} + a^{5}b^{2}c + a^{5}bc^{2} - 2 a^{5}c^{3} + 3 a^{4}b^{4} - a^{4}b^{3}c + 2 a^{4}b^{2}c^{2} - a^{4}bc^{3} + 3 a^{4}c^{4} - 2 a^{3}b^{5} - a^{3}b^{4}c - a^{3}b^{3}c^{2} - a^{3}b^{2}c^{3} - a^{3}bc^{4} - 2 a^{3}c^{5} + a^{2}b^{5}c + 2 a^{2}b^{4}c^{2} - a^{2}b^{3}c^{3} + 2 a^{2}b^{2}c^{4} + a^{2}bc^{5} - ab^{6}c + ab^{5}c^{2} - ab^{4}c^{3} - ab^{3}c^{4} + ab^{2}c^{5} - abc^{6} + b^{8} - 2 b^{5}c^{3} + 3 b^{4}c^{4} - 2 b^{3}c^{5} + c^{8}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**8 - a**6*b*c - 2*a**5*b**3 + a**5*b**2*c + a**5*b*c**2 - 2*a**5*c**3 + 3*a**4*b**4 - a**4*b**3*c + 2*a**4*b**2*c**2 - a**4*b*c**3 + 3*a**4*c**4 - 2*a**3*b**5 - a**3*b**4*c - a**3*b**3*c**2 - a**3*b**2*c**3 - a**3*b*c**4 - 2*a**3*c**5 + a**2*b**5*c + 2*a**2*b**4*c**2 - a**2*b**3*c**3 + 2*a**2*b**2*c**4 + a**2*b*c**5 - a*b**6*c + a*b**5*c**2 - a*b**4*c**3 - a*b**3*c**4 + a*b**2*c**5 - a*b*c**6 + b**8 - 2*b**5*c**3 + 3*b**4*c**4 - 2*b**3*c**5 + c**8, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "19\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( y^{18}z^{9} + 2 y^{16}z^{14} - y^{15}z^{9} + 2 y^{14}z^{16} - y^{14}z^{13} - y^{13}z^{14} - y^{13}z^{11} - y^{12}z^{12} + y^{12}z^{9} - y^{11}z^{13} - y^{11}z^{7} + 2 y^{11}z^{4} - y^{10}z^{5} + y^{9}z^{18} - y^{9}z^{15} + y^{9}z^{12} - y^{9}z^{6} - y^{8}z^{4} - y^{7}z^{11} - y^{7}z^{5} + 2 y^{7}z^{2} - y^{6}z^{9} + y^{6}z^{6} - y^{5}z^{10} - y^{5}z^{7} + 2 y^{4}z^{11} - y^{4}z^{8} - y^{3}z^{3} + 2 y^{2}z^{7} + 1, y, z, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(y**18*z**9 + 2*y**16*z**14 - y**15*z**9 + 2*y**14*z**16 - y**14*z**13 - y**13*z**14 - y**13*z**11 - y**12*z**12 + y**12*z**9 - y**11*z**13 - y**11*z**7 + 2*y**11*z**4 - y**10*z**5 + y**9*z**18 - y**9*z**15 + y**9*z**12 - y**9*z**6 - y**8*z**4 - y**7*z**11 - y**7*z**5 + 2*y**7*z**2 - y**6*z**9 + y**6*z**6 - y**5*z**10 - y**5*z**7 + 2*y**4*z**11 - y**4*z**8 - y**3*z**3 + 2*y**2*z**7 + 1, y, z, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3} - a^{2}b - a^{2}c - ab^{2} + 3 abc - ac^{2} + b^{3} - b^{2}c - bc^{2} + c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3 - a**2*b - a**2*c - a*b**2 + 3*a*b*c - a*c**2 + b**3 - b**2*c - b*c**2 + c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "21\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 y^{4}z^{2} - y^{3}z^{3} - 5 y^{3}z + 2 y^{2}z^{4} - 9 y^{2}z^{2} + 5 y^{2} - 5 yz^{3} + 23 yz + 5 z^{2} - 9, y, z, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*y**4*z**2 - y**3*z**3 - 5*y**3*z + 2*y**2*z**4 - 9*y**2*z**2 + 5*y**2 - 5*y*z**3 + 23*y*z + 5*z**2 - 9, y, z, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "22\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{\\frac{5}{2}}b\\frac{1}{\\sqrt{a b + a + b + 1}} + 2 a^{\\frac{5}{2}}\\frac{1}{\\sqrt{a b + a + b + 1}} + 2 a^{2}b^{\\frac{7}{2}}\\frac{1}{\\sqrt{b + 1}} + 2 a^{2}b^{\\frac{5}{2}}\\frac{1}{\\sqrt{b + 1}} + 2 a^{2}b^{2}\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - a^{2}b^{2}\\sqrt{3} + 2 a^{2}b\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - a^{2}b\\sqrt{3} + 2 a^{\\frac{3}{2}}b\\frac{1}{\\sqrt{a b + a + b + 1}} + 4 ab^{\\frac{7}{2}}\\frac{1}{\\sqrt{b + 1}} + 4 ab^{\\frac{5}{2}}\\frac{1}{\\sqrt{b + 1}} + 4 ab^{2}\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - 2 ab^{2}\\sqrt{3} + 2 ab^{\\frac{3}{2}}\\frac{1}{\\sqrt{b + 1}} + 6 ab\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - 2 ab\\sqrt{3} + 2 a\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - a\\sqrt{3} + 2 b^{\\frac{7}{2}}\\frac{1}{\\sqrt{b + 1}} + 2 b^{\\frac{5}{2}}\\frac{1}{\\sqrt{b + 1}} + 2 b^{2}\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - b^{2}\\sqrt{3} + 4 b\\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}} - b\\sqrt{3} + 2 \\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}}, \\sqrt{a}, \\sqrt{b}, \\frac{1}{a b \\sqrt{a b + a + b + 1} + a \\sqrt{a b + a + b + 1} + b \\sqrt{a b + a + b + 1} + \\sqrt{a b + a + b + 1}}, \\frac{1}{\\sqrt{a b + a + b + 1}}, \\frac{1}{\\sqrt{b + 1}}, \\sqrt{3}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*(sqrt(a))**5*(sqrt(b))**2*(1/sqrt(a*b + a + b + 1)) + 2*(sqrt(a))**5*(1/sqrt(a*b + a + b + 1)) + 2*(sqrt(a))**4*(sqrt(b))**7*(1/sqrt(b + 1)) + 2*(sqrt(a))**4*(sqrt(b))**5*(1/sqrt(b + 1)) + 2*(sqrt(a))**4*(sqrt(b))**4*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - (sqrt(a))**4*(sqrt(b))**4*(sqrt(3)) + 2*(sqrt(a))**4*(sqrt(b))**2*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - (sqrt(a))**4*(sqrt(b))**2*(sqrt(3)) + 2*(sqrt(a))**3*(sqrt(b))**2*(1/sqrt(a*b + a + b + 1)) + 4*(sqrt(a))**2*(sqrt(b))**7*(1/sqrt(b + 1)) + 4*(sqrt(a))**2*(sqrt(b))**5*(1/sqrt(b + 1)) + 4*(sqrt(a))**2*(sqrt(b))**4*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - 2*(sqrt(a))**2*(sqrt(b))**4*(sqrt(3)) + 2*(sqrt(a))**2*(sqrt(b))**3*(1/sqrt(b + 1)) + 6*(sqrt(a))**2*(sqrt(b))**2*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - 2*(sqrt(a))**2*(sqrt(b))**2*(sqrt(3)) + 2*(sqrt(a))**2*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - (sqrt(a))**2*(sqrt(3)) + 2*(sqrt(b))**7*(1/sqrt(b + 1)) + 2*(sqrt(b))**5*(1/sqrt(b + 1)) + 2*(sqrt(b))**4*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - (sqrt(b))**4*(sqrt(3)) + 4*(sqrt(b))**2*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))) - (sqrt(b))**2*(sqrt(3)) + 2*(1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1))), sqrt(a), sqrt(b), 1/(a*b*sqrt(a*b + a + b + 1) + a*sqrt(a*b + a + b + 1) + b*sqrt(a*b + a + b + 1) + sqrt(a*b + a + b + 1)), 1/sqrt(a*b + a + b + 1), 1/sqrt(b + 1), sqrt(3), domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "23\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{4} - 4 abcd + b^{4} + c^{4} + d^{4}, a, b, c, d, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**4 - 4*a*b*c*d + b**4 + c**4 + d**4, a, b, c, d, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "24\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{3}b^{2} + a^{3}c^{2} + a^{2}b^{3} - 2 a^{2}b^{2}c - 2 a^{2}bc^{2} + a^{2}c^{3} - 2 ab^{2}c^{2} + b^{3}c^{2} + b^{2}c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**3*b**2 + a**3*c**2 + a**2*b**3 - 2*a**2*b**2*c - 2*a**2*b*c**2 + a**2*c**3 - 2*a*b**2*c**2 + b**3*c**2 + b**2*c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "25\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( def + de + df - 2 \\sqrt{d}\\sqrt{e} - 2 \\sqrt{d}\\sqrt{f} + ef - 2 \\sqrt{e}\\sqrt{f} + f + 2, \\sqrt{d}, \\sqrt{e}, \\sqrt{f}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly((sqrt(d))**2*(sqrt(e))**2*(sqrt(f))**2 + (sqrt(d))**2*(sqrt(e))**2 + (sqrt(d))**2*(sqrt(f))**2 - 2*(sqrt(d))*(sqrt(e)) - 2*(sqrt(d))*(sqrt(f)) + (sqrt(e))**2*(sqrt(f))**2 - 2*(sqrt(e))*(sqrt(f)) + (sqrt(f))**2 + 2, sqrt(d), sqrt(e), sqrt(f), domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "26\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( de^{2}f^{2} + de^{2}f + 2 def^{2} - 6 def + de + df^{2} + df + e^{2}f^{2} + e^{2}f + 2 ef^{2} + 3 ef + e + f^{2} + 2 f + 1, d, e, f, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(d*e**2*f**2 + d*e**2*f + 2*d*e*f**2 - 6*d*e*f + d*e + d*f**2 + d*f + e**2*f**2 + e**2*f + 2*e*f**2 + 3*e*f + e + f**2 + 2*f + 1, d, e, f, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "27\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( s^{2}def + s^{2}, s, d, e, f, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(s**2*d*e*f + s**2, s, d, e, f, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "28\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( -2 \\sqrt{3}x_{1}x_{2} - 2 \\sqrt{3}x_{2}x_{3} - 2 \\sqrt{3}x_{3}x_{4} - 2 \\sqrt{3}x_{4}x_{5} + 3 x_{1}^{2} + 3 x_{2}^{2} + 3 x_{3}^{2} + 3 x_{4}^{2} + 3 x_{5}^{2}, \\sqrt{3}, x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(-2*(sqrt(3))*x_1*x_2 - 2*(sqrt(3))*x_2*x_3 - 2*(sqrt(3))*x_3*x_4 - 2*(sqrt(3))*x_4*x_5 + 3*x_1**2 + 3*x_2**2 + 3*x_3**2 + 3*x_4**2 + 3*x_5**2, sqrt(3), x_1, x_2, x_3, x_4, x_5, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "29\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 7 a^{2}b^{3} - 6 a^{2}b^{2} - 6 a^{2}b + 7 a^{2} + 14 ab^{3} - 12 ab^{2} + 15 ab - 13 a + 7 b^{3} - 6 b^{2} - 6 b + 7, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(7*a**2*b**3 - 6*a**2*b**2 - 6*a**2*b + 7*a**2 + 14*a*b**3 - 12*a*b**2 + 15*a*b - 13*a + 7*b**3 - 6*b**2 - 6*b + 7, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "30\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{2}b^{2} + a^{2}b + 2 ab^{2} + ab + a + b^{2} + b, a, b, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**2*b**2 + a**2*b + 2*a*b**2 + a*b + a + b**2 + b, a, b, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "31\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( -2 \\frac{1}{\\sqrt{b}}\\sqrt{\\frac{a^{2} b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a^{2} b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1}} - 2 \\frac{1}{\\sqrt{b}}\\sqrt{\\frac{a b}{a^{2} b + a^{2} + a b + 2 a + 1} + \\frac{b}{a^{2} b + a^{2} + a b + 2 a + 1}} - 2 \\sqrt{\\frac{a^{2} b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a^{2} b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1}}\\sqrt{\\frac{a b}{a^{2} b + a^{2} + a b + 2 a + 1} + \\frac{b}{a^{2} b + a^{2} + a b + 2 a + 1}} + 3, \\frac{1}{\\sqrt{b}}, \\sqrt{\\frac{a^{2} b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a^{2} b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b^{2}}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1} + \\frac{a b}{a^{2} b + a^{2} + a b^{2} + 3 a b + 2 a + b^{2} + 2 b + 1}}, \\sqrt{\\frac{a b}{a^{2} b + a^{2} + a b + 2 a + 1} + \\frac{b}{a^{2} b + a^{2} + a b + 2 a + 1}}, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(-2*(1/sqrt(b))*(sqrt(a**2*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a**2*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1))) - 2*(1/sqrt(b))*(sqrt(a*b/(a**2*b + a**2 + a*b + 2*a + 1) + b/(a**2*b + a**2 + a*b + 2*a + 1))) - 2*(sqrt(a**2*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a**2*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1)))*(sqrt(a*b/(a**2*b + a**2 + a*b + 2*a + 1) + b/(a**2*b + a**2 + a*b + 2*a + 1))) + 3, 1/sqrt(b), sqrt(a**2*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a**2*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b**2/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1) + a*b/(a**2*b + a**2 + a*b**2 + 3*a*b + 2*a + b**2 + 2*b + 1)), sqrt(a*b/(a**2*b + a**2 + a*b + 2*a + 1) + b/(a**2*b + a**2 + a*b + 2*a + 1)), domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "32\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( a^{5}b^{2} + a^{5}c^{2} + a^{4}b^{3} - a^{4}b^{2}c - a^{4}bc^{2} - a^{4}c^{3} - a^{3}b^{4} + a^{3}c^{4} + a^{2}b^{5} - a^{2}b^{4}c - a^{2}bc^{4} + a^{2}c^{5} - ab^{4}c^{2} - ab^{2}c^{4} + b^{5}c^{2} + b^{4}c^{3} - b^{3}c^{4} + b^{2}c^{5}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(a**5*b**2 + a**5*c**2 + a**4*b**3 - a**4*b**2*c - a**4*b*c**2 - a**4*c**3 - a**3*b**4 + a**3*c**4 + a**2*b**5 - a**2*b**4*c - a**2*b*c**4 + a**2*c**5 - a*b**4*c**2 - a*b**2*c**4 + b**5*c**2 + b**4*c**3 - b**3*c**4 + b**2*c**5, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "33\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{2}d^{3} - a^{2}d^{2} - a^{2}d + 2 a^{2} + 4 ad^{3} - 2 ad^{2} - 3 a + 2 d^{3} - d^{2} - d + 2, a, d, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**2*d**3 - a**2*d**2 - a**2*d + 2*a**2 + 4*a*d**3 - 2*a*d**2 - 3*a + 2*d**3 - d**2 - d + 2, a, d, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "34\n" + ] + }, + { + "data": { + "text/latex": [ + "$\\displaystyle \\operatorname{Poly}{\\left( 2 a^{3} - 3 a^{2}b + a^{2}c + ab^{2} - 3 ac^{2} + 2 b^{3} - 3 b^{2}c + bc^{2} + 2 c^{3}, a, b, c, domain=\\mathbb{Z} \\right)}$" + ], + "text/plain": [ + "Poly(2*a**3 - 3*a**2*b + a**2*c + a*b**2 - 3*a*c**2 + 2*b**3 - 3*b**2*c + b*c**2 + 2*c**3, a, b, c, domain='ZZ')" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for i,ineq in zip(range(len(ineqs2)),ineqs2):\n", + " print(i)\n", + " display(reducegens(assumeall(ineq,positive=True)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Most formulas was converted to polynomials of independent variables. However formulas No. 22 and No. 31 were not. For this reason it's very unlikely that any method of proving these ones will succeed.\n", + "\n", + "Now let's try some methods of proving these inequalities. The first one would be the simple `prove`." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "tm=[0]*4" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,2,0,0,2,2,0,2,2,0,2,0,2,0,\n", + "20.714609994000057\n" + ] + }, + { + "data": { + "text/plain": [ + "Counter({0: 21, 2: 14})" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from collections import Counter\n", + "from timeit import default_timer as timer\n", + "start=timer()\n", + "t=[]\n", + "for ineq in ineqs2:\n", + " t+=[prove(ineq)]\n", + " print(t[-1],end=',')\n", + "tm[0]=timer()-start\n", + "print('\\n',tm[0],sep='')\n", + "Counter(t)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Code 0 means that the proof was found, all other codes means that proof wasn't found. So this method has proved 21 inequalities.\n", + "\n", + "The second method uses `findvalues` function, rationalizes the result numbers and gives them as additional parameter to `prove` function." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,2,0,0,2,0,0,2,2,0,2,0,2,0,\n", + "21.832711064998875\n" + ] + }, + { + "data": { + "text/plain": [ + "Counter({0: 24, 2: 11})" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def cut(a):\n", + " if a<=0 or a>=100 or (a is None):\n", + " return 1\n", + " return a\n", + "start=timer()\n", + "t2=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " values=nsimplify(numvalues,tolerance=0.1,rational=True)\n", + " values=list(map(cut,values))\n", + " t2+=[prove(ineq,values=values)]\n", + " print(t2[-1],end=',')\n", + "tm[1]=timer()-start\n", + "print('\\n',tm[1],sep='')\n", + "Counter(t2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The third method is similar to the second one, but instead of rationalize values it squares, rationalizes and makes square roots of these values." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0,2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,2,0,0,2,0,0,2,2,0,2,0,2,0,\n", + "21.697120987002563\n" + ] + }, + { + "data": { + "text/plain": [ + "Counter({0: 23, 2: 12})" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def cut(a):\n", + " if a<=0 or a>=1000 or (a is None):\n", + " return S(1)\n", + " return a\n", + " \n", + "start=timer()\n", + "t3=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " numvalues=tuple([x**2 for x in numvalues])\n", + " values=nsimplify(numvalues,tolerance=0.1,rational=True)\n", + " values=[sqrt(x) for x in values]\n", + " values=list(map(cut,values))\n", + " t3+=[prove(ineq,values=values)]\n", + " print(t3[-1],end=',')\n", + "tm[2]=timer()-start\n", + "print('\\n',tm[2],sep='')\n", + "Counter(t3)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, the fourth method is a slight modification to the third method. It does the same \"findvalues, square, rationalize and make square roots\" thing, but then it scales the values and runs it again. It can sometimes help with uniform formulas." + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0,2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,2,0,0,2,0,0,0,2,0,2,0,2,0,\n", + "23.187820409999404\n" + ] + }, + { + "data": { + "text/plain": [ + "Counter({0: 24, 2: 11})" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "def betw(a):\n", + " return a>0.001 and a<1000 and a!=None\n", + "def cut(a):\n", + " if betw(a):\n", + " return a\n", + " return S(1)\n", + "\n", + "start=timer()\n", + "t4=[]\n", + "for ineq in ineqs2:\n", + " numvalues=findvalues(ineq,disp=0)\n", + " n=1\n", + " numvalues2=[]\n", + " for i in numvalues:\n", + " if betw(i):\n", + " n=1/i\n", + " break\n", + " for i in numvalues:\n", + " if betw(i):\n", + " numvalues2+=[i*n]\n", + " else:\n", + " numvalues2+=[1]\n", + " numvalues3=findvalues(ineq,values=numvalues2,disp=0)\n", + " numvalues4=tuple([x**2 for x in numvalues3])\n", + " values=nsimplify(numvalues4,tolerance=0.1,rational=True)\n", + " values=[sqrt(x) for x in values]\n", + " values=list(map(cut,values))\n", + " t4+=[prove(ineq,values=values)]\n", + " print(t4[-1],end=',')\n", + "tm[3]=timer()-start\n", + "print('\\n',tm[3],sep='')\n", + "Counter(t4)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi40LCBodHRwOi8vbWF0cGxvdGxpYi5vcmcv7US4rQAAD8RJREFUeJzt3X2sJXV9x/H3R8CqiAHChW7B7dVWqbRBSDaIpSY+EnwCwecUNUjdpkrFaB+wGsWaptb6lJqm7aIIrUolFRQrrcV1Cda26qIIi0AwiBbZslCru0qKAt/+cWbrFXfvmX2YM3v2934lJ+fM78zD905y7+fOzG9+k6pCktSuB41dgCRpXAaBJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmNMwgkqXH7jl1AH4ccckgtLi6OXYYkzZWrr776rqpamDbfXATB4uIi69evH7sMSZorSb7VZz5PDUlS4wwCSWqcQSBJjTMIJKlxBoEkNc4gkKTGGQSS1DiDQJIaZxBIUuPm4s5iSW1aPOfTY5cwulvf8ezBt+ERgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjTMIJKlxBoEkNc4gkKTGGQSS1DjHGtKyWh/rZRbjvEhjMwikARmkBuk88NSQJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmNMwgkqXF7/Q1l3tDjDT2SlucRgSQ1ziCQpMYNFgRJHplkXZIbklyf5Oyu/eAkVyS5uXs/aKgaJEnTDXlEcC/whqp6HHA88JokRwHnAGur6jHA2m5akjSSwYKgqjZW1Ve6z1uAG4DDgVOAC7vZLgSeN1QNkqTpZnKNIMkicCzwReCwqtoIk7AADt3OMquTrE+y/s4775xFmZLUpMGDIMnDgY8Dr6uqzX2Xq6o1VbWqqlYtLCwMV6AkNW7QIEiyH5MQ+EhVXdI135FkRff9CmDTkDVIkpY3ZK+hAB8Ebqiq9yz56jLgFd3nVwCfHKoGSdJ0Q95ZfALwMuC6JNd0bX8EvAO4OMmZwLeBFw5YgyRpisGCoKr+Fch2vn7aUNuVJO0Y7yyWpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjTMIJKlxBoEkNc4gkKTGGQSS1DiDQJIaZxBIUuMMAklqnEEgSY0zCCSpcQaBJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmNMwgkqXEGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWrcvst9meQveqxjc1W9eTfVI0masWWDADgFeMuUec4BDAJJmlPTguC9VXXhcjMkOWg31iNJmrFlrxFU1fumraDPPJKkPVevi8VJ3pnkEUn2S7I2yV1JTh+6OEnS8Pr2GjqxqjYDzwFuAx4L/P5gVUmSZqZvEOzXvT8LuKiqvjttgSTnJ9mUZMOStnOTfCfJNd3rWTtRsyRpN+obBJ9KciOwClibZAH43ynLXACctI3291bVMd3r8v6lSpKG0CsIquoc4InAqqr6MXA3k66lyy1zFTD1yEGSNK5pN5Sdto22pZOX7MQ2z0rycmA98Iaq+p+dWIckaTeZdh/Bc7v3Q4FfBz7XTT8FuJIdD4K/At4OVPf+buCV25oxyWpgNcDKlSt3cDOSpL6m3UdwRlWdweQP91FV9fyqej7wqzuzsaq6o6ruq6r7gfOA45aZd01VraqqVQsLCzuzOUlSD30vFi9W1cYl03cw6UK6Q5KsWDJ5KrBhe/NKkmZj2qmhra5M8hngIiZHBy8B1i23QJKLgCcDhyS5DXgr8OQkx3TruBX47Z0rW5K0u/QKgqo6q7tw/KSuaU1VXTplmZduo/mDO1ifJGlgfY8IqKpL2LleQpKkPVjfsYZOS3Jzku8n2ZxkS5LNQxcnSRpe3yOCdwLPraobhixGkjR7fXsN3WEISNLeqe8RwfokHwM+AdyztbG7biBJmmN9g+ARTMYXOnFJW+HFY0mae327j54xdCGSpHH07TV0RJJLu+cL3JHk40mOGLo4SdLw+l4s/hBwGfALwOHAp7o2SdKc6xsEC1X1oaq6t3tdADgSnCTtBfoGwV1JTk+yT/c6HfjvIQuTJM1G3yB4JfAi4L+AjcAL2M5zBCRJ86Vvr6FvAycPXIskaQR9ew1dmOTAJdMHJTl/uLIkSbPS99TQ0VX1va0T3XOGjx2mJEnSLPUNggclOWjrRJKD2YEhrCVJe66+f8zfDfxbkn9gMrTEi4A/GawqSdLM9L1Y/LdJ1gNPBQKcVlVfH7QySdJM9D01BHAw8MOqej9wZ5JHDVSTJGmG+vYaeivwh8Abu6b9gA8PVZQkaXb6HhGcyuQ+gh8CVNXtwAFDFSVJmp2+QfCjqiomF4pJsv9wJUmSZqlvEFyc5G+AA5O8CvgscN5wZUmSZqVvr6F3JXkGsBk4EnhLVV0xaGWSpJnoFQTdqaDPVdUVSY4EjkyyX1X9eNjyJElD63tq6Crg55IczuS00BnABUMVJUmanb5BkKq6GzgNeH9VnQocNVxZkqRZ6R0ESZ4I/Cbw6a7NsYYkaS/QNwjOZnIz2aVVdX2SRwPrhitLkjQrfXsNXcXkOsHW6VuA1w5VlCRpdpY9Ikhy7rQV9JlHkrTnmnZE8FtJNi/zfYCXAOfutookSTM1LQjOY/qYQt5hLElzbNkgqKq3zaoQSdI4duR5BJKkvZBBIEmNGywIkpyfZFOSDUvaDk5yRZKbu/eDhtq+JKmfvk8oe2yStVv/qCc5Osmbpyx2AXDSA9rOAdZW1WOAtd20JGlEfY8IzmNyZ/GPAarqWibdRreruwntuw9oPgW4sPt8IfC83pVKkgbRNwgeVlVfekDbvTuxvcOqaiNA937o9mZMsjrJ+iTr77zzzp3YlCSpj75BcFeSX+Inj6p8AbBxsKqAqlpTVauqatXCwsKQm5KkpvUdQfQ1wBrgV5J8B/gmcPpObO+OJCuqamOSFcCmnViHJGk36jvo3C3A07snlT2oqrbs5PYuA14BvKN7/+ROrkeStJv0fVTlgcDLgUVg3yQAVNV2RyBNchHwZOCQJLcBb2USABcnORP4NvDCXahdkrQb9D01dDnwH8B1wP19Fqiql27nq6f13KYkaQb6BsFDqur1g1YiSRpF315Df5fkVUlWdHcHH5zk4EErkyTNRN8jgh8Bfw68ia4Laff+6CGKkiTNTt8geD3wy1V115DFSJJmr++poeuBu4csRJI0jr5HBPcB1yRZB9yztXG57qOSpPnQNwg+0b0kSXuZvncWXzh9LknSPFo2CJJcXFUvSnIdP+kt9P+q6ujBKpMkzcS0I4Kzu/fnDF2IJGkcy/Ya2vrsAODVVfWtpS/g1cOXJ0kaWt/uo8/YRtszd2chkqRxTLtG8DtM/vN/dJJrl3x1APCFIQuTJM3GtGsEHwX+CfhTfvpB81uq6oHPI5YkzaFlg6Cqvg98H9jekNKSpDnX9xqBJGkvZRBIUuMMAklqnEEgSY0zCCSpcQaBJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmNMwgkqXEGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjVv24fVDSXIrsAW4D7i3qlaNUYckaaQg6Dylqu4acfuSJDw1JEnNGysICviXJFcnWT1SDZIkxjs1dEJV3Z7kUOCKJDdW1VVLZ+gCYjXAypUrx6hRkpowyhFBVd3evW8CLgWO28Y8a6pqVVWtWlhYmHWJktSMmQdBkv2THLD1M3AisGHWdUiSJsY4NXQYcGmSrdv/aFX98wh1SJIYIQiq6hbg8bPeriRp2+w+KkmNMwgkqXEGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjTMIJKlxBoEkNc4gkKTGGQSS1DiDQJIaZxBIUuMMAklqnEEgSY0zCCSpcQaBJDXOIJCkxhkEktQ4g0CSGmcQSFLjDAJJapxBIEmNMwgkqXEGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjTMIJKlxBoEkNc4gkKTGjRIESU5KclOSbyQ5Z4waJEkTMw+CJPsAfwk8EzgKeGmSo2ZdhyRpYowjguOAb1TVLVX1I+DvgVNGqEOSxDhBcDjwn0umb+vaJEkj2HeEbWYbbfUzMyWrgdXd5A+S3DRoVcM5BLhrrI3nz8ba8m7j/ts17r9dM+r+g13eh7/YZ6YxguA24JFLpo8Abn/gTFW1Blgzq6KGkmR9Va0au4555f7bNe6/XdPK/hvj1NCXgcckeVSSBwMvAS4boQ5JEiMcEVTVvUnOAj4D7AOcX1XXz7oOSdLEGKeGqKrLgcvH2PYI5v701sjcf7vG/bdrmth/qfqZ67SSpIY4xIQkNc4gGEiS85NsSrJh7FrmUZJHJlmX5IYk1yc5e+ya5kmShyT5UpKvdfvvbWPXNI+S7JPkq0n+cexahmQQDOcC4KSxi5hj9wJvqKrHAccDr3Eokh1yD/DUqno8cAxwUpLjR65pHp0N3DB2EUMzCAZSVVcB3x27jnlVVRur6ivd5y1Mfhm9A72nmvhBN7lf9/KC4A5IcgTwbOADY9cyNINAe7wki8CxwBfHrWS+dKc1rgE2AVdUlftvx7wP+APg/rELGZpBoD1akocDHwdeV1Wbx65nnlTVfVV1DJO7949L8mtj1zQvkjwH2FRVV49dyywYBNpjJdmPSQh8pKouGbueeVVV3wOuxGtWO+IE4OQktzIZIfmpST48bknDMQi0R0oS4IPADVX1nrHrmTdJFpIc2H1+KPB04MZxq5ofVfXGqjqiqhaZDIPzuao6feSyBmMQDCTJRcC/A0cmuS3JmWPXNGdOAF7G5D+xa7rXs8Yuao6sANYluZbJ+F5XVNVe3QVSO887iyWpcR4RSFLjDAJJapxBIEmNMwgkqXEGgSQ1ziCQdlCSY5Z2ZU1ybpLf24X17dLy0q4yCKQddwzgPQ3aaxgEalKSxSQ3JvlAkg1JPpLk6Um+kOTmJMcl2b97rsSXuzHpT0nyYOCPgRd3N7m9uFvlUUmuTHJLktcu2c7ru/VvSPK6Je1vSnJTks8CR872p5d+mjeUqUndiKbfYDKq6fVM7r79GnAmcDJwBvB14OtV9eFuuIYvdfO/EFhVVWd16zoXOBF4CnAAcBPw88DRTJ5LcTwQJqOnns7kH7ALgCcweW74V4C/rqp3DfkzS9szysPrpT3EN6vqOoAk1wNrq6qSXAcsMhm18+Ql5+8fAqzczro+XVX3APck2QQcBvwGcGlV/bDbxiXAk5gEwaVVdXfXftkgP53Uk0Gglt2z5PP9S6bvZ/K7cR/w/Kq6aelCSZ4wZV33dctnmW17KK49htcIpO37DPC73UioJDm2a9/C5BTQNFcBz0vysCT7A6cCn+/aT03y0CQHAM/d/aVL/RkE0va9nckjHq9NsqGbBljH5OLw0ovFP6N71OYFTK4tfBH4QFV9tWv/GHANk+ctfH64H0GazovFktQ4jwgkqXEGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSBJjfs/ZA6/DVKt+QAAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "plt.bar(['1','2','3','4'],tm)\n", + "plt.ylabel('time [seconds]')\n", + "plt.xlabel('method')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "u=pd.DataFrame(zip(['']*len(ineqs),t,t2,t3,t4))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEKCAYAAAAfGVI8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi40LCBodHRwOi8vbWF0cGxvdGxpYi5vcmcv7US4rQAAFQBJREFUeJzt3X/wXXV95/HnS34sGmEhEjAFY6DDsFLHBPsdSkXdCtLiqgR3ddGpNKOZTVuowuC2G11brXZ3cX8otrO7bQou8bcUoURFLU2hVOuACb8hsLGIkCWSKCogO7iB9/5xT8rXmO/9nm/yPffmm/N8zNw595x7frzvnSSvnPM5n/NJVSFJ6q9njbsASdJ4GQSS1HMGgST1nEEgST1nEEhSzxkEktRzBoEk9ZxBIEk9ZxBIUs/tP+4C2jj88MNr8eLF4y5DkuaUDRs2fK+qFky33pwIgsWLF7N+/fpxlyFJc0qS77RZz0tDktRznQVBkuOT3Drp9WiSC5LMT3Jtkk3N9LCuapAkTa+zIKiqe6tqaVUtBX4ReAK4ClgFrKuq44B1zbwkaUxGdWnoNOAfquo7wDJgTbN8DXDWiGqQJO3CqILgzcBnmvdHVtUWgGZ6xK42SLIyyfok67dt2zaiMiWpfzoPgiQHAmcCfzGT7apqdVVNVNXEggXT3v0kSdpNozgjeA1wc1U93Mw/nGQhQDPdOoIaJElTGEUQvIVnLgsBrAWWN++XA1ePoAZJ0hQ6DYIkzwFOB66ctPgi4PQkm5rPLuqyBknScJ32LK6qJ4Dn7bTs+wzuItIcsHjVl8Zdwljdf9Frx11Cr/nnbzR//uxZLEk9ZxBIUs8ZBJLUcwaBJPWcQSBJPWcQSFLPGQSS1HNzYoQyaa7yPnj7YcwFnhFIUs8ZBJLUcwaBJPWcQSBJPWcQSFLPGQSS1HMGgST1nEEgST1nEEhSzxkEktRzBoEk9ZxBIEk9ZxBIUs91GgRJDk1yRZJ7kmxM8stJ5ie5NsmmZnpYlzVIkobr+ozgo8BXquqfAUuAjcAqYF1VHQesa+YlSWPSWRAkOQR4JXApQFX9pKp+CCwD1jSrrQHO6qoGSdL0ujwjOBbYBvyvJLckuSTJPODIqtoC0EyP6LAGSdI0uhyhbH/gpcA7qurGJB9lBpeBkqwEVgIsWrRot4twhChHiJI0XJdnBJuBzVV1YzN/BYNgeDjJQoBmunVXG1fV6qqaqKqJBQsWdFimJPVbZ0FQVd8FHkxyfLPoNOBuYC2wvFm2HLi6qxokSdPrevD6dwCfSnIgcB/wNgbhc3mSFcADwJs6rkGSNESnQVBVtwITu/jotC6PK0lqz57FktRzBoEk9ZxBIEk9ZxBIUs8ZBJLUcwaBJPWcQSBJPWcQSFLPGQSS1HMGgST1nEEgST035bOGkvxxi+0frar3zmI9kqQRG/bQuWXAH0yz/SrAIJCkOWxYEHykqtYM+Zwkh81yPZKkEZuyjaCqLp5u4zbrSJL2bq0bi5O8PsmNSW5Ncm6XRUmSRmfKIEiyZKdF5wAnMxh3+Le7LEqSNDrD2gjOTRLgD3aMPwz8B+Bp4KFRFCdJ6t6UQVBVv9mcFfxZkvXA7wMvA54DfHBE9UmSOja0jaCqbquqZcCtwFpgYVWtraonR1KdJKlzw9oIfivJLUluBuYBZwCHJflqkleMrEJJUqeGnRGcW1UnMmgg/t2q2l5Vfwy8GXhDm50nuT/JHc2dRuubZfOTXJtkUzO1L4IkjdGwIPg/ST4I/Efgnh0Lq+oHVXXhDI7xqqpaWlUTzfwqYF1VHQesa+YlSWMyLAiWATcBfw38xiwecxmwo8fyGuCsWdy3JGmGhgXB/Kr6QlV9paqe2tUKSZ4/zf4L+KskG5KsbJYdWVVbAJrpETOuWpI0a4b1I7iGQeexYaZb55SqeijJEcC1Se4Zsu5PaYJjJcCiRYvabiZJmqFhQbAkyaNDPg8w7HOq6qFmujXJVcBJwMNJFlbVliQLga1TbLsaWA0wMTFRw44jSdp9wx46t19VHTLkdXBVHTXV9knmJTl4x3vgV4E7GfRHWN6sthy4eva+jiRppoadEeypI4GrBk+pYH/g01X1lSTfBC5PsgJ4AHhThzVIkqbRWRBU1X3Azg+uo6q+D5zW1XElSTPjmMWS1HOtzgiS7MfgUs8/rl9VD3RVlCRpdKYNgiTvAN4HPMzgEdQw6B/wkg7rkiSNSJszgvOB45tr+5KkfUybNoIHgR91XYgkaTzanBHcB1yf5EvAP45DUFUf7qwqSdLItAmCB5rXgc1LkrQPmTYIquoPYdA7uKp+3H1JkqRRmraNIMkvJ7kb2NjML0nyPzqvTJI0Em0aiy8Gfg34PgzGMQZe2WVRkqTRadWzuKoe3GnRLscnkCTNPW0aix9M8jKgkhwIvJPmMpEkae5rc0bwW8B5wFHAZmBpMy9J2ge0OSNIVf1655VIksaizRnB3yf5qyQrkhzaeUWSpJGaNgiq6jjgvcAvADcn+WKSt3ZemSRpJNreNXRTVV3IYMzhR4A1nVYlSRqZNh3KDkmyPMmXgb8HtjAIBEnSPqBNY/FtwF8CH6iqb3RcjyRpxNoEwbFVVUkOTvLcqnq886okSSPTpo3gF5LcAtwJ3J1kQ5IXd1yXJGlE2gTBauDCqnphVS0C3tUsayXJfkluSfLFZv6YJDcm2ZTkc01vZUnSmLQJgnlVdd2Omaq6Hpg3g2Ocz08/kuJDwEea21J/AKyYwb4kSbOsTRDcl+T3kyxuXu8Fvt1m50mOBl4LXNLMBzgVuKJZZQ1w1szLliTNljZB8HZgAXBl8zoceFvL/V8M/B7wdDP/POCHVbW9md/M4BlGkqQxGXrXUJL9gPdU1TtnuuMkrwO2VtWGJL+yY/EuVq0ptl8JrARYtGjRTA8vSWpp6BlBVT0F/OJu7vsU4Mwk9wOfZXBJ6GLg0CQ7Auho4KEpjr26qiaqamLBggW7WYIkaTptLg3dkmRtknOS/Msdr+k2qqp3V9XRVbUYeDPwN81TTK8D3tisthy4eneLlyTtuTYdyuYzGKby1EnLikF7we74d8Bnk/wRcAtw6W7uR5I0C6YNgqpq2zA8bB/XA9c37+/DZxVJ0l6jzUPnjk3yhSTbkmxNcnWSY0ZRnCSpe23aCD4NXA4sBH4O+AsGjb+SpH1AmyBIVX2iqrY3r08yxS2fkqS5p01j8XVJVjE4CyjgbOBLSeYDVNUjHdYnSepYmyA4u5n+5k7L384gGI6d1YokSSPV5q4hG4YlaR/WasxiSdK+yyCQpJ4zCCSp59p0KDslybzm/VuTfDjJC7svTZI0Cm3OCP4n8ESSJQzGFvgO8PFOq5IkjUybINheVQUsAz5aVR8FDu62LEnSqLTpR/BYkncD5wCvaAarOaDbsiRJo9LmjOBs4Eng7VX1XQZDS/6XTquSJI3MtEHQ/OP/eeCfNIu+B1zVZVGSpNFpc9fQvwGuAP6sWXQU8JddFiVJGp02l4bOYzD+8KMAVbUJOKLLoiRJo9MmCJ6sqp/smGkGnvcx1JK0j2gTBH+b5D3As5OczmBgmi90W5YkaVTaBMEqYBtwB4NHUV8DvLfLoiRJo9PmMdRPA3/evCRJ+5gpgyDJ5VX1r5PcwS7aBKrqJZ1WJkkaiWFnBOc309ftzo6THATcwKD/wf7AFVX1viTHMBj2cj5wM3DO5MZoSdJoTdlGUFVbmrfnVtV3Jr+Ac1vs+0ng1KpaAiwFzkhyMvAh4CNVdRzwA2DFnn0FSdKeaNNYfPoulr1muo1q4PFm9oDmVcCpDDqoAawBzmpRgySpI1MGQZLfbtoHjk9y+6TXt4Hb2+w8yX5JbgW2AtcC/wD8sKq2N6tsZtBTeVfbrkyyPsn6bdu2zeQ7SZJmYFgbwaeBLwP/icEtpDs8VlWPtNl5VT0FLE1yKIPnE71oV6tNse1qYDXAxMSEHdgkqSPDgqCq6v4k5+38QZL5bcOg2dEPk1wPnAwcmmT/5qzgaOChmRYtSZo9w9oIPt1MNwDrm+mGSfNDJVnQnAmQ5NnAq4GNwHXAG5vVlgNX71blkqRZMeUZQVW9rpkes5v7XgisaQayeRZweVV9McndwGeT/BFwC3Dpbu5fkjQLhnUoe+mwDavq5mk+vx04cRfL7wNOalugJKlbw9oI/tuQz3bcBipJmuOGXRp61SgLkSSNR5vB60nyYuAE4KAdy6rq410VJUkanWmDIMn7gF9hEATXMOhV/DXAIJCkfUCbR0y8ETgN+G5VvQ1YwjMD2UuS5rg2QfB/mzEJtic5hMHjIo7ttixJ0qi0aSNY33QM+3MGnckeB27qtCpJ0si0GaFsxyOn/zTJV4BDmj4CkqR9QJvG4lfuallV3dBNSZKkUWpzaeh3J70/iEGv4A3YoUyS9gltLg29fvJ8khcA/7mziiRJI9XmrqGdbQZePNuFSJLGo00bwZ/wzOAxz2Iw/vBtXRYlSRqdVrePTnq/HfhMVX29o3okSSPWpo1gzSgKkSSNR5tLQ3ew63GFw2A4y5fMelWSpJFpc2noy830E83014EnAM8UJGkf0CYITqmqUybNr0ry9ar6QFdFSZJGp83to/OSvHzHTJKXAfO6K0mSNEptzghWAB9L8k8ZtBX8CHh7p1VJkkamzV1DG4AlzSOoU1U/6r4sSdKoTHtpKMmRSS4FPldVP0pyQpIVLbZ7QZLrkmxMcleS85vl85Ncm2RTMz1sFr6HJGk3tWkjuAz4KvBzzfz/Bi5osd124F1V9SLgZOC8JCcAq4B1VXUcsK6ZlySNSZsgOLyqLgeeBqiq7cBT021UVVuq6ubm/WPARuAoYBnP3Hq6BjhrN+qWJM2SNkHw4yTPo+lUluRkBg3GrSVZDJwI3AgcWVVbYBAWwBFTbLMyyfok67dt2zaTw0mSZqDNXUMXAmuBn0/ydWABgwHtW0nyXODzwAVV9WiSVttV1WpgNcDExMSuejZLkmZBm7uGbk7yz4HjGTxW4t6q+n9tdp7kAAYh8KmqurJZ/HCShVW1JclCYOtu1i5JmgVtxyM4CVgCvBR4S5LfmG6DDP7rfymwsao+POmjtcDy5v1y4Or25UqSZlubh859Avh54FaeaSQu4OPTbHoKcA5wR5Jbm2XvAS4CLm9uQX0AeNNu1C1JmiVt2ggmgBOqakbX6avqawwuJe3KaTPZlySpO20uDd0JPL/rQiRJ49HmjOBw4O4kNwFP7lhYVWd2VpUkaWTaBMH7uy5CkjQ+bW4f/dtRFCJJGo8pgyDJ16rq5Uke46eHqtwxROUhnVcnSerclEFQVS9vpgePrhxJ0qi17VAmSdpHGQSS1HMGgST1nEEgST1nEEhSzxkEktRzBoEk9ZxBIEk9ZxBIUs8ZBJLUcwaBJPWcQSBJPWcQSFLPGQSS1HMGgST1XGdBkORjSbYmuXPSsvlJrk2yqZke1tXxJUntdHlGcBlwxk7LVgHrquo4YF0zL0kao86CoKpuAB7ZafEyYE3zfg1wVlfHlyS1M+o2giOragtAMz1ixMeXJO1kr20sTrIyyfok67dt2zbuciRpnzXqIHg4yUKAZrp1qhWranVVTVTVxIIFC0ZWoCT1zaiDYC2wvHm/HLh6xMeXJO2ky9tHPwN8Azg+yeYkK4CLgNOTbAJOb+YlSWO0f1c7rqq3TPHRaV0dU5I0c3ttY7EkaTQMAknqOYNAknrOIJCknjMIJKnnDAJJ6jmDQJJ6ziCQpJ4zCCSp5wwCSeo5g0CSes4gkKSeMwgkqecMAknqOYNAknrOIJCknjMIJKnnDAJJ6jmDQJJ6ziCQpJ4zCCSp58YSBEnOSHJvkm8lWTWOGiRJAyMPgiT7Af8deA1wAvCWJCeMug5J0sA4zghOAr5VVfdV1U+AzwLLxlCHJInxBMFRwIOT5jc3yyRJY7D/GI6ZXSyrn1kpWQmsbGYfT3Jvp1V153Dge+M6eD40riPPGn+/PePvt2fm+u/3wjYrjSMINgMvmDR/NPDQzitV1Wpg9aiK6kqS9VU1Me465ip/vz3j77dn+vL7jePS0DeB45Ick+RA4M3A2jHUIUliDGcEVbU9ye8AXwX2Az5WVXeNug5J0sA4Lg1RVdcA14zj2GMw5y9vjZm/357x99szvfj9UvUz7bSSpB7xEROS1HMGQUeSfCzJ1iR3jruWuSjJC5Jcl2RjkruSnD/umuaSJAcluSnJbc3v94fjrmkuSrJfkluSfHHctXTJIOjOZcAZ4y5iDtsOvKuqXgScDJzno0hm5Eng1KpaAiwFzkhy8phrmovOBzaOu4iuGQQdqaobgEfGXcdcVVVbqurm5v1jDP4y2gO9pRp4vJk9oHnZIDgDSY4GXgtcMu5aumYQaK+XZDFwInDjeCuZW5rLGrcCW4Frq8rfb2YuBn4PeHrchXTNINBeLclzgc8DF1TVo+OuZy6pqqeqaimD3vsnJXnxuGuaK5K8DthaVRvGXcsoGATaayU5gEEIfKqqrhx3PXNVVf0QuB7brGbiFODMJPczeELyqUk+Od6SumMQaK+UJMClwMaq+vC465lrkixIcmjz/tnAq4F7xlvV3FFV766qo6tqMYPH4PxNVb11zGV1xiDoSJLPAN8Ajk+yOcmKcdc0x5wCnMPgf2K3Nq9/Me6i5pCFwHVJbmfwfK9rq2qfvgVSu8+exZLUc54RSFLPGQSS1HMGgST1nEEgST1nEEhSzxkE0gwlWTr5VtYk70/yb/dgf3u0vbSnDAJp5pYC9mnQPsMgUC8lWZzkniSXJLkzyaeSvDrJ15NsSnJSknnNuBLfbJ5JvyzJgcAHgLObTm5nN7s8Icn1Se5L8s5Jx7mw2f+dSS6YtPzfJ7k3yV8Dx4/220s/zQ5l6qXmiabfYvBU07sY9L69DVgBnAm8DbgbuLuqPtk8ruGmZv03ARNV9TvNvt4P/CrwKuBg4F7g+cBLGIxLcTIQBk9PfSuD/4BdBvwSg3HDbwb+tKr+a5ffWZrKWAavl/YS366qOwCS3AWsq6pKcgewmMFTO8+cdP3+IGDRFPv6UlU9CTyZZCtwJPBy4Kqq+nFzjCuBVzAIgquq6olm+dpOvp3UkkGgPnty0vunJ80/zeDvxlPAv6qqeydvlOSXptnXU832GXJsT8W117CNQJraV4F3NE9CJcmJzfLHGFwCms4NwFlJnpNkHvAG4O+a5W9I8uwkBwOvn/3SpfYMAmlqH2QwxOPtSe5s5gGuY9A4PLmx+Gc0Q21exqBt4Ubgkqq6pVn+OeBWBuMt/F13X0Gano3FktRznhFIUs8ZBJLUcwaBJPWcQSBJPWcQSFLPGQSS1HMGgST1nEEgST33/wEm667avpkz1QAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.bar(['1','2','3','4'],[sum(u[i]==0)/len(ineqs2)*100 for i in range(1,5)])\n", + "plt.ylabel('inequalities proven [%]')\n", + "plt.xlabel('method')\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Down below there are contingency tables and McNemar test for every pair of methods." + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
2FalseTrue
1
False113
True021
\n", + "
" + ], + "text/plain": [ + "2 False True \n", + "1 \n", + "False 11 3\n", + "True 0 21" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
3FalseTrue
1
False122
True021
\n", + "
" + ], + "text/plain": [ + "3 False True \n", + "1 \n", + "False 12 2\n", + "True 0 21" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
4FalseTrue
1
False113
True021
\n", + "
" + ], + "text/plain": [ + "4 False True \n", + "1 \n", + "False 11 3\n", + "True 0 21" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
3FalseTrue
2
False110
True123
\n", + "
" + ], + "text/plain": [ + "3 False True \n", + "2 \n", + "False 11 0\n", + "True 1 23" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
4FalseTrue
2
False101
True123
\n", + "
" + ], + "text/plain": [ + "4 False True \n", + "2 \n", + "False 10 1\n", + "True 1 23" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
4FalseTrue
3
False111
True023
\n", + "
" + ], + "text/plain": [ + "4 False True \n", + "3 \n", + "False 11 1\n", + "True 0 23" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "for i in range(4):\n", + " for j in range(i+1,4):\n", + " display(pd.crosstab(u[i+1]==0, u[j+1]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pvalue 0.25\n", + "statistic 0.0\n", + "pvalue 0.5\n", + "statistic 0.0\n", + "pvalue 0.25\n", + "statistic 0.0\n", + "pvalue 1.0\n", + "statistic 0.0\n", + "pvalue 1.0\n", + "statistic 1.0\n", + "pvalue 1.0\n", + "statistic 0.0\n" + ] + } + ], + "source": [ + "from statsmodels.stats.contingency_tables import mcnemar\n", + "for i in range(4):\n", + " for j in range(i+1,4):\n", + " print(mcnemar(pd.crosstab(u[i+1]==0, u[j+1]==0)))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In all cases p-value is greater than 0.05, so there is no statistical difference between the methods." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/statistics.pdf b/statistics.pdf new file mode 100644 index 0000000..5d30eec Binary files /dev/null and b/statistics.pdf differ