def rosen_hess_prod(x, p):
 x = atleast_1d(x)
 Hp = numpy.zeros(len(x), dtype=x.dtype)
 Hp[0] = (((((1200 * (x[0] ** 2)) - (400 * x[1])) + 2) * p[0]) - ((400 * x[0]) * p[1]))
 Hp[1:(-1)] = (((((-400) * x[:(-2)]) * p[:(-2)]) + (((202 + (1200 * (x[1:(-1)] ** 2))) - (400 * x[2:])) * p[1:(-1)])) - ((400 * x[1:(-1)]) * p[2:]))
 Hp[(-1)] = ((((-400) * x[(-2)]) * p[(-2)]) + (200 * p[(-1)]))
 return Hp

def rosen_hess_prod ( x , p ) : x = atleast_1d ( x ) Hp = numpy . zeros ( len ( x ) , dtype = x . dtype ) Hp [ 0 ] = ( ( ( ( ( 1200 * ( x [ 0 ] ** 2 ) ) - ( 400 * x [ 1 ] ) ) + 2 ) * p [ 0 ] ) - ( ( 400 * x [ 0 ] ) * p [ 1 ] ) ) Hp [ 1 : ( - 1 ) ] = ( ( ( ( ( - 400 ) * x [ : ( - 2 ) ] ) * p [ : ( - 2 ) ] ) + ( ( ( 202 + ( 1200 * ( x [ 1 : ( - 1 ) ] ** 2 ) ) ) - ( 400 * x [ 2 : ] ) ) * p [ 1 : ( - 1 ) ] ) ) - ( ( 400 * x [ 1 : ( - 1 ) ] ) * p [ 2 : ] ) ) Hp [ ( - 1 ) ] = ( ( ( ( - 400 ) * x [ ( - 2 ) ] ) * p [ ( - 2 ) ] ) + ( 200 * p [ ( - 1 ) ] ) ) return Hp
product of the hessian matrix of the rosenbrock function with a vector .