{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Newton method"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the function\n",
"$$\n",
"f(x) = \\exp(x) - \\frac{3}{2} - \\arctan(x)\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%config InlineBackend.figure_format = 'svg'\n",
"from numpy import linspace,abs\n",
"from sympy import Symbol,exp,atan,diff,lambdify\n",
"from matplotlib.pyplot import figure,subplot,plot,grid,title"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We define the function using sympy and automatically compute its derivative. Then we make functions out of these."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"f = exp(x) - atan(x) - 1.5\n",
"df= exp(x) - 1/(x**2 + 1)\n"
]
},
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
"