Post by ObiWan:: On Thu, 30 May 2024 10:58:45 -0400
:: (microsoft.public.vb.general.discussion)
Post by StanWeissI have always used ()^.5 is SQRT() better for any reason?
It would be interesting to check the speed and the precision of both
methods, it shouldn't be difficult putting together a couple of loops
doing each operation on a given list of values and filling two arrays,
at end it will be possible to check the elapsed time for each loop and
to compare the results to check if there are discrepancies :)
Thanks.
Before I look at speed I wanted to make sure that they didn't produce a
different results.
I ran the following code.
For a = .12345 To 10000 Step .12345
If (a)^.5 <> SQR(a) Then
WorkString = WorkString & "Calculation Mismatch " & Format(a,
"0.0######################") & " - " & Format((a)^.5,
"0.0######################") & " - " & Format(SQR(a),
"0.0######################") & VBCrLf
End If
Next
I got he following results. I don't see the difference
Calculation Mismatch 97.4020500000008 - 9.86924769169367 - 9.86924769169367
Calculation Mismatch 396.644849999983 - 19.9159446173156 - 19.9159446173156
Calculation Mismatch 1272.64605000027 - 35.6741650217671 - 35.6741650217671
Calculation Mismatch 1485.84420000035 - 38.5466496598648 - 38.5466496598648
Calculation Mismatch 1623.49095000041 - 40.2925669323811 - 40.2925669323811
Calculation Mismatch 1624.60200000041 - 40.3063518567534 - 40.3063518567534
Calculation Mismatch 1889.89605000051 - 43.4729346835535 - 43.4729346835535
Calculation Mismatch 1935.44910000053 - 43.9937393273239 - 43.9937393273239
Calculation Mismatch 1964.33640000054 - 44.3208348296886 - 44.3208348296886
Calculation Mismatch 1984.33530000055 - 44.5458785972456 - 44.5458785972456
Calculation Mismatch 2192.59545000063 - 46.8251583019281 - 46.8251583019281
Calculation Mismatch 2252.83905000065 - 47.4640816828963 - 47.4640816828963
Calculation Mismatch 2274.44280000066 - 47.6911186700486 - 47.6911186700486
Calculation Mismatch 2798.73495000086 - 52.9030712719107 - 52.9030712719107
Calculation Mismatch 2799.84600000086 - 52.9135710380698 - 52.9135710380699
Calculation Mismatch 3036.37620000096 - 55.103322948811 - 55.103322948811
Calculation Mismatch 3118.10010000099 - 55.8399507521361 - 55.8399507521361
Calculation Mismatch 3566.84085000116 - 59.7230345009458 - 59.7230345009458
Calculation Mismatch 3648.68820000119 - 60.4043723583086 - 60.4043723583086
Calculation Mismatch 3709.91940000122 - 60.9091076933591 - 60.9091076933591
Calculation Mismatch 3947.93100000131 - 62.8325632136817 - 62.8325632136817
Calculation Mismatch 4299.51660000145 - 65.5706992489896 - 65.5706992489896
Calculation Mismatch 5346.74295000186 - 73.1214260665221 - 73.1214260665221
Calculation Mismatch 5400.81405000188 - 73.4902309834571 - 73.4902309834571
Calculation Mismatch 5441.92290000189 - 73.769389993424 - 73.7693899934241
Calculation Mismatch 5945.59890000209 - 77.1077097312719 - 77.1077097312719
Calculation Mismatch 6015.34815000212 - 77.5586755302211 - 77.5586755302211
Calculation Mismatch 6171.88275000218 - 78.5613311369033 - 78.5613311369033
Calculation Mismatch 6491.4948000023 - 80.5698132057057 - 80.5698132057056
Calculation Mismatch 6532.60365000232 - 80.8245238154999 - 80.8245238154999
Calculation Mismatch 6802.34190000242 - 82.4763111444882 - 82.4763111444882
Calculation Mismatch 6898.87980000246 - 83.0594955438718 - 83.0594955438718
Calculation Mismatch 6902.95365000246 - 83.0840156107206 - 83.0840156107206
Calculation Mismatch 7217.25735000258 - 84.9544427914314 - 84.9544427914313
Calculation Mismatch 7280.09340000261 - 85.3234633615081 - 85.323463361508
Calculation Mismatch 7443.54120000267 - 86.2759595716134 - 86.2759595716134
Calculation Mismatch 7910.55255000285 - 88.9412870943683 - 88.9412870943683
Calculation Mismatch 8340.52890000193 - 91.3264961552885 - 91.3264961552885
Calculation Mismatch 8760.50579999899 - 93.5975736864957 - 93.5975736864957
Thanks,
Stan
--
This email has been checked for viruses by Avast antivirus software.
www.avast.com