{ "cells": [ { "cell_type": "markdown", "id": "ce5d9df2", "metadata": {}, "source": [ "# Solving a Quartic Equation\n", "\n", "Ferrari's method first translates a quartic to\n", "\n", "$$\n", "y^4+py^2+qy+r=0.\n", "$$\n", "\n", "It then chooses a resolvent parameter $u$ so that the polynomial\n", "factors into two quadratics. The condition on $u$ is the cubic\n", "\n", "$$\n", "u(p+u)^2-4ru-q^2=0.\n", "$$\n" ] }, { "cell_type": "markdown", "id": "aa63359a", "metadata": {}, "source": [ "## Three structural cases\n", "\n", "A biquadratic ($q=0$) needs only two quadratic solves. A general\n", "depressed quartic uses the resolvent cubic. Finally,\n", "$x=y-b/4$ removes the cubic term from a monic quartic; a non-monic\n", "polynomial is normalized first.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "905d616d", "metadata": {}, "outputs": [], "source": [ "declare symbol x, y, u: MathValue\n", "\n", "def solveBiquadratic\n", " (p : MathValue)\n", " (q : MathValue)\n", " : (MathValue, MathValue, MathValue, MathValue) :=\n", " let (s1, s2) := qF' 1 p q\n", " (r1, r2) := qF' 1 0 (- s1)\n", " (r3, r4) := qF' 1 0 (- s2)\n", " in (r1, r2, r3, r4)\n" ] }, { "cell_type": "markdown", "id": "04d22c92", "metadata": {}, "source": [ "## Biquadratic shortcut\n", "\n", "For $x^4-5x^2+4=0$, the substitution $t=x^2$ yields\n", "$(t-1)(t-4)=0$. Solving first for $t$ and then taking the two\n", "square roots of each value gives all four roots.\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "79e4b59d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$(2, -2, 1, -1)$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "solveBiquadratic (-5) 4\n" ] }, { "cell_type": "markdown", "id": "321c1efc", "metadata": {}, "source": [ "## Ferrari's general branch\n", "\n", "Consider the already-depressed polynomial\n", "\n", "$$\n", "y^4-15y^2-10y+24\n", " =(y+3)(y+2)(y-1)(y-4).\n", "$$\n", "\n", "Here $(p,q,r)=(-15,-10,24)$, so this is genuinely outside the\n", "biquadratic case. Its resolvent has the convenient root $u=1$.\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "b197dfb2", "metadata": {}, "outputs": [], "source": [ "def p : MathValue := -15\n", "def q : MathValue := -10\n", "def r : MathValue := 24\n", "def chosenU : MathValue := 1\n", "\n", "def resolvent (u : MathValue) : MathValue :=\n", " u * (p + u)^2 - 4 * r * u - q^2\n", "\n", "def factorPlus : MathValue :=\n", " y^2 + (p + chosenU) / 2\n", " + sqrt chosenU * (y - q / (2 * chosenU))\n", "\n", "def factorMinus : MathValue :=\n", " y^2 + (p + chosenU) / 2\n", " - sqrt chosenU * (y - q / (2 * chosenU))\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "8400ad4c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$0$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "resolvent chosenU\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "34aa89fd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$(y^{2} + y - 2, y^{2} - y - 12)$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "(factorPlus, factorMinus)\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "9ea1631f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "$((1, -2), (4, -3))$" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "(qF factorPlus y, qF factorMinus y)\n" ] }, { "cell_type": "markdown", "id": "caed1bd8", "metadata": {}, "source": [ "## Why the factorization works\n", "\n", "Once a root $u$ of the resolvent is chosen, the depressed quartic is\n", "split into\n", "\n", "$$\n", "y^2+\\frac{p+u}{2}\n", " \\pm\\sqrt{u}\\left(y-\\frac{q}{2u}\\right)=0.\n", "$$\n", "\n", "The two calls to the quadratic solver return all four roots.\n" ] }, { "cell_type": "markdown", "id": "36b0ae0e", "metadata": {}, "source": [ "## Takeaway\n", "\n", "The two executable paths mirror Ferrari's proof: the biquadratic case\n", "reduces immediately to quadratic equations, while the nonzero-linear\n", "case uses one resolvent root to expose two quadratic factors. Egison\n", "keeps the exact factorization and all four roots symbolic.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Egison", "language": "egison", "name": "egison" }, "language_info": { "codemirror_mode": "egison", "file_extension": ".egi", "mimetype": "text/x-egison", "name": "egison" } }, "nbformat": 4, "nbformat_minor": 5 }