{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Convergence of AB4\n", "\n", "We consider the IVP $u'=\\sin[(u+t)^2]$ over $0\\le t \\le 4$, with $u(0)=-1$." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "using FundamentalsNumericalComputation" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "\u001b[36mODEProblem\u001b[0m with uType \u001b[36mFloat64\u001b[0m and tType \u001b[36mFloat64\u001b[0m. In-place: \u001b[36mfalse\u001b[0m\n", "timespan: (0.0, 4.0)\n", "u0: -1.0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ivp = ODEProblem((u,p,t)->sin((t+u)^2),-1.,(0.0,4.0))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use a solver from `DifferentialEquations` to construct an accurate approximation to the exact solution." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "u_exact = solve(ivp,Tsit5(),reltol=1e-14,abstol=1e-14);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we perform a convergence study of the AB4 code." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "
\n", "n | \n", "inf-norm error | \n", "
---|---|
10 | \n", "1.421332157914805 | \n", "
20 | \n", "0.2998677236341702 | \n", "
40 | \n", "0.006278094753455532 | \n", "
80 | \n", "0.0005392729579345446 | \n", "
160 | \n", "3.975975730263759e-5 | \n", "
320 | \n", "2.64515824960343e-6 | \n", "