{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Newton method with double root"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the function\n",
"$$\n",
"f(x) = (x-1)^2 \\sin(x)\n",
"$$\n",
"for which $x=1$ is a double root."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'svg'\n",
"from numpy import sin,cos,linspace,zeros,abs\n",
"from matplotlib.pyplot import plot,xlabel,ylabel,grid"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def f(x):\n",
" return (x-1.0)**2 * sin(x)\n",
"\n",
"def df(x):\n",
" return 2.0*(x-1.0)*sin(x) + (x-1.0)**2 * cos(x)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
"