Sandbox

From Rosetta Code
(Redirected from Help:Sandbox)

J[edit]

Works with: Jsoftware
Library: math/calculus

In earlier versions without calculus library, D. can be used instead of pderiv

load 'math/calculus'
coinsert 'jcalculus'
ps=: 9!:11
ps 18
go=: 0.1 _1

func=: monad define
'xp yp' =: y
((1-xp)*(1-xp) * ]  ^-(yp)^2) + yp*(yp+2)* ] ^ _2 * xp^2
)

go=: 0.1 _1

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