Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * Closures are admitted
6 *
7 * @path ch13/13.2/S13.2.1_A5_T2.js
8 * @description Returning a function that approximates the derivative of f
9 * using an interval of dx, which should be appropriately small
10 */
12 // Return a function that approximates the derivative of f
13 // using an interval of dx, which should be appropriately small.
14 function derivative(f, dx) {
15 return function(x) {
16 return (f(x + dx) - f(x)) / dx;
17 };
18 }
20 //////////////////////////////////////////////////////////////////////////////
21 //CHECK#1
22 if (Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) >= 1/65536.0) {
23 $ERROR('#1: Math.abs(derivative(Math.sin, 0.0001)(0) - derivative(Math.sin, 0.0001)(2*Math.PI)) <= 1/65536.0');
24 }
25 //
26 //////////////////////////////////////////////////////////////////////////////