Roots of a function: Difference between revisions

m
m (→‎faster version and timings: marked a version as "incomplete".)
Line 2,064:
found an exact root at 2
</pre>
 
===faster version and timings===
 
{{incomplete|REXX| <br><br> This version doesn't: <br><br> --- find the roots of the specified function, <br> --- doesn't show the roots, <br> --- doesn't show if the root is exact or approximate. <br><br> }}
 
<lang rexx>/* REXX */
Parse Version v; Say v
n=1000000
Say 'N='n
Call time 'R'; Do i=1 To n; xx=f1(5); End; Say 'f1' xx time('E')
Call time 'R'; Do i=1 To n; xx=f2(5); End; Say 'f2' xx time('E')
Call time 'R'; Do i=1 To n; xx=f3(5); End; Say 'f3' xx time('E')
Exit
f1: procedure; parse arg x; return x**3 - 3 * x**2 + 2 * x
f2: procedure; parse arg x; x2=x*x; return x*x2 - 3*x2 + x+x
f3: Return((arg(1)-3)*arg(1)+2)*arg(1)</lang>
{{out}}
<pre>E:\>rexx ftest
REXX-ooRexx_4.2.0(MT)_32-bit 6.04 22 Feb 2014
N=1000000
f1 60 1.747000
f2 60 1.108000
f3 60 0.452000
 
E:\>regina ftest
REXX-Regina_3.9.1(MT) 5.00 5 Apr 2015
N=1000000
f1 60 3.167000
f2 60 3.213000
f3 60 1.233000
 
ftest
REXX370 4.02 01 Dec 1998
N=10000
f1 60 41.958018
f2 60 30.447473
f3 60 28.532632</pre>
 
=={{header|RLaB}}==
2,299

edits