{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# p01: Convergence of fourth order finite differences"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us compute the derivative of\n",
"$$\n",
"u(x) = \\exp(\\sin(x)), \\qquad x \\in [-\\pi,\\pi]\n",
"$$\n",
"using fourth order finite difference scheme\n",
"$$\n",
"u'(x_j) \\approx w_j = \\frac{1}{h} \\left( \\frac{1}{12} u_{j-2} - \\frac{2}{3} u_{j-1} + \\frac{2}{3} u_{j+1} - \\frac{1}{12} u_{j+2} \\right)\n",
"$$\n",
"using periodic boundary conditions."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format='svg'\n",
"from scipy.sparse import coo_matrix\n",
"from numpy import arange,pi,exp,sin,cos,ones,inf\n",
"from numpy.linalg import norm\n",
"from matplotlib.pyplot import figure,loglog,semilogy,text,grid,xlabel,ylabel,title"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
"