index.js (1745B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Compute the relative difference of two real numbers. 23 * 24 * @module @stdlib/math/base/utils/relative-difference 25 * 26 * @example 27 * var reldiff = require( '@stdlib/math/base/utils/relative-difference' ); 28 * 29 * var d = reldiff( 2.0, 5.0 ); // => 3/5 30 * // returns 0.6 31 * 32 * d = reldiff( -1.0, 3.14 ); // => 4.14/3.14 33 * // returns ~1.318 34 * 35 * d = reldiff( -2.0, 5.0, 'max-abs' ); // => |-7/5| 36 * // returns 1.4 37 * 38 * d = reldiff( -2.0, 5.0, 'max' ); // => |-7/5| 39 * // returns 1.4 40 * 41 * d = reldiff( -2.0, 5.0, 'min-abs' ); // => |-7/2| 42 * // returns 3.5 43 * 44 * d = reldiff( -2.0, 5.0, 'min' ); // => |-7/-2| 45 * // returns 3.5 46 * 47 * d = reldiff( -2.0, 5.0, 'mean-abs' ); // => |-7/3.5| 48 * // returns 2.0 49 * 50 * d = reldiff( -2.0, 5.0, 'mean' ); // => |-7/1.5| 51 * // returns ~4.67 52 * 53 * d = reldiff( -2.0, 5.0, 'x' ); // => |-7/-2| 54 * // returns 3.5 55 * 56 * d = reldiff( 5.0, -2.0, 'x' ); // => |7/5| 57 * // returns 1.4 58 * 59 * d = reldiff( -2.0, 5.0, 'y' ); // => |-7/5| 60 * // returns 1.4 61 * 62 * d = reldiff( 5.0, -2.0, 'y' ); // => |7/-2| 63 * // returns 3.5 64 */ 65 66 // MODULES // 67 68 var reldiff = require( './main.js' ); 69 70 71 // EXPORTS // 72 73 module.exports = reldiff;