Sandbox: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
=={{header|J}}== |
=={{header|J}}== |
||
{{works with|Jsoftware|>9.0.1}} |
{{works with|Jsoftware|>= 9.0.1}} |
||
{{libheader|math/calculus}} |
{{libheader|math/calculus}} |
||
Line 12: | Line 12: | ||
ps=: 9!:11 |
ps=: 9!:11 |
||
ps 18 |
ps 18 |
||
go=: 0.1 _1 |
|||
func=: monad define |
func=: monad define |
||
Line 18: | Line 19: | ||
) |
) |
||
go=: 0.1 _1 |
|||
shortygd =: monad define |
shortygd =: monad define |
Revision as of 15:22, 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
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