<jupyter_start><jupyter_text>Essential Math for Machine Learning: Python EditionCourse source: [LinkedIn Learning](https://www.linkedin.com/learning/essential-math-for-machine-learning-python-edition)  1. Equations, Graphs, and Functions 1.1 Linear Equations 1.1.1 Solving a Linear EquationConsider the following equation:\begin{equation}2y + 3 = 3x - 1 \end{equation}After simplification: \begin{equation}y = \frac{3x - 4}{2} \end{equation}<jupyter_code>import pandas as pd

# Create a dataframe with an x column containing values from -10 to 10
df = pd.DataFrame ({'x': range(-10, 11)})

# Add a y column by applying the solved equation to x
df['y'] = (3*df['x'] - 4) / 2

#Display the dataframe
df<jupyter_output><empty_output><jupyter_text>1.1.2 Visualization<jupyter_code>%matplotlib inline
from matplotlib import pyplot as plt

plt.plot(df.x, df.y, color="grey", marker = "o")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>1.1.3 InterceptsLet's take a look at the line from our linear equation with the X and Y axis shown through the origin (0,0).<jupyter_code>plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()

## add axis lines for 0,0
plt.axhline()
plt.axvline()
plt.show()
plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()

## add axis lines for 0,0
plt.axhline()
plt.axvline()
## After calculation equation x-intercept: 4/3, y-intercept: -2
plt.annotate('x-intercept',(1.333, 0))
plt.annotate('y-intercept',(0,-2))
plt.show()<jupyter_output><empty_output><jupyter_text>1.1.4 Slope<jupyter_code>plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()

# set the slope
m = 1.5

# get the y-intercept
yInt = -2

# plot the slope from the y-intercept for 1x
mx = [0, 1]
my = [yInt, yInt + m]
plt.plot(mx,my, color='red', lw=5)

plt.show()<jupyter_output><empty_output><jupyter_text>1.1.4.1 Slope-Intercept FormNow that we know the slope and y-intercept for the line that this equation defines, we can rewrite the equation as:\begin{equation}y = 1\frac{1}{2}x + -2 \end{equation}<jupyter_code># Create a dataframe with an x column containing values from -10 to 10
df = pd.DataFrame ({'x': range(-10, 11)})

# Define slope and y-intercept
m = 1.5
yInt = -2

# Add a y column by applying the slope-intercept equation to x
df['y'] = m*df['x'] + yInt

# Plot the line
from matplotlib import pyplot as plt

plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()

# label the y-intercept
plt.annotate('y-intercept',(0,yInt))

# plot the slope from the y-intercept for 1x
mx = [0, 1]
my = [yInt, yInt + m]
plt.plot(mx,my, color='red', lw=5)

plt.show()<jupyter_output><empty_output><jupyter_text>1.2 Systems of EquationsHere are the equations\begin{equation}x + y = 16 \end{equation}\begin{equation}10x + 25y = 250 \end{equation}Taken together, these equations form a *system of equations* that will enable us to determine how many of each chip denomination we have. 1.2.1 Graphing Lines to Find the Intersection PointOne approach is to determine all possible values for x and y in each equation and plot them.Let's plot each of these ranges of values as lines on a graph:<jupyter_code># Get the extremes for number
x1 = [16, 0]
y1 = [0, 16]

# Get the extremes for values
x2 = [25,0]
y2 = [0,10]

# Plot the lines
plt.plot(x1, y1, color='blue')
plt.plot(x2, y2, color="orange")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()

plt.show()<jupyter_output><empty_output><jupyter_text>1.3 Exponentials, Radicals, and Logs 1.3.1 Exponentials\begin{equation}2^{2} = 2 \cdot 2 = 4\end{equation}<jupyter_code>x = 2**2
print(x)<jupyter_output>4<jupyter_text>1.3.2 Radicals (Roots)\begin{equation}\sqrt[3]{64} = 4 \end{equation}<jupyter_code>import math

# Calculate square root of 25
x = math.sqrt(25)
print (x)

# Calculate cube root of 64
cr = round(64 ** (1. / 3))
print(cr)<jupyter_output>5.0
4<jupyter_text>1.3.3 Logarithms\begin{equation}log_{4}(16) = 2 \end{equation}\begin{equation}log(1000) = 3 \end{equation}\begin{equation}log_{e}(64) = ln(64) = 4.1589 \end{equation}<jupyter_code># log of 16 base 4
print(math.log(16, 4))

# Common log of 1000
print(math.log10(1000))

# Natural log of 64
print (math.log(64))<jupyter_output>2.0
3.0
4.1588830833596715<jupyter_text>1.3.4 Solving Equations with Exponentials\begin{equation}2y = 2x^{4} ( \frac{x^{2} + 2x^{2}}{x^{3}} ) \end{equation}\begin{equation}y = 3x^{3} \end{equation}Now we have a solution that defines y in terms of x. We can use Python to plot the line created by this equation for a set of arbitrary *x* and *y* values:<jupyter_code># Create a dataframe with an x column containing values from -10 to 10
df = pd.DataFrame ({'x': range(-10, 11)})

# Add a y column by applying the slope-intercept equation to x
df['y'] = 3*df['x']**3

#Display the dataframe
print(df)

plt.plot(df.x, df.y, color="magenta")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()<jupyter_output>x     y
0  -10 -3000
1   -9 -2187
2   -8 -1536
3   -7 -1029
4   -6  -648
5   -5  -375
6   -4  -192
7   -3   -81
8   -2   -24
9   -1    -3
10   0     0
11   1     3
12   2    24
13   3    81
14   4   192
15   5   375
16   6   648
17   7  1029
18   8  1536
19   9  2187
20  10  3000<jupyter_text>For Equation:\begin{equation}y = 2^{x}\end{equation}<jupyter_code># Create a dataframe with an x column containing values from -10 to 10
df = pd.DataFrame ({'x': range(-10, 11)})

# Add a y column by applying the slope-intercept equation to x
df['y'] = 2.0**df['x']

#Display the dataframe
print(df)

plt.plot(df.x, df.y, color="magenta")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()<jupyter_output>x            y
0  -10     0.000977
1   -9     0.001953
2   -8     0.003906
3   -7     0.007812
4   -6     0.015625
5   -5     0.031250
6   -4     0.062500
7   -3     0.125000
8   -2     0.250000
9   -1     0.500000
10   0     1.000000
11   1     2.000000
12   2     4.000000
13   3     8.000000
14   4    16.000000
15   5    32.000000
16   6    64.000000
17   7   128.000000
18   8   256.000000
19   9   512.000000
20  10  1024.000000<jupyter_text>1.4 Quadratic EquationsConsider the following equation:\begin{equation}y = 2(x - 1)(x + 2)\end{equation}If you multiply out the factored ***x*** expressions, this equates to:\begin{equation}y = 2x^{2} + 2x - 4\end{equation}Note that the highest ordered term includes a squared variable (x2).Let's graph this equation for a range of ***x*** values:<jupyter_code># Create a dataframe with an x column containing values to plot
df = pd.DataFrame ({'x': range(-9, 9)})

# Add a y column by applying the quadratic equation to x
df['y'] = 2*df['x']**2 + 2 *df['x'] - 4

plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()<jupyter_output><empty_output><jupyter_text>For following **Parabola**\begin{equation}y = -2x^{2} + 6x + 7\end{equation}<jupyter_code># Create dataFrame for x column
df = pd.DataFrame({'x': range(-9,13)})

# Add y column
df['y'] = -2 * df['x'] ** 2 + 6 * df['x'] - 4

plt.plot(df.x, df.y, color="blue")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()
plt.show()<jupyter_output><empty_output><jupyter_text>Again, the graph shows a parabola, but this time instead of being open at the top, the parabola is open at the bottom.Equations that assign a value to ***y*** based on an expression that includes a squared value for ***x*** create parabolas. If the relationship between ***y*** and ***x*** is such that ***y*** is a *positive* multiple of the ***x2*** term, the parabola will be open at the top; when ***y*** is a *negative* multiple of the ***x2*** term, then the parabola will be open at the bottom.These kinds of equations are known as *quadratic* equations, and they have some interesting characteristics. There are several ways quadratic equations can be written, but the *standard form* for quadratic equation is:\begin{equation}y = ax^{2} + bx + c\end{equation}Where ***a***, ***b***, and ***c*** are numeric coefficients or constants. 1.4.1 Parabola Vertex and Line of SymmetryParabolas are symmetrical, with x and y values converging exponentially towards the highest point (in the case of a downward opening parabola) or lowest point (in the case of an upward opening parabola). The point where the parabola meets the line of symmetry is known as the *vertex*.<jupyter_code>import numpy as np

def plot_parabola(a, b, c):
    # get the x value for the line of symmetry
    vx = (-1*b)/(2*a)
    
    # get the y value when x is at the line of symmetry
    vy = a*vx**2 + b*vx + c

    # Create a dataframe with an x column containing values from x-10 to x+10
    minx = int(vx - 10)
    maxx = int(vx + 11)
    df = pd.DataFrame ({'x': range(minx, maxx)})

    # Add a y column by applying the quadratic equation to x
    df['y'] = a*df['x']**2 + b *df['x'] + c

    # get min and max y values
    miny = df.y.min()
    maxy = df.y.max()

    # Plot the line
    plt.plot(df.x, df.y, color="grey")
    plt.xlabel('x')
    plt.ylabel('y')
    plt.grid()
    plt.axhline()
    plt.axvline()

    # plot the line of symmetry
    sx = [vx, vx]
    sy = [miny, maxy]
    plt.plot(sx,sy, color='magenta')

    # Annotate the vertex
    plt.scatter(vx,vy, color="red")
    plt.annotate('vertex',(vx, vy), xytext=(vx - 1, (vy + 5)* np.sign(a)))

    plt.show()
plot_parabola(2, 2, -4)   
plot_parabola(-2, 3, 5)<jupyter_output><empty_output><jupyter_text>1.4.2 Parabola InterceptsWhen y is 0, x is -2 or 1. Let's plot these points on our parabola:<jupyter_code># Assign the calculated x values
x1 = -2
x2 = 1

# Create a dataframe with an x column containing some values to plot
df = pd.DataFrame ({'x': range(x1-5, x2+6)})

# Add a y column by applying the quadratic equation to x
df['y'] = 2*(df['x'] - 1) * (df['x'] + 2)

# Get x at the line of symmetry (halfway between x1 and x2)
vx = (x1 + x2) / 2

# Get y when x is at the line of symmetry
vy = 2*(vx -1)*(vx + 2)

# get min and max y values
miny = df.y.min()
maxy = df.y.max()

plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()

# Plot calculated x values for y = 0
plt.scatter([x1,x2],[0,0], color="green")
plt.annotate('x1',(x1, 0))
plt.annotate('x2',(x2, 0))

# plot the line of symmetry
sx = [vx, vx]
sy = [miny, maxy]
plt.plot(sx,sy, color='magenta')

# Annotate the vertex
plt.scatter(vx,vy, color="red")
plt.annotate('vertex',(vx, vy), xytext=(vx - 1, (vy - 5)))

plt.show()<jupyter_output><empty_output><jupyter_text>1.4.3 Solving Quadratics Using the Square Root MethodLet's consider this equation:\begin{equation}y = 3x^{2} - 12\end{equation}Let's restate it so we're solving for ***x*** when ***y*** is 0:\begin{equation}3x^{2} - 12 = 0\end{equation}\begin{equation}x = \pm\sqrt{4}\end{equation}Let's see this in Python, and use the results to calculate and plot the parabola with its line of symmetry and vertex:<jupyter_code>y = 0
x1 = int(- math.sqrt(y + 12 / 3))
x2 = int(math.sqrt(y + 12 / 3))

# Create a dataframe with an x column containing some values to plot
df = pd.DataFrame ({'x': range(x1-10, x2+11)})

# Add a y column by applying the quadratic equation to x
df['y'] = 3*df['x']**2 - 12

# Get x at the line of symmetry (halfway between x1 and x2)
vx = (x1 + x2) / 2

# Get y when x is at the line of symmetry
vy = 3*vx**2 - 12

# get min and max y values
miny = df.y.min()
maxy = df.y.max()

plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()

# Plot calculated x values for y = 0
plt.scatter([x1,x2],[0,0], color="green")
plt.annotate('x1',(x1, 0))
plt.annotate('x2',(x2, 0))

# plot the line of symmetry
sx = [vx, vx]
sy = [miny, maxy]
plt.plot(sx,sy, color='magenta')

# Annotate the vertex
plt.scatter(vx,vy, color="red")
plt.annotate('vertex',(vx, vy), xytext=(vx - 1, (vy - 20)))

plt.show()<jupyter_output><empty_output><jupyter_text>1.4.4 Solving Quadratics Using the Completing the Square MethodLet's look at an example:\begin{equation}y = x^{2} + 6x - 7\end{equation}Let's start as we've always done so far by restating the equation to solve ***x*** for a ***y*** value of 0:\begin{equation}x^{2} + 6x - 7 = 0\end{equation}\begin{equation}x^{2} + 6x = 7\end{equation}\begin{equation}x^{2} + 6x + 9 = 16\end{equation}\begin{equation}(x + 3)^{2} = 16\end{equation}\begin{equation}x + 3 =\pm\sqrt{16}\end{equation}\begin{equation}x = -7, 1\end{equation}Let's see what the parabola for this equation looks like in Python:<jupyter_code>x1 = int(- math.sqrt(16) - 3)
x2 = int(math.sqrt(16) - 3)

# Create a dataframe with an x column containing some values to plot
df = pd.DataFrame ({'x': range(x1-10, x2+11)})

# Add a y column by applying the quadratic equation to x
df['y'] = ((df['x'] + 3)**2) - 16

# Get x at the line of symmetry (halfway between x1 and x2)
vx = (x1 + x2) / 2

# Get y when x is at the line of symmetry
vy = ((vx + 3)**2) - 16

# get min and max y values
miny = df.y.min()
maxy = df.y.max()

plt.plot(df.x, df.y, color="grey")
plt.xlabel('x')
plt.ylabel('y')
plt.grid()
plt.axhline()
plt.axvline()

# Plot calculated x values for y = 0
plt.scatter([x1,x2],[0,0], color="green")
plt.annotate('x1',(x1, 0))
plt.annotate('x2',(x2, 0))

# plot the line of symmetry
sx = [vx, vx]
sy = [miny, maxy]
plt.plot(sx,sy, color='magenta')

# Annotate the vertex
plt.scatter(vx,vy, color="red")
plt.annotate('vertex',(vx, vy), xytext=(vx - 1, (vy - 10)))

plt.show()<jupyter_output><empty_output><jupyter_text>1.4.5 Vertex FormTh *vertex form* of a quadratic equation which is generically described as:\begin{equation}y = a(x - h)^{2} + k\end{equation}The neat thing about this form of the equation is that it tells us the coordinates of the vertex - it's at ***h,k***.<jupyter_code>def plot_parabola_from_vertex_form(a, h, k):
    # Create a dataframe with an x column a range of x values to plot
    df = pd.DataFrame ({'x': range(h-10, h+11)})

    # Add a y column by applying the quadratic equation to x
    df['y'] = (a*(df['x'] - h)**2) + k

    # get min and max y values
    miny = df.y.min()
    maxy = df.y.max()

    # calculate y when x is 0 (h+-h)
    y = a*(0 - h)**2 + k

    plt.plot(df.x, df.y, color="grey")
    plt.xlabel('x')
    plt.ylabel('y')
    plt.grid()
    plt.axhline()
    plt.axvline()

    # Plot calculated y values for x = 0 (h-h and h+h)
    plt.scatter([h-h, h+h],[y,y], color="green")
    plt.annotate(str(h-h) + ',' + str(y),(h-h, y))
    plt.annotate(str(h+h) + ',' + str(y),(h+h, y))

    # plot the line of symmetry (x = h)
    sx = [h, h]
    sy = [miny, maxy]
    plt.plot(sx,sy, color='magenta')

    # Annotate the vertex (h,k)
    plt.scatter(h,k, color="red")
    plt.annotate('v=' + str(h) + ',' + str(k),(h, k), xytext=(h - 1, (k - 10)))

    plt.show()
# Call the function for the example discussed above
plot_parabola_from_vertex_form(2, 4, -30)
plot_parabola_from_vertex_form(3, -1, -1)<jupyter_output><empty_output><jupyter_text>1.4.6 Shortcuts for Solving Quadratic Equations 1.4.6.1 The Quadratic FormulaAnother useful formula to remember is the *quadratic formula*, which makes it easy to calculate values for ***x*** when ***y*** is **0**; or in other words:\begin{equation}ax^{2} + bx + c = 0\end{equation}Here's the formula:\begin{equation}x = \frac{-b \pm \sqrt{b^{2} - 4ac}}{2a}\end{equation}<jupyter_code>def plot_parabola_from_formula (a, b, c):
    # Get vertex
    print('CALCULATING THE VERTEX')
    print('vx = -b / 2a')

    nb = -b
    a2 = 2*a
    print('vx = ' + str(nb) + ' / ' + str(a2))

    vx = -b/(2*a)
    print('vx = ' + str(vx))

    print('\nvy = ax^2 + bx + c')
    print('vy = ' + str(a) + '(' + str(vx) + '^2) + ' + str(b) + '(' + str(vx) + ') + ' + str(c))

    avx2 = a*vx**2
    bvx = b*vx
    print('vy = ' + str(avx2) + ' + ' + str(bvx) + ' + ' + str(c))

    vy = avx2 + bvx + c
    print('vy = ' + str(vy))

    print ('\nv = ' + str(vx) + ',' + str(vy))

    # Get +x and -x (showing intermediate calculations)
    print('\nCALCULATING -x AND +x FOR y=0')
    print('x = -b +- sqrt(b^2 - 4ac) / 2a')


    b2 = b**2
    ac4 = 4*a*c
    print('x = ' + str(nb) + ' +- sqrt(' + str(b2) + ' - ' + str(ac4) + ') / ' + str(a2))

    sr = math.sqrt(b2 - ac4)
    print('x = ' + str(nb) + ' +- ' + str(sr) + ' / ' + str(a2))
    print('-x = ' + str(nb) + ' - ' + str(sr) + ' / ' + str(a2))
    print('+x = ' + str(nb) + ' + ' + str(sr) + ' / ' + str(a2))

    posx = (nb + sr) / a2
    negx = (nb - sr) / a2
    print('-x = ' + str(negx))
    print('+x = ' + str(posx))


    print('\nPLOTTING THE PARABOLA')

    # Create a dataframe with an x column a range of x values to plot
    df = pd.DataFrame ({'x': range(round(vx)-10, round(vx)+11)})

    # Add a y column by applying the quadratic equation to x
    df['y'] = a*df['x']**2 + b*df['x'] + c

    # get min and max y values
    miny = df.y.min()
    maxy = df.y.max()

    plt.plot(df.x, df.y, color="grey")
    plt.xlabel('x')
    plt.ylabel('y')
    plt.grid()
    plt.axhline()
    plt.axvline()

    # Plot calculated x values for y = 0
    plt.scatter([negx, posx],[0,0], color="green")
    plt.annotate('-x=' + str(negx) + ',' + str(0),(negx, 0), xytext=(negx - 3, 5))
    plt.annotate('+x=' + str(posx) + ',' + str(0),(posx, 0), xytext=(posx - 3, -10))

    # plot the line of symmetry
    sx = [vx, vx]
    sy = [miny, maxy]
    plt.plot(sx,sy, color='magenta')

    # Annotate the vertex
    plt.scatter(vx,vy, color="red")
    plt.annotate('v=' + str(vx) + ',' + str(vy),(vx, vy), xytext=(vx - 1, vy - 10))

    plt.show()
plot_parabola_from_formula (2, -16, 2)<jupyter_output>CALCULATING THE VERTEX
vx = -b / 2a
vx = 16 / 4
vx = 4.0

vy = ax^2 + bx + c
vy = 2(4.0^2) + -16(4.0) + 2
vy = 32.0 + -64.0 + 2
vy = -30.0

v = 4.0,-30.0

CALCULATING -x AND +x FOR y=0
x = -b +- sqrt(b^2 - 4ac) / 2a
x = 16 +- sqrt(256 - 16) / 4
x = 16 +- 15.491933384829668 / 4
-x = 16 - 15.491933384829668 / 4
+x = 16 + 15.491933384829668 / 4
-x = 0.12701665379258298
+x = 7.872983346207417

PLOTTING THE PARABOLA<jupyter_text>1.5 FunctionsFor example, consider the following equation:\begin{equation}f(x) = x^{2} + 2\end{equation}<jupyter_code>def f(x):
    return x**2 + 2
# Create an array of x values from -100 to 100
x = np.array(range(-100, 101))

# Set up the graph
plt.xlabel('x')
plt.ylabel('f(x)')
plt.grid()

# Plot x against f(x)
plt.plot(x,f(x), color='purple')

plt.show()<jupyter_output><empty_output><jupyter_text>1.5.1 Bounds of a FunctionFor example, consider the function ***u*** defined here:\begin{equation}u(x) = x + 1\end{equation}\begin{equation}\{x \in \rm I\!R\}\end{equation} 1.5.1.1 Domain of a FunctionNow consider the following function ***g***:\begin{equation}g(x) = (\frac{12}{2x})^{2}\end{equation}This is interpreted as *Any value for x where x is in the set of real numbers such that x is not equal to 0*, and we can incorporate this into the function's definition like this:\begin{equation}g(x) = (\frac{12}{2x})^{2}, \{x \in \rm I\!R\;\;|\;\; x \ne 0 \}\end{equation}Or more simply:\begin{equation}g(x) = (\frac{12}{2x})^{2},\;\; x \ne 0\end{equation}<jupyter_code># Define function g
def g(x):
    if x != 0:
        return (12/(2*x))**2
# Create an array of x values from -100 to 100
x = range(-100, 101)

# Get the corresponding y values from the function
y = [g(a) for a in x]

# Set up the graph
plt.xlabel('x')
plt.ylabel('g(x)')
plt.grid()

# Plot x against g(x)
plt.plot(x,y, color='purple')

# plot an empty circle to show the undefined point
plt.plot(0,g(0.0000001), color='purple', marker='o', markerfacecolor='w', markersize=8)

plt.show()<jupyter_output><empty_output><jupyter_text>We can indicate the domain of this function in its definition like this:\begin{equation}h(x) = 2\sqrt{x}, \{x \in \rm I\!R\;\;|\;\; x \ge 0 \}\end{equation}<jupyter_code>def h(x):
    if x >= 0:
        return 2 * np.sqrt(x)
# Create an array of x values from -100 to 100
x = range(-100, 101)

# Get the corresponding y values from the function
y = [h(a) for a in x]

# Set up the graph
plt.xlabel('x')
plt.ylabel('h(x)')
plt.grid()

# Plot x against h(x)
plt.plot(x,y, color='purple')

# plot a filled circle at the end to indicate a closed interval
plt.plot(0, h(0), color='purple', marker='o', markerfacecolor='purple', markersize=8)

plt.show()<jupyter_output><empty_output><jupyter_text>1.5.1.2 Range of a FunctionFor example, consider the following function:\begin{equation}p(x) = x^{2} + 1\end{equation}It's range is:\begin{equation}\{p(x) \in \rm I\!R\;\;|\;\; p(x) \ge 1 \}\end{equation}Let's create and plot the function for a range of ***x*** values in Python:<jupyter_code># define a function to return x^2 + 1
def p(x):
    return x**2 + 1
# Create an array of x values from -100 to 100
x = np.array(range(-100, 101))

# Set up the graph
plt.xlabel('x')
plt.ylabel('p(x)')
plt.grid()

# Plot x against f(x)
plt.plot(x,p(x), color='purple')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17105387747372408, 'fraction_numerical': 0.053214657702869046, 'mean_word_length': 3.694, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 88, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '23', 'dir': 'jupyter-structured-clean-dedup', 'id': '624183', 'license': 'MIT', 'n_tokens_mistral': 9146, 'n_tokens_neox': 8205, 'n_words': 2475, 'path': 'Codes/Essential Math for Machine Learning/1. Equations, Graphs, and Functions.ipynb', 'repo_name': 'moni-roy/100DaysOfMLCode', 'size': '21122'}