# [Scilab-users] Floating-point relative accuracy – HELP

3 messages
Open this post in threaded view
|

## [Scilab-users] Floating-point relative accuracy – HELP

 Hello I'm not fully conversant with Matlab, but offered to help my daughter with a tutorial in Scilab ... and then Matlab! Basically Matlab gives the 'expected' tutorial answer (n=17), and scilab does not! Hopefully this is down to my lack of expertise, but i would very much like understand why. Does the problem require the use of floating-point relative accuracy feature (%eps)? Any help would be very much appreciated. *** scilab output   n k S dif      0.    1.    1.    1.718281828459045      1.    1.    2.    0.718281828459045      2.    2.    2.5    0.218281828459045      3.    6.    2.666666666666667    0.051615161792379      4.    24.    2.708333333333333    0.009948495125712      5.    120.    2.716666666666666    0.001615161792379      6.    720.    2.718055555555555    0.000226272903490      7.    5040.    2.718253968253968    0.000027860205077      8.    40320.    2.71827876984127    0.000003058617775      9.    362880.    2.718281525573192    0.000000302885853      10.    3628800.    2.718281801146385    0.000000027312661      11.    39916800.    2.718281826198493    0.000000002260552      12.    479001600.    2.718281828286169    0.000000000172876      13.    6227020800.    2.718281828446759    0.000000000012286      14.    87178291200.    2.71828182845823    0.000000000000815      15.    1307674368000.    2.718281828458995 0.000000000000050      16.    20922789888000.    2.718281828459043 0.000000000000002      17.    355687428096000.    2.718281828459046 4.44089209850D-16      18.    6402373705728000.    2.718281828459046 4.44089209850D-16      19.    1.21645100409D+17    2.718281828459046 4.44089209850D-16      20.    2.43290200818D+18    2.718281828459046 4.44089209850D-16 *** matlab output n k S dif 0           1           1      1.7183 1           1           2     0.71828 2           2         2.5     0.21828 3           6      2.6667    0.051615 4           24      2.70833    0.0099485 5           120      2.716667   0.001615162 6           720      2.718056  0.0002262729 7           5040       2.718254  2.7860205e-05 8           40320      2.71827877  3.05861778e-06 9           362880      2.718281526  3.028858533e-07 10           3628800      2.7182818011  2.7312661022e-08 11           39916800       2.7182818262  2.26055263397e-09 12           479001600      2.718281828286  1.728768239673e-10 13           6227020800      2.7182818284468  1.2286172079712e-11 14           87178291200      2.71828182845823 8.15347789284715e-13 15          1307674368000      2.718281828458995 5.062616992290714e-14 16         20922789888000      2.718281828459043 2.664535259100376e-15 17        355687428096000 2.718281828459046                      0 _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users m.txt (1K) Download Attachment q4.m (564 bytes) Download Attachment q4.sce (666 bytes) Download Attachment sce.txt (1K) Download Attachment
 Hello, Le 14/12/2017 à 21:54, David Brant a écrit : ```Hello I'm not fully conversant with Matlab, but offered to help my daughter with a tutorial in Scilab ... and then Matlab! Basically Matlab gives the 'expected' tutorial answer (n=17), and scilab does not! Hopefully this is down to my lack of expertise, but i would very much like understand why. Does the problem require the use of floating-point relative accuracy feature (%eps)?``` Yes. The stopping test is ```if dif/S <= %eps break end ``` This stops at n=17 as well. Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users