Menu

[r3949]: / trunk / course / examples / scipy / example5.3  Maximize  Restore  History

Download this file

11 lines (9 with data), 318 Bytes

1
2
3
4
5
6
7
8
9
>>> def rosen_der(x):
xm = x[1:-1]
xm_m1 = x[:-2]
xm_p1 = x[2:]
der = zeros(x.shape,x.typecode())
der[1:-1] = 200*(xm-xm_m1**2) - 400*(xm_p1 - xm**2)*xm - 2*(1-xm)
der[0] = -400*x[0]*(x[1]-x[0]**2) - 2*(1-x[0])
der[-1] = 200*(x[-1]-x[-2]**2)
return der
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.