#!/usr/bin/python3

import numpy as np
import matplotlib.pyplot as plt
import math as math

def f(x): #x^2 sin(1/x)
    return (x**2)*np.sin(1/x)

def diff(f,h,x): #returns the numerical derivative of a function
    return (f(x+h)-f(x-h))/(2*h)

x = np.linspace(-1,1) #set domain as [-1,1]

plt.plot(x,diff(f,1e-9,x)) #plot f'(x)
plt.show()

