Gradient descent: Difference between revisions
no edit summary
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 368:
The minimum is at x = 0.107627, y = -1.223260 for which f(x, y) = -0.750063.
</pre>
=={{header|J}}==
{{works with|Jsoftware|>= 9.0.1}}
{{libheader|math/calculus}}
In earlier versions without calculus library, D. can be used instead of pderiv
<syntaxhighlight lang="J">
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 NB. evaluates from right to left without precedence
)
shortygd =: monad define
go=.y
go=. go - 0.03 * func pderiv 1 ] go NB. use D. instead of pderiv for earlier versions
)
NB. use:
shortygd ^:_ go
</syntaxhighlight>
{{out}}
<pre>
0.107626780140768125 _1.22325973233483509
</pre>
=={{header|Julia}}==
|