Sandbox: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 3:
{{libheader|math/calculus}}
In earlier versions without calculus library, D. can be used instead of pderiv
<syntaxhighlight lang="J">
load 'math/calculus' ▼
coinsert 'jcalculus'▼
▲coinsert 'jcalculus'
func=: monad define
Line 23 ⟶ 18:
)
go=.y
go=. go - 0.03 * func pderiv 1 ] go NB. use D. instead of pderiv for earlier versions
)
shortygd ^:_ go
</syntaxhighlight>
{{out}}
<pre>
0.107626780140768125 _1.22325973233483509
</pre>
|
Revision as of 15:19, 15 January 2023
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