Sandbox
J
In earlier versions without calculus library, D. can be used instead of pderiv
load 'math/calculus'
coinsert 'jcalculus'
ps=: 9!:11
ps 18
func=: monad define
'xp yp' =: y
((1-xp)*(1-xp) * ] ^-(yp)^2) + yp*(yp+2)* ] ^ _2 * xp^2
)
shortygd =: monad define
go=.y
go=. go - 0.03 * func pderiv 1 ] go NB. use D. instead of pderiv for earlier versions
)
shortygd ^:_ go
- Output:
0.107626780140768125 _1.22325973233483509