@Zeineb The reason that your instructor assigned you this exercise is specifically to teach you some of the same things that I've been telling you. This function was specifically designed to cause trouble (an erratic sequence) for Newton's method when the initial value is several "humps" away from the true solution. Look at a plot of f and another of its derivative on the interval x= 0..22. Note the wild oscillations of the derivative. If the derivative is near zero, the tangent line is nearly horizontal, and thus the point where the tangent intersects the x-axis (which is, by definition, the next x) will be far away from the current x.
Here's a procedure that I think will help you see the "bare bones" of what's happening. You can use it as an alternative to Newton in Student:-NumericalAnalysis. You should especially experiment with different values of digits and different initial values.
criterion::identical(relative, absolute, residual):= ':-relative'
X:= Array(1..2, [rhs(X0)+1, rhs(X0)], datatype= sfloat),
proc(x) option remember; evalf(_f(x)) end proc
N:= subs(_d= unapply(diff(f,x), x), x-> x-F(x)/evalf(_d(x))),
':-absolute'= ((a,b,t)-> abs(a-b) < t),
':-relative'= ((a,b,t)-> abs(1-b/a) < t),
':-residual'= ((a,b,t)-> abs(F(a)) < t)
for k from 3 to 2+maxiters do
if Crit[criterion](X[k-1], X[k-2], tolerance) then break fi;
if k > 2+maxiters then print("Did not converge") fi;
Newton(f, x=0, digits= 15, tolerance= .5e-13, criterion= relative);