{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 2.22 (A Parametrized Integral)\n", "Derive a D-finite equation for a rational period integral. \n", "*Requirements: [ore_algebra package](https://github.com/mkauers/ore_algebra/)*" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# Define function to help with latex typesetting\n", "def le(s): return LatexExpr(s)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# Introduce our domains for computations, and define f\n", "S. = QQ['t']\n", "R. = S.fraction_field()['x']" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\verb|G(t)|\\phantom{\\verb!x!}\\verb|=| \\int_{|x|=1/2} \\frac{-1}{x^{2} - x + t} dx\n", "\\end{math}" ], "text/plain": [ "'G(t) =' \\int_{|x|=1/2} -1/(x^2 - x + t) dx" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Our goal is to determine a differential equation for the integral\n", "f = -x^2-t+x\n", "F = 1/f\n", "show(\"G(t) =\", le(\"\\\\int_{|x|=1/2}\"), F, le(\"dx\"))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{dF}{dt} = (x^{2} - x + t)^{-2}\n", "\\end{math}" ], "text/plain": [ "\\frac{dF}{dt} = (x^2 - x + t)^-2" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# We do this by relating F to\n", "show(le(\"\\\\frac{dF}{dt} = \"), diff(F,t).factor())" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}1 = A \\cdot f + B \\cdot \\frac{df}{dx} \\phantom{\\verb!x!}\\verb|where|\\phantom{\\verb!x!}\\verb|A|\\phantom{\\verb!x!}\\verb|=| -\\frac{4}{4 \\, t - 1} \\phantom{\\verb!x!}\\verb|and|\\phantom{\\verb!x!}\\verb|B|\\phantom{\\verb!x!}\\verb|=| \\frac{2 \\, x}{4 \\, t - 1} - \\frac{1}{4 \\, t - 1}\n", "\\end{math}" ], "text/plain": [ "1 = A \\cdot f + B \\cdot \\frac{df}{dx} ' where A = ' -4/(4*t - 1) ' and B = ' 2*x/(4*t - 1) - 1/(4*t - 1)" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Since the derivative has a higher exponent in the denominator, we use the Euclidean algorithm to write\n", "r,a,b = f.xgcd(diff(f,x))\n", "show(le(\"1 = A \\\\cdot f + B \\\\cdot \\\\frac{df}{dx}\"), \" where A = \", SR(a), \" and B = \", SR(b))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{dF}{dt} = 1 \\cdot \\frac{dF}{dt} = \\left(A\\cdot f + B \\frac{df}{dx}\\right) (x^{2} - x + t)^{-2}\n", "\\end{math}" ], "text/plain": [ "\\frac{dF}{dt} = 1 \\cdot \\frac{dF}{dt} = \\left(A\\cdot f + B \\frac{df}{dx}\\right) (x^2 - x + t)^-2" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Thus, we see\n", "show(le(\"\\\\frac{dF}{dt} = 1 \\\\cdot \\\\frac{dF}{dt} = \\\\left(A\\\\cdot f + B \\\\frac{df}{dx}\\\\right)\"), diff(F,t).factor())" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{d}{dx}\\frac{B(x)}{f(x)} = - \\frac{df}{dx}\\frac{B(x)}{f(x)^2} + \\frac{1}{f(x)}\\frac{dB}{dx}\n", "\\end{math}" ], "text/plain": [ "\\frac{d}{dx}\\frac{B(x)}{f(x)} = - \\frac{df}{dx}\\frac{B(x)}{f(x)^2} + \\frac{1}{f(x)}\\frac{dB}{dx}" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Note the chain rule implies that for any function B(x)\n", "show(le(\"\\\\frac{d}{dx}\\\\frac{B(x)}{f(x)} = - \\\\frac{df}{dx}\\\\frac{B(x)}{f(x)^2} + \\\\frac{1}{f(x)}\\\\frac{dB}{dx}\"))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}(x^{2} - x + t)^{-2} = -\\frac{2}{{\\left(x^{2} + t - x\\right)} {\\left(4 \\, t - 1\\right)}} \\phantom{\\verb!x!}\\verb|+| \\frac{d}{dx} \\frac{2 \\, x - 1}{{\\left(x^{2} + t - x\\right)} {\\left(4 \\, t - 1\\right)}}\n", "\\end{math}" ], "text/plain": [ "(x^2 - x + t)^-2 = -2/((x^2 + t - x)*(4*t - 1)) ' + ' \\frac{d}{dx} (2*x - 1)/((x^2 + t - x)*(4*t - 1))" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Thus, we have the relation\n", "show(diff(F,t).factor() , le(\" = \"), SR(-a/f - diff(b,x)/f), \" + \", le(\"\\\\frac{d}{dx}\"), -SR(b/f).factor())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Clearing the factor of $(4t-1)$ from the denominator gives the relation\n", "\\[ (4t-1) \\frac{d}{dt}F(x,t) + 2F(t) = \\frac{d}{dx}\\left(\\frac{1-2x}{f(x,t)}\\right) \\]" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# This relation is easily verified\n", "simplify((4*t-1)*diff(F,t) + 2*F - diff((1-2*x)*F,x))" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Integrating with respect to x kills the right-hand side\n", "var('θ')\n", "var('t'); assume(t<1/4, sqrt(1-4*t)-1>0)\n", "integral(diff((1-2*x)*F,x).subs(x=exp(I*θ)/2)*exp(I*θ)*I/2,θ,-pi,pi)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}(4t-1) G'(t) + 2G(t) = 0\n", "\\end{math}" ], "text/plain": [ "(4t-1) G'(t) + 2G(t) = 0" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Thus, we have the following differential equation\n", "show(le(\"(4t-1) G'(t) + 2G(t) = 0\"))" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "\\begin{math}\n", "\\newcommand{\\Bold}[1]{\\mathbf{#1}}G(0) = 0\n", "\\end{math}" ], "text/plain": [ "G(0) = 0" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# And initial condition\n", "show(le(\"G(0) = \"), integral(((1-2*x)*F(t=0)).subs(x=exp(I*θ)/2)*exp(I*θ)*I/2,θ,-pi,pi)/2/pi/I)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1/sqrt(-4*T + 1)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# We can solve this differential equation to get G(t)\n", "var('T')\n", "g = function('g')(T)\n", "assume(0