Posted to tcl by emiliano at Tue Mar 02 13:43:00 GMT 2010view raw

  1. --- calculus.tcl.orig 2010-03-02 10:26:56.000000000 -0300
  2. +++ calculus.tcl 2010-03-02 10:41:43.000000000 -0300
  3. @@ -305,7 +305,8 @@
  4. #
  5. proc ::math::calculus::eulerStep { t tstep xvec func } {
  6.  
  7. - set xderiv [uplevel 1 $func $t [list $xvec]]
  8. + set funq [uplevel 1 namespace which -command $func]
  9. + set xderiv [$funcq $t $xvec]
  10. set result {}
  11. foreach xv $xvec dx $xderiv {
  12. set xnew [expr {$xv+$tstep*$dx}]
  13. @@ -373,10 +374,10 @@
  14. #
  15. # Four steps:
  16. # - k1 = tstep*func(t,x0)
  17. - # - k2 = tstep*func(t+0.5*tstep,x0+0.5*k1)
  18. - # - k3 = tstep*func(t+0.5*tstep,x0+0.5*k2)
  19. - # - k4 = tstep*func(t+ tstep,x0+ k3)
  20. - # - x1 = x0 + (k1+2*k2+2*k3+k4)/6
  21. + # - k2 = tstep*func(t+0.5*tstep,x0+0.5*tstep*k1)
  22. + # - k3 = tstep*func(t+0.5*tstep,x0+0.5*tstep*k2)
  23. + # - k4 = tstep*func(t+ tstep,x0+ tstep*k3)
  24. + # - x1 = x0 + tstep*(k1+2*k2+2*k3+k4)/6
  25. #
  26. set tstep2 [expr {$tstep/2.0}]
  27. set tstep6 [expr {$tstep/6.0}]
  28.