Approximations allow you to find functions for values that you cannot (or don't want to, possibly) find directly.
Remember that:
In [14]:
import sympy as sp
from matplotlib import pyplot as plt
%matplotlib inline
configure_matplotlib()
f = lambda x: -4*(x**4)-3*(x**3)+4*(x**2)
# First derivative of f
f1 = lambda x: -16*(x**3)-9*(x**2)+8*x
# Second derivative of f
f2 = lambda x: -48*(x**2)-18*x+8
# L(x) is a linearization of f(x) at x = -1
a = -1
L = lambda x: f(a)+f1(a)*(x-a)
# Q(x) is a quadratic approximation of f(x) at x = -1
Q = lambda x: f(a)+f1(a)*(x-a)+f2(a)/2*(x-a)**2
sp.mpmath.plot([f, L, Q], xlim=[-2,0], ylim=[-1,5], points=500)
As you can see from the plot above, the quadratic approximation is more accurate for $x$ near $a$.
In [15]:
def configure_matplotlib():
# Customize figure size
plt.rcParams['figure.figsize'] = 25, 15
#plt.rcParams['lines.linewidth'] = 1
#plt.rcParams['lines.color'] = 'g'
#plt.rcParams['font.family'] = 'monospace'
plt.rcParams['font.size'] = '16.0'
plt.rcParams['font.monospace'] = 'Anonymous Pro, serif'
plt.rcParams['text.hinting'] = 'either'
In [ ]: