Hi Aleem,
Here is a function in syms called solve, which can evaluate roots of a function but for continous part only,
syms x
f =(x^3*heaviside(x))/18 - (3*x^2*heaviside(x))/2 + (27*heaviside(x - 6)*(x - 6))/4 + (27*x*heaviside(x))/4 + heaviside(x - 9)*(x - 9)^2 - (heaviside(x - 9)*(x - 9)^3)/18
solve(f == 0, x, 'MaxDegree', 4);
roots = vpa(ans,6);
fplot(f,[-2, 12])
hold on
plot(roots, subs(f,roots), '*')
hold off
For Maxima and Minima,
syms x
f =(x^3*heaviside(x))/18 - (3*x^2*heaviside(x))/2 + (27*heaviside(x - 6)*(x - 6))/4 + (27*x*heaviside(x))/4 + heaviside(x - 9)*(x - 9)^2 - (heaviside(x - 9)*(x - 9)^3)/18
g = diff(f,x);
solve(g == 0,x,'MaxDegree',4);
extrema = vpa(ans,6)
fplot(f,[-2, 12])
hold on
plot(extrema, subs(f,extrema), '*')
hold off
This code works fine for the differentiable part, for non-differentiable part you may iterate the points one-by-one how function is behaving.
Best Answer