I got stucked with the problem

Good evening to everyone. I have some troubles with a task I have to do. I need some assistance. Excuse me if I haven't searched thoroughly in the forum and there is a similar topic somewhere. Thank you!

Here's the issue:

You would take as input any analytic function of 1 independent variable and a closed
interval [a, b], on which the function is analytic. You have to find out the extrema(s) of
the function. Then you have to show whether the local extrema is maxima or minima.
Write a code which is going to find the solution of the above problem.

Examples:
f (x)=2 x
315 x
2
+36 x on [1, 5]
stationary points at x = 2 and x = 3 with end points at x = 1 and x = 5
extremas at x = 1 and x = 5
with x =1 is minimum (23) and x = 5 is maximum (55)

f (x)=sin (x) on [0, 2PI]
stationary points at x = PI/2 and x = -PI/2 with end points at x = 0 and x = 2
PI
extremas at x = -PI/2 and x = PI/2
with x =-PI/2 is minimum (-1) and x = PI/2 is maximum (1)

examples of test cases:
Test case 1
(x, f(x)) = (0, 0), (1, -1), (2, 8), (3, 63), (4, 224), (-1, -1), (-2, 8), (-3, 63)
corner points, x = -3, 4
extremas, x = 0, -1, 1
maxima, x = 0
minima, x = -1, 1

Test case 2
(x, f(x)) = (0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (-1, 1), (-2, 4), (-3, 9), (-4, 16)
corner points, x = -4, 4
extremas, x = 0, -4, 4
maxima, x = -4, 4
minima, x = 0

I'm really stuck and I don't know what exactly to do. I'll be very thankful if you give me some clues. Thank you one more time!