The following code examples apply the gradient descent algorithm to find the minimum of the function f ( x ) = x 4 − 3 x 3 + 2 , {\displaystyle f(x)=x^{4}-3x^{3}+2,} with derivative f ′ ( x ) = 4 x 3 − 9 x 2 . {\displaystyle f'(x)=4x^{3}-9x^{2}.}