This exercise covers built-in JavaScript Math functions.
- Generate a plot of
Math.sinover the interval[0,2π]. - Generate a plot of
Math.cosover the interval[0,2π].
A common measure of numerical accuracy is the root-mean-square error (RMSE). The basic idea is to determine the average deviation of computed values from a known standard. The lower the RMSE, the more accurate the algorithm; the higher the RMSE, the less accurate the algorithm.
- Write a function to compute the root-mean-square error (RMSE).
- Generate a plot showing the sine computed by
Math.sinand the sine computed from Julia (Julia results can be found in the./fixturesdirectory). Thexvalues over which to compute the sin are included in the fixtures. - Generate a plot showing the deviations (in units of epsilon) of
Math.sinfrom Julia (include the RMSE in the plot title). - As a bonus, repeat the test for different Node versions.
-
Extend the previous solutions to test the following Math functions:
costansqrtpowexplog
The output should be a single web page showing the deviations in units of epsilon for all functions.
-
As a bonus, repeat the tests for different browsers, such as Firefox and Internet Explorer.
-
Extend the previous solution to test custom implementations of the above functions.
sin:@stdlib/math/base/special/sincos:@stdlib/math/base/special/costan:@stdlib/math/base/special/tansqrt:@stdlib/math/base/special/sqrtlog:@stdlib/math/base/special/lnexp:@stdlib/math/base/special/exppow:@stdlib/math/base/special/pow
- When calculating the RMSE, consider using Welford's method for robust computation of the mean.
- When generating plots, be sure to specify plot axis labels and the plot title.
- To test against different Node versions, use nvm.
- Testing different browsers may be rather involved. One possible solution would be to launch a browser, load a test script which runs the computations, and then stream the results back to an analysis server which collects the results and generates a plot.
Assuming that each solution is placed in a separate file,
$ node ./path/to/<solution_1>.js
$ node ./path/to/<solution_2>.js
# ...When all your solutions succeed, proceed to the next exercise.