Roots of a function: Difference between revisions

Content added Content deleted
(→‎{{header|Tcl}}: balanced angle bracket, added puts call)
Line 490: Line 490:
proc sgn x {expr {($x>0) - ($x<0)}}
proc sgn x {expr {($x>0) - ($x<0)}}


froots {x {expr {$x**3 - 3*$x**2 + 2*$x}}}
puts [froots {x {expr {$x**3 - 3*$x**2 + 2*$x}}}]
</lang>
</lang>
Result and timing:
Result and timing:
<pre/Tcl $ time ./froots.tcl
<pre>/Tcl $ time ./froots.tcl
~0.00000000000 ~1.00000000000 ~2.00000000000
~0.00000000000 ~1.00000000000 ~2.00000000000