import numpy as np
import matplotlib.pyplot as plt

# some function
func = lambda x: 3./(1 + 400*np.exp(-2*x)) - 1
xvals = np.linspace(0, 6)
plt.plot(xvals, func(xvals))
plt.text(5.3, 2.1, '$f(x)$', fontsize=16)

# zero line
plt.plot([0,6], [0,0], 'k-')

# value at step n
plt.plot([4,4], [0,func(4)], 'k:')
plt.text(4, -.2, '$x_n$', fontsize=16)

# tangent line
tanline = lambda x: -0.858 + 0.626*x
plt.plot(xvals, tanline(xvals), 'r--')

# point at step n+1
xprime = 0.858/0.626
plt.plot([xprime, xprime], [tanline(xprime), func(xprime)], 'k:')
plt.text(xprime+.1, -.2, '$x_{n+1}$', fontsize=16)
136ffe1fe16f6075dc843f2c08d4a24835a33463
<mask token>

<mask token>
plt.plot(xvals, func(xvals))
plt.text(5.3, 2.1, '$f(x)$', fontsize=16)
plt.plot([0, 6], [0, 0], 'k-')
plt.plot([4, 4], [0, func(4)], 'k:')
plt.text(4, -0.2, '$x_n$', fontsize=16)
<mask token>
plt.plot(xvals, tanline(xvals), 'r--')
<mask token>
plt.plot([xprime, xprime], [tanline(xprime), func(xprime)], 'k:')
plt.text(xprime + 0.1, -0.2, '$x_{n+1}$', fontsize=16)

<mask token>
func = lambda x: 3.0 / (1 + 400 * np.exp(-2 * x)) - 1
xvals = np.linspace(0, 6)
plt.plot(xvals, func(xvals))
plt.text(5.3, 2.1, '$f(x)$', fontsize=16)
plt.plot([0, 6], [0, 0], 'k-')
plt.plot([4, 4], [0, func(4)], 'k:')
plt.text(4, -0.2, '$x_n$', fontsize=16)
tanline = lambda x: -0.858 + 0.626 * x
plt.plot(xvals, tanline(xvals), 'r--')
xprime = 0.858 / 0.626
plt.plot([xprime, xprime], [tanline(xprime), func(xprime)], 'k:')
plt.text(xprime + 0.1, -0.2, '$x_{n+1}$', fontsize=16)

import numpy as np
import matplotlib.pyplot as plt
func = lambda x: 3.0 / (1 + 400 * np.exp(-2 * x)) - 1
xvals = np.linspace(0, 6)
plt.plot(xvals, func(xvals))
plt.text(5.3, 2.1, '$f(x)$', fontsize=16)
plt.plot([0, 6], [0, 0], 'k-')
plt.plot([4, 4], [0, func(4)], 'k:')
plt.text(4, -0.2, '$x_n$', fontsize=16)
tanline = lambda x: -0.858 + 0.626 * x
plt.plot(xvals, tanline(xvals), 'r--')
xprime = 0.858 / 0.626
plt.plot([xprime, xprime], [tanline(xprime), func(xprime)], 'k:')
plt.text(xprime + 0.1, -0.2, '$x_{n+1}$', fontsize=16)

import numpy as np
import matplotlib.pyplot as plt

# some function
func = lambda x: 3./(1 + 400*np.exp(-2*x)) - 1
xvals = np.linspace(0, 6)
plt.plot(xvals, func(xvals))
plt.text(5.3, 2.1, '$f(x)$', fontsize=16)

# zero line
plt.plot([0,6], [0,0], 'k-')

# value at step n
plt.plot([4,4], [0,func(4)], 'k:')
plt.text(4, -.2, '$x_n$', fontsize=16)

# tangent line
tanline = lambda x: -0.858 + 0.626*x
plt.plot(xvals, tanline(xvals), 'r--')

# point at step n+1
xprime = 0.858/0.626
plt.plot([xprime, xprime], [tanline(xprime), func(xprime)], 'k:')
plt.text(xprime+.1, -.2, '$x_{n+1}$', fontsize=16)