Abstract
Despite their widespread use, implementations of numerical computing algorithms are generally tested manually with fuzzily defined thresholds determining success or failure. Modern software testing methods, such as automated regression testing, are difficult to apply because both test oracles and algorithm output are approximate. Based on the observation that high accuracy numerical algorithms appear to be fragile by design to errors in their parameters, we propose to compare the error of target implementations to mutated versions of themselves with the expectation that the mutants will suffer degraded accuracy. We test the idea on Matlab implementations of some basic numerical algorithms, and find that most mutants are worse while the few which are better show a distinctive pattern of mutation.
This work was supported by National Science and Engineering Research Council of Canada (NSERC) Discovery Grant RGPIN-2017-04543 and an Undergraduate Student Research Award (USRA).
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
These quantities may be known when it comes time to solve a particular problem, but outside of introductory numerical analysis courses most problems are solved by calling a library routine or legacy implementation; consequently, those who design, implement and test such routines should not assume knowledge of these values.
References
Ascher, U.M., Greif, C.: A First Course on Numerical Methods. SIAM (2011)
de Dinechin, F., Lauter, C.Q., Melquiond, G.: Assisted verification of elementary functions using Gappa. In: ACM Symposium on Applied Computing, pp. 1318–1322 (2006). https://doi.org/10.1145/1141277.1141584
Grcar, J.: John von Neumann’s analysis of Gaussian elimination and the origins of modern numerical analysis. SIAM Rev. 53(4), 607–682 (2011). https://doi.org/10.1137/080734716
Guest, C., McKean, M., Shearer, H., Reiner, R.: This is spinal tap. film (1984). Director: Rob Reiner, producer: Karen Murphy
Heath, M.T.: Scientific Computing: An Introductory Survey. SIAM (2018)
Hook, D., Kelly, D.: Mutation sensitivity testing. Comput. Sci. Eng. 11(6), 40–47 (2009)
Howden, W.E.: Theoretical and empirical studies of program testing. In: Proceedings of the 3rd International Conference on Software Engineering, pp. 305–311 (1978)
Howden, W.E.: Weak mutation testing and completeness of test sets. IEEE Trans. Softw. Eng. 4, 371–379 (1982)
Jézéquel, F., Chesneaux, J.M.: CADNA: a library for estimating round-off error propagation. Comput. Phys. Commun. 178(12), 933–955 (2008). https://doi.org/10.1016/j.cpc.2008.02.003
Knupp, P., Salari, K.: Verification of Computer Codes in Computational Science and Engineering. Chapman & Hall/CRC, Boca Raton (2002)
Nedialkov, N.S.: VNODE-LP: a validated solver for initial value problems in ordinary differential equations. Technical report CAS-06-06-NN, Department of Computing and Software, McMaster University (2006)
Oberkampf, W.L., Roy, C.J.: Verification and Validation in Scientific Computing. Cambridge University Press, Cambridge (2010)
Roy, C.J.: Review of code and solution verification procedures for computational simulation. J. Comput. Phys. 205(1), 131–156 (2005)
Von Neumann, J., Goldstine, H.H.: Numerical inverting of matrices of high order. Bull. Am. Math. Soc. 53(11), 1021–1099 (1947)
Wikipedia contributors: Sign test—Wikipedia, the free encyclopedia (2019). https://en.wikipedia.org/wiki/Sign_test. Accessed 30 Apr 2019
Acknowledgements
The authors would like to thank Kevin Jayamanna for doing related preliminary work in his undergrad thesis, and Daniel Hook for providing MATmute to the community.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
A Numerical Algorithms
A Numerical Algorithms
Our implementations are based on the descriptions in [1]. In this section we briefly describe each of the algorithms, the error measurement for that algorithm, and the test case generation procedure.
1.1 A.1 Simpson’s Method
The definite integral problem is to evaluate
for a specified \(a,b \in \mathbb {R}\) and scalar function f(x).
Simpson’s method is a fourth order accurate method that is used to approximate definite integrals. It is given by:
Composite Simpson’s method involves dividing the domain of integration into subintervals called “panels,” applying Simpson’s method to each panel, and summing the result. Let r, the number of panels, be even. The formula is
where \(t_i = a+ih\), \(i = \{1, 2, ..., r\}\).
For analysis purposes, we define the error as the absolute value of the difference between the algorithm’s output and the (floating point approximation of the) analytic answer. It can be shown that composite Simpson’s method has an error bound of
A typical 3-line implementation of composite Simpson’s method in Matlab generates 180–190 mutants using MATmute, of which roughly 120–130 are viable.
Test cases are generated either using pen-and-paper integration, or by MMS.
1.2 A.2 Complete Cubic Spline
A cubic spline is a continuously differentiable, piecewise cubic scalar function v(x) that interpolates points \(\{(x_1,f(x_1)), ..., (x_n,f(x_n))\}\), meaning that \(v(x_i) = f(x_i)\). We call the spline “complete” because the derivatives at the endpoints \(f'(x_1)\) and \(f'(x_n)\) are also provided, and we choose v(x) such that \(v'(x_1) = f'(x_1)\) and \(v'(x_n) = f'(x_n)\).
For analysis purposes, we generate a set of test points between the interpolation points, compute the difference between the value of the interpolant and the value of the original function at these test points, and report the greatest absolute difference across all test points as the error.
MATmute generates roughly 680–700 mutants from our 30-line implementation of a complete cubic spline.
For this problem analytic solutions are trivial to construct: We pick a function f and a set of points \(\{x_i\}\). Then, we use \(\{x_i\}\) and \(\{f(x_i)\}\) as the input to our cubic spline algorithm. The exact answers can be obtained directly from the function f.
1.3 A.3 Runge-Kutta Schemes
Runge-Kutta methods are used to solve initial value problems for ordinary differential equations. This class of problems is defined by:
where f(x) and \(x_0\) are specified. While x(t) may be a vector in general, for our purposes we considered only scalar cases.
We used the classic fourth order accurate Runge-Kutta method. It is given by the following set of update formulae:
where \(y_n\) is the approximation at time \(t_n\) and a fixed stepsize h has been assumed.
For analysis purposes, we define the error in our Runge-Kutta implementation as the absolute value of the difference between the algorithm’s output and the analytic answer at a final time.
MATmute generates roughly 480–500 mutants from a typical 4th order Runge-Kutta implementation.
Test cases are generated by MMS: Starting with a function for x(t), supply
as the inputs.
Rights and permissions
Copyright information
© 2019 Springer Nature Switzerland AG
About this paper
Cite this paper
Wu, R.(., Mitchell, I.M. (2019). Mutant Accuracy Testing for Assessing the Implementation of Numerical Algorithms. In: Zamani, M., Zufferey, D. (eds) Numerical Software Verification. NSV 2019. Lecture Notes in Computer Science(), vol 11652. Springer, Cham. https://doi.org/10.1007/978-3-030-28423-7_9
Download citation
DOI: https://doi.org/10.1007/978-3-030-28423-7_9
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-28422-0
Online ISBN: 978-3-030-28423-7
eBook Packages: Computer ScienceComputer Science (R0)