Has any one here ever written a program that finds the derivative or anti derivative?

Because I'm trying to write a program that finds the derivative or antiderivative but I don't know where to start. I dont know how I would allow the user to enter in their f(x) and then take that and find the derivative or antiderivative? Any tips or tricks would be appreciated thanks