Posted to tcl by emiliano at Tue Mar 02 13:43:00 GMT 2010view raw
- --- calculus.tcl.orig 2010-03-02 10:26:56.000000000 -0300
- +++ calculus.tcl 2010-03-02 10:41:43.000000000 -0300
- @@ -305,7 +305,8 @@
- #
- proc ::math::calculus::eulerStep { t tstep xvec func } {
- - set xderiv [uplevel 1 $func $t [list $xvec]]
- + set funq [uplevel 1 namespace which -command $func]
- + set xderiv [$funcq $t $xvec]
- set result {}
- foreach xv $xvec dx $xderiv {
- set xnew [expr {$xv+$tstep*$dx}]
- @@ -373,10 +374,10 @@
- #
- # Four steps:
- # - k1 = tstep*func(t,x0)
- - # - k2 = tstep*func(t+0.5*tstep,x0+0.5*k1)
- - # - k3 = tstep*func(t+0.5*tstep,x0+0.5*k2)
- - # - k4 = tstep*func(t+ tstep,x0+ k3)
- - # - x1 = x0 + (k1+2*k2+2*k3+k4)/6
- + # - k2 = tstep*func(t+0.5*tstep,x0+0.5*tstep*k1)
- + # - k3 = tstep*func(t+0.5*tstep,x0+0.5*tstep*k2)
- + # - k4 = tstep*func(t+ tstep,x0+ tstep*k3)
- + # - x1 = x0 + tstep*(k1+2*k2+2*k3+k4)/6
- #
- set tstep2 [expr {$tstep/2.0}]
- set tstep6 [expr {$tstep/6.0}]