Merge lp:~rpadovani/ubuntu-calculator-app/mathjs140 into lp:ubuntu-calculator-app

Proposed by Riccardo Padovani
Status: Merged
Approved by: Bartosz Kosiorek
Approved revision: 116
Merged at revision: 117
Proposed branch: lp:~rpadovani/ubuntu-calculator-app/mathjs140
Merge into: lp:ubuntu-calculator-app
Diff against target: 19309 lines (+9350/-7017)
1 file modified
app/engine/math.js (+9350/-7017)
To merge this branch: bzr merge lp:~rpadovani/ubuntu-calculator-app/mathjs140
Reviewer Review Type Date Requested Status
Bartosz Kosiorek Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+251419@code.launchpad.net

Commit message

Updated math.js to 1.4.0

Description of the change

Updated math.js to 1.4.0

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bartosz Kosiorek (gang65) wrote :

It works perfectly for me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/engine/math.js'
2--- app/engine/math.js 2015-01-22 17:37:01 +0000
3+++ app/engine/math.js 2015-03-02 09:18:55 +0000
4@@ -34,8 +34,8 @@
5 */
6
7 (function webpackUniversalModuleDefinition(root, factory) {
8- // UCA: we delete all exports, we don't need them, and we keep only our var
9- mathJs = factory();
10+ // UCA: we delete all exports, we don't need them, and we keep only our var
11+ mathJs = factory();
12 })(this, function() {
13 return /******/ (function(modules) { // webpackBootstrap
14 /******/ // The module cache
15@@ -92,8 +92,8 @@
16
17 'use strict';
18
19- var object = __webpack_require__(3);
20- var digits = __webpack_require__(4).digits;
21+ var object = __webpack_require__(2);
22+ var digits = __webpack_require__(3).digits;
23
24 /**
25 * math.js factory function.
26@@ -158,7 +158,7 @@
27
28 // reload the constants (they depend on option number and precision)
29 // this must be done after math.type.BigNumber.config is applied
30- __webpack_require__(2)(math, _config);
31+ __webpack_require__(4)(math, _config);
32
33 // TODO: remove deprecated setting some day (deprecated since version 0.17.0)
34 if (options.number && options.number.defaultType) {
35@@ -205,7 +205,7 @@
36 math.create = create;
37
38 // create a new BigNumber factory for this instance of math.js
39- var BigNumber = __webpack_require__(159).constructor();
40+ var BigNumber = __webpack_require__(5).constructor();
41
42 // extend BigNumber with a function clone
43 if (typeof BigNumber.prototype.clone !== 'function') {
44@@ -241,37 +241,40 @@
45 }
46
47 // errors
48- math.error = __webpack_require__(5);
49+ math.error = __webpack_require__(6);
50
51 // types (Matrix, Complex, Unit, ...)
52 math.type = {};
53- math.type.Complex = __webpack_require__(6);
54- math.type.Range = __webpack_require__(7);
55- math.type.Index = __webpack_require__(8);
56- math.type.Matrix = __webpack_require__(9);
57- math.type.Unit = __webpack_require__(10);
58- math.type.Help = __webpack_require__(11);
59- math.type.ResultSet = __webpack_require__(12);
60+ math.type.Complex = __webpack_require__(7);
61+ math.type.Range = __webpack_require__(8);
62+ math.type.Index = __webpack_require__(9);
63+ math.type.Matrix = __webpack_require__(10);
64+ math.type.Unit = __webpack_require__(11);
65+ math.type.Help = __webpack_require__(12);
66+ math.type.ResultSet = __webpack_require__(13);
67 math.type.BigNumber = BigNumber;
68
69- math.collection = __webpack_require__(13);
70+ math.collection = __webpack_require__(14);
71
72 // expression (parse, Parser, nodes, docs)
73 math.expression = {};
74- math.expression.node = __webpack_require__(16);
75- math.expression.parse = __webpack_require__(14);
76- math.expression.Parser = __webpack_require__(15);
77- math.expression.docs = __webpack_require__(17);
78+ math.expression.node = __webpack_require__(15);
79+ math.expression.parse = __webpack_require__(16);
80+ math.expression.Parser = __webpack_require__(17);
81+ math.expression.docs = __webpack_require__(18);
82+
83+ // serialization utilities
84+ math.json = {
85+ reviver: __webpack_require__(19)
86+ };
87
88 // expression parser
89- __webpack_require__(29)(math, _config);
90- __webpack_require__(30)(math, _config);
91 __webpack_require__(31)(math, _config);
92 __webpack_require__(32)(math, _config);
93-
94- // functions - arithmetic
95 __webpack_require__(33)(math, _config);
96 __webpack_require__(34)(math, _config);
97+
98+ // functions - arithmetic
99 __webpack_require__(35)(math, _config);
100 __webpack_require__(36)(math, _config);
101 __webpack_require__(37)(math, _config);
102@@ -299,25 +302,25 @@
103 __webpack_require__(59)(math, _config);
104 __webpack_require__(60)(math, _config);
105 __webpack_require__(61)(math, _config);
106-
107- // functions - bitwise
108 __webpack_require__(62)(math, _config);
109 __webpack_require__(63)(math, _config);
110+
111+ // functions - bitwise
112 __webpack_require__(64)(math, _config);
113 __webpack_require__(65)(math, _config);
114 __webpack_require__(66)(math, _config);
115 __webpack_require__(67)(math, _config);
116 __webpack_require__(68)(math, _config);
117-
118- // functions - complex
119 __webpack_require__(69)(math, _config);
120 __webpack_require__(70)(math, _config);
121+
122+ // functions - complex
123 __webpack_require__(71)(math, _config);
124 __webpack_require__(72)(math, _config);
125-
126- // functions - construction
127 __webpack_require__(73)(math, _config);
128 __webpack_require__(74)(math, _config);
129+
130+ // functions - construction
131 __webpack_require__(75)(math, _config);
132 __webpack_require__(76)(math, _config);
133 __webpack_require__(77)(math, _config);
134@@ -326,16 +329,16 @@
135 __webpack_require__(80)(math, _config);
136 __webpack_require__(81)(math, _config);
137 __webpack_require__(82)(math, _config);
138-
139- // functions - logical
140 __webpack_require__(83)(math, _config);
141 __webpack_require__(84)(math, _config);
142+
143+ // functions - logical
144 __webpack_require__(85)(math, _config);
145 __webpack_require__(86)(math, _config);
146-
147- // functions - matrix
148 __webpack_require__(87)(math, _config);
149 __webpack_require__(88)(math, _config);
150+
151+ // functions - matrix
152 __webpack_require__(89)(math, _config);
153 __webpack_require__(90)(math, _config);
154 __webpack_require__(91)(math, _config);
155@@ -350,41 +353,41 @@
156 __webpack_require__(100)(math, _config);
157 __webpack_require__(101)(math, _config);
158 __webpack_require__(102)(math, _config);
159-
160- // functions - probability
161- //require('./function/probability/distribution')(math, _config); // TODO: rethink math.distribution
162 __webpack_require__(103)(math, _config);
163 __webpack_require__(104)(math, _config);
164 __webpack_require__(105)(math, _config);
165+
166+ // functions - probability
167+ //require('./function/probability/distribution')(math, _config); // TODO: rethink math.distribution
168 __webpack_require__(106)(math, _config);
169 __webpack_require__(107)(math, _config);
170 __webpack_require__(108)(math, _config);
171 __webpack_require__(109)(math, _config);
172-
173- // functions - relational
174 __webpack_require__(110)(math, _config);
175 __webpack_require__(111)(math, _config);
176 __webpack_require__(112)(math, _config);
177+
178+ // functions - relational
179 __webpack_require__(113)(math, _config);
180 __webpack_require__(114)(math, _config);
181 __webpack_require__(115)(math, _config);
182 __webpack_require__(116)(math, _config);
183 __webpack_require__(117)(math, _config);
184-
185- // functions - statistics
186 __webpack_require__(118)(math, _config);
187 __webpack_require__(119)(math, _config);
188 __webpack_require__(120)(math, _config);
189+
190+ // functions - statistics
191 __webpack_require__(121)(math, _config);
192 __webpack_require__(122)(math, _config);
193 __webpack_require__(123)(math, _config);
194 __webpack_require__(124)(math, _config);
195 __webpack_require__(125)(math, _config);
196-
197- // functions - trigonometry
198 __webpack_require__(126)(math, _config);
199 __webpack_require__(127)(math, _config);
200 __webpack_require__(128)(math, _config);
201+
202+ // functions - trigonometry
203 __webpack_require__(129)(math, _config);
204 __webpack_require__(130)(math, _config);
205 __webpack_require__(131)(math, _config);
206@@ -398,11 +401,7 @@
207 __webpack_require__(139)(math, _config);
208 __webpack_require__(140)(math, _config);
209 __webpack_require__(141)(math, _config);
210-
211- // functions - units
212 __webpack_require__(142)(math, _config);
213-
214- // functions - utils
215 __webpack_require__(143)(math, _config);
216 __webpack_require__(144)(math, _config);
217 __webpack_require__(145)(math, _config);
218@@ -412,6 +411,22 @@
219 __webpack_require__(149)(math, _config);
220 __webpack_require__(150)(math, _config);
221 __webpack_require__(151)(math, _config);
222+ __webpack_require__(152)(math, _config);
223+ __webpack_require__(153)(math, _config);
224+
225+ // functions - units
226+ __webpack_require__(154)(math, _config);
227+
228+ // functions - utils
229+ __webpack_require__(155)(math, _config);
230+ __webpack_require__(156)(math, _config);
231+ __webpack_require__(157)(math, _config);
232+ __webpack_require__(158)(math, _config);
233+ __webpack_require__(159)(math, _config);
234+ __webpack_require__(160)(math, _config);
235+ __webpack_require__(161)(math, _config);
236+ __webpack_require__(162)(math, _config);
237+ __webpack_require__(163)(math, _config);
238
239 // TODO: deprecated since version 0.25.0, remove some day.
240 math.ifElse = function () {
241@@ -419,23 +434,25 @@
242 };
243
244 // constants
245- __webpack_require__(2)(math, _config);
246+ __webpack_require__(4)(math, _config);
247
248 // attach transform functions (for converting one-based indices to zero-based)
249- __webpack_require__(18)(math, _config);
250- __webpack_require__(19)(math, _config);
251- __webpack_require__(20)(math, _config);
252- __webpack_require__(21)(math, _config);
253- __webpack_require__(22)(math, _config);
254- __webpack_require__(23)(math, _config);
255- __webpack_require__(24)(math, _config);
256- __webpack_require__(25)(math, _config);
257- __webpack_require__(26)(math, _config);
258- __webpack_require__(27)(math, _config);
259+ math.expression.transform = {
260+ concat: __webpack_require__(20)(math, _config),
261+ filter: __webpack_require__(21)(math, _config),
262+ forEach:__webpack_require__(22)(math, _config),
263+ index: __webpack_require__(23)(math, _config),
264+ map: __webpack_require__(24)(math, _config),
265+ max: __webpack_require__(25)(math, _config),
266+ mean: __webpack_require__(26)(math, _config),
267+ min: __webpack_require__(27)(math, _config),
268+ range: __webpack_require__(28)(math, _config),
269+ subset: __webpack_require__(29)(math, _config)
270+ };
271
272 // selector (we initialize after all functions are loaded)
273 math.chaining = {};
274- math.chaining.Chain = __webpack_require__(28)(math, _config);
275+ math.chaining.Chain = __webpack_require__(30)(math, _config);
276 math.chaining.Selector = math.chaining.Chain; // TODO: deprecate in v2.0
277
278 // apply provided configuration options
279@@ -464,49 +481,6 @@
280
281 'use strict';
282
283- module.exports = function (math, config) {
284- var bignumber = __webpack_require__(152);
285- var Complex = __webpack_require__(6);
286- var BigNumber = math.type.BigNumber;
287-
288- var big = config.number === 'bignumber';
289-
290- // TODO: in case of support for defineProperty, we can lazy evaluate the BigNumber constants by creating them as properties (calculation of PI is slow for example)
291- math.pi = big ? bignumber.pi(config.precision) : Math.PI;
292- math.tau = big ? bignumber.tau(config.precision) : Math.PI * 2;
293- math.e = big ? bignumber.e(config.precision) : Math.E;
294- math.phi = big ? bignumber.phi(config.precision) : 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2
295-
296- math.i = new Complex(0, 1);
297-
298- math['Infinity'] = Infinity;
299- math['NaN'] = NaN;
300- math['true'] = true;
301- math['false'] = false;
302- math['null'] = null;
303- math['uninitialized'] = __webpack_require__(153).UNINITIALIZED;
304-
305- // uppercase constants (for compatibility with built-in Math)
306- math.E = math.e;
307- math.LN2 = big ? new BigNumber(2).ln() : Math.LN2;
308- math.LN10 = big ? new BigNumber(10).ln() : Math.LN10;
309- math.LOG2E = big ? new BigNumber(1).div(new BigNumber(2).ln()) : Math.LOG2E;
310- math.LOG10E = big ? new BigNumber(1).div(new BigNumber(10).ln()) : Math.LOG10E;
311- math.PI = math.pi;
312- math.SQRT1_2 = big ? new BigNumber(0.5).sqrt() : Math.SQRT1_2;
313- math.SQRT2 = big ? new BigNumber(2).sqrt() : Math.SQRT2;
314-
315- // meta information
316- math.version = __webpack_require__(154);
317- };
318-
319-
320-/***/ },
321-/* 3 */
322-/***/ function(module, exports, __webpack_require__) {
323-
324- 'use strict';
325-
326 /**
327 * Clone an object
328 *
329@@ -652,9 +626,60 @@
330 }
331 };
332
333+ /**
334+ * Test whether the current JavaScript engine supports Object.defineProperty
335+ * @returns {boolean} returns true if supported
336+ */
337+ exports.canDefineProperty = function () {
338+ // test needed for broken IE8 implementation
339+ try {
340+ if (Object.defineProperty) {
341+ Object.defineProperty({}, 'x', {});
342+ return true;
343+ }
344+ } catch (e) {}
345+
346+ return false;
347+ };
348+
349+ /**
350+ * Attach a lazy loading property to a constant.
351+ * The given function `fn` is called once when the property is first requested.
352+ * On older browsers (<IE8), the function will fall back to direct evaluation
353+ * of the properties value.
354+ * @param {Object} object Object where to add the property
355+ * @param {string} prop Property name
356+ * @param {function} fn Function returning the property value. Called
357+ * without arguments.
358+ */
359+ exports.lazy = function (object, prop, fn) {
360+ if (exports.canDefineProperty()) {
361+ var _uninitialized = true;
362+ var _value;
363+ Object.defineProperty(object, prop, {
364+ get: function () {
365+ if (_uninitialized) {
366+ _value = fn();
367+ _uninitialized = false;
368+ }
369+ return _value;
370+ },
371+
372+ set: function (value) {
373+ _value = value;
374+ _uninitialized = false;
375+ }
376+ });
377+ }
378+ else {
379+ // fall back to immediate evaluation
380+ object[prop] = fn();
381+ }
382+ };
383+
384
385 /***/ },
386-/* 4 */
387+/* 3 */
388 /***/ function(module, exports, __webpack_require__) {
389
390 'use strict';
391@@ -938,27 +963,125 @@
392
393
394 /***/ },
395+/* 4 */
396+/***/ function(module, exports, __webpack_require__) {
397+
398+ 'use strict';
399+
400+ module.exports = function (math, config) {
401+ var object = __webpack_require__(2);
402+ var bignumber = __webpack_require__(164);
403+ var Complex = __webpack_require__(7);
404+ var BigNumber = math.type.BigNumber;
405+
406+ math['true'] = true;
407+ math['false'] = false;
408+ math['null'] = null;
409+ math['uninitialized'] = __webpack_require__(165).UNINITIALIZED;
410+
411+ if (config.number === 'bignumber') {
412+ math['Infinity'] = new BigNumber(Infinity);
413+ math['NaN'] = new BigNumber(NaN);
414+
415+ object.lazy(math, 'pi', function () {return bignumber.pi(config.precision)});
416+ object.lazy(math, 'tau', function () {return bignumber.tau(config.precision)});
417+ object.lazy(math, 'e', function () {return bignumber.e(config.precision)});
418+ object.lazy(math, 'phi', function () {return bignumber.phi(config.precision)}); // golden ratio, (1+sqrt(5))/2
419+
420+ // uppercase constants (for compatibility with built-in Math)
421+ object.lazy(math, 'E', function () {return math.e;});
422+ object.lazy(math, 'LN2', function () {return new BigNumber(2).ln();});
423+ object.lazy(math, 'LN10', function () {return new BigNumber(10).ln()});
424+ object.lazy(math, 'LOG2E', function () {return new BigNumber(1).div(new BigNumber(2).ln());});
425+ object.lazy(math, 'LOG10E', function () {return new BigNumber(1).div(new BigNumber(10).ln())});
426+ object.lazy(math, 'PI', function () {return math.pi});
427+ object.lazy(math, 'SQRT1_2', function () {return new BigNumber('0.5').sqrt()});
428+ object.lazy(math, 'SQRT2', function () {return new BigNumber(2).sqrt()});
429+ }
430+ else {
431+ math['Infinity'] = Infinity;
432+ math['NaN'] = NaN;
433+
434+ math.pi = Math.PI;
435+ math.tau = Math.PI * 2;
436+ math.e = Math.E;
437+ math.phi = 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2
438+
439+ // uppercase constants (for compatibility with built-in Math)
440+ math.E = math.e;
441+ math.LN2 = Math.LN2;
442+ math.LN10 = Math.LN10;
443+ math.LOG2E = Math.LOG2E;
444+ math.LOG10E = Math.LOG10E;
445+ math.PI = math.pi;
446+ math.SQRT1_2 = Math.SQRT1_2;
447+ math.SQRT2 = Math.SQRT2;
448+ }
449+
450+ // complex i
451+ math.i = new Complex(0, 1);
452+
453+ // meta information
454+ math.version = __webpack_require__(166);
455+ };
456+
457+
458+/***/ },
459 /* 5 */
460 /***/ function(module, exports, __webpack_require__) {
461
462+ var BigNumber = __webpack_require__(336);
463+
464+ // FIXME: replace all require('decimal.js') with require('./BigNumber').
465+
466+ /**
467+ * Get a JSON representation of a BigNumber containing
468+ * type information
469+ * @returns {Object} Returns a JSON object structured as:
470+ * `{"mathjs": "BigNumber", "value": "0.2"}`
471+ */
472+ BigNumber.prototype.toJSON = function () {
473+ return {
474+ mathjs: 'BigNumber',
475+ value: this.toString()
476+ };
477+ };
478+
479+ /**
480+ * Instantiate a BigNumber from a JSON object
481+ * @param {Object} json a JSON object structured as:
482+ * `{"mathjs": "BigNumber", "value": "0.2"}`
483+ * @return {BigNumber}
484+ */
485+ BigNumber.fromJSON = function (json) {
486+ return new BigNumber(json.value);
487+ };
488+
489+ module.exports = BigNumber;
490+
491+
492+/***/ },
493+/* 6 */
494+/***/ function(module, exports, __webpack_require__) {
495+
496 'use strict';
497
498- exports.ArgumentsError = __webpack_require__(155);
499- exports.DimensionError = __webpack_require__(156);
500- exports.IndexError = __webpack_require__(157);
501- exports.UnsupportedTypeError = __webpack_require__(158);
502+ exports.ArgumentsError = __webpack_require__(167);
503+ exports.DimensionError = __webpack_require__(168);
504+ exports.IndexError = __webpack_require__(169);
505+ exports.UnsupportedTypeError = __webpack_require__(170);
506
507 // TODO: implement an InvalidValueError?
508
509
510 /***/ },
511-/* 6 */
512+/* 7 */
513 /***/ function(module, exports, __webpack_require__) {
514
515 'use strict';
516
517- var util = __webpack_require__(160),
518- Unit = __webpack_require__(10),
519+ var util = __webpack_require__(171),
520+ Unit = __webpack_require__(11),
521 number = util.number,
522
523 isNumber = util.number.isNumber,
524@@ -1334,20 +1457,30 @@
525 * @return {String} str
526 */
527 Complex.prototype.format = function (options) {
528- var str = '',
529- strRe = number.format(this.re, options),
530- strIm = number.format(this.im, options);
531-
532- if (this.im == 0) {
533+ var str = '';
534+ var im = this.im;
535+ var re = this.re;
536+ var strRe = number.format(this.re, options);
537+ var strIm = number.format(this.im, options);
538+
539+ // round either re or im when smaller than the configured precision
540+ var precision = isNumber(options) ? options : options ? options.precision : null;
541+ if (precision !== null) {
542+ var epsilon = Math.pow(10, -precision);
543+ if (Math.abs(re / im) < epsilon) {re = 0;}
544+ if (Math.abs(im / re) < epsilon) {im = 0;}
545+ }
546+
547+ if (im == 0) {
548 // real value
549 str = strRe;
550 }
551- else if (this.re == 0) {
552+ else if (re == 0) {
553 // purely complex value
554- if (this.im == 1) {
555+ if (im == 1) {
556 str = 'i';
557 }
558- else if (this.im == -1) {
559+ else if (im == -1) {
560 str = '-i';
561 }
562 else {
563@@ -1356,8 +1489,8 @@
564 }
565 else {
566 // complex value
567- if (this.im > 0) {
568- if (this.im == 1) {
569+ if (im > 0) {
570+ if (im == 1) {
571 str = strRe + ' + i';
572 }
573 else {
574@@ -1365,7 +1498,7 @@
575 }
576 }
577 else {
578- if (this.im == -1) {
579+ if (im == -1) {
580 str = strRe + ' - i';
581 }
582 else {
583@@ -1386,6 +1519,31 @@
584 };
585
586 /**
587+ * Get a JSON representation of the complex number
588+ * @returns {Object} Returns a JSON object structured as:
589+ * `{"mathjs": "Complex", "re": 2, "im": 3}`
590+ */
591+ Complex.prototype.toJSON = function () {
592+ return {
593+ mathjs: 'Complex',
594+ re: this.re,
595+ im: this.im
596+ };
597+ };
598+
599+ /**
600+ * Create a Complex number from a JSON object
601+ * @param {Object} json A JSON Object structured as
602+ * {"mathjs": "Complex", "re": 2, "im": 3}
603+ * All properties are optional, default values
604+ * for `re` and `im` are 0.
605+ * @return {Complex} Returns a new Complex number
606+ */
607+ Complex.fromJSON = function (json) {
608+ return new Complex(json);
609+ };
610+
611+ /**
612 * Returns a string representation of the complex number.
613 * @return {String} str
614 */
615@@ -1396,12 +1554,12 @@
616
617
618 /***/ },
619-/* 7 */
620+/* 8 */
621 /***/ function(module, exports, __webpack_require__) {
622
623 'use strict';
624
625- var util = __webpack_require__(160);
626+ var util = __webpack_require__(171);
627
628 var number = util.number;
629 var string = util.string;
630@@ -1666,19 +1824,43 @@
631 return this.format();
632 };
633
634+ /**
635+ * Get a JSON representation of the range
636+ * @returns {Object} Returns a JSON object structured as:
637+ * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}`
638+ */
639+ Range.prototype.toJSON = function () {
640+ return {
641+ mathjs: 'Range',
642+ start: this.start,
643+ end: this.end,
644+ step: this.step
645+ };
646+ };
647+
648+ /**
649+ * Instantiate a Range from a JSON object
650+ * @param {Object} json A JSON object structured as:
651+ * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}`
652+ * @return {Range}
653+ */
654+ Range.fromJSON = function (json) {
655+ return new Range(json.start, json.end, json.step);
656+ };
657+
658 // exports
659 module.exports = Range;
660
661
662 /***/ },
663-/* 8 */
664+/* 9 */
665 /***/ function(module, exports, __webpack_require__) {
666
667 'use strict';
668
669- var util = __webpack_require__(160),
670+ var util = __webpack_require__(171),
671
672- Range = __webpack_require__(7),
673+ Range = __webpack_require__(8),
674
675 number = util.number,
676
677@@ -1941,28 +2123,50 @@
678 return '[' + strings.join(', ') + ']';
679 };
680
681+ /**
682+ * Get a JSON representation of the Index
683+ * @returns {Object} Returns a JSON object structured as:
684+ * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}`
685+ */
686+ Index.prototype.toJSON = function () {
687+ return {
688+ mathjs: 'Index',
689+ ranges: this._ranges
690+ };
691+ };
692+
693+ /**
694+ * Instantiate an Index from a JSON object
695+ * @param {Object} json A JSON object structured as:
696+ * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}`
697+ * @return {Index}
698+ */
699+ Index.fromJSON = function (json) {
700+ return Index.create(json.ranges);
701+ };
702+
703 // exports
704 module.exports = Index;
705
706
707 /***/ },
708-/* 9 */
709+/* 10 */
710 /***/ function(module, exports, __webpack_require__) {
711
712 'use strict';
713
714- var util = __webpack_require__(160),
715- DimensionError = __webpack_require__(156),
716-
717- Index = __webpack_require__(8),
718-
719- number = util.number,
720- string = util.string,
721- array = util.array,
722- object = util.object,
723-
724- isArray = Array.isArray,
725- validateIndex = array.validateIndex;
726+ var util = __webpack_require__(171);
727+ var DimensionError = __webpack_require__(168);
728+
729+ var Index = __webpack_require__(9);
730+
731+ var number = util.number;
732+ var string = util.string;
733+ var array = util.array;
734+ var object = util.object;
735+
736+ var isArray = Array.isArray;
737+ var validateIndex = array.validateIndex;
738
739 /**
740 * @constructor Matrix
741@@ -2443,6 +2647,28 @@
742 };
743
744 /**
745+ * Get a JSON representation of the matrix
746+ * @returns {Object}
747+ */
748+ Matrix.prototype.toJSON = function () {
749+ return {
750+ mathjs: 'Matrix',
751+ data: this._data
752+ }
753+ };
754+
755+ /**
756+ * Generate a matrix from a JSON object
757+ * @param {Object} json An object structured like
758+ * `{"mathjs": "Matrix", data: []}`,
759+ * where mathjs is optional
760+ * @returns {Matrix}
761+ */
762+ Matrix.fromJSON = function (json) {
763+ return new Matrix(json.data);
764+ };
765+
766+ /**
767 * Preprocess data, which can be an Array or Matrix with nested Arrays and
768 * Matrices. Replaces all nested Matrices with Arrays
769 * @param {Array} data
770@@ -2467,12 +2693,12 @@
771
772
773 /***/ },
774-/* 10 */
775+/* 11 */
776 /***/ function(module, exports, __webpack_require__) {
777
778 'use strict';
779
780- var util = __webpack_require__(160),
781+ var util = __webpack_require__(171),
782
783 number = util.number,
784 string = util.string,
785@@ -2731,13 +2957,13 @@
786 };
787
788 /**
789- * Unnormalize a value, based on its currently set unit
790+ * Denormalize a value, based on its currently set unit
791 * @param {Number} value
792 * @param {Number} [prefixValue] Optional prefix value to be used
793- * @return {Number} unnormalized value
794+ * @return {Number} denormalized value
795 * @private
796 */
797- Unit.prototype._unnormalize = function (value, prefixValue) {
798+ Unit.prototype._denormalize = function (value, prefixValue) {
799 if (prefixValue == undefined) {
800 return value / this.unit.value / this.prefix.value - this.unit.offset;
801 }
802@@ -2856,7 +3082,7 @@
803 */
804 Unit.prototype.toNumber = function (valuelessUnit) {
805 var other = this.to(valuelessUnit);
806- return other._unnormalize(other.value, other.prefix.value);
807+ return other._denormalize(other.value, other.prefix.value);
808 };
809
810
811@@ -2869,6 +3095,32 @@
812 };
813
814 /**
815+ * Get a JSON representation of the unit
816+ * @returns {Object} Returns a JSON object structured as:
817+ * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}`
818+ */
819+ Unit.prototype.toJSON = function () {
820+ return {
821+ mathjs: 'Unit',
822+ value: this._denormalize(this.value),
823+ unit: this.prefix.name + this.unit.name,
824+ fixPrefix: this.fixPrefix
825+ };
826+ };
827+
828+ /**
829+ * Instantiate a Unit from a JSON object
830+ * @param {Object} json A JSON object structured as:
831+ * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}`
832+ * @return {Unit}
833+ */
834+ Unit.fromJSON = function (json) {
835+ var unit = new Unit(json.value, json.unit);
836+ unit.fixPrefix = json.fixPrefix || false;
837+ return unit;
838+ };
839+
840+ /**
841 * Returns the string representation of the unit.
842 * @return {String}
843 */
844@@ -2888,12 +3140,12 @@
845
846 if (this.value !== null && !this.fixPrefix) {
847 var bestPrefix = this._bestPrefix();
848- value = this._unnormalize(this.value, bestPrefix.value);
849+ value = this._denormalize(this.value, bestPrefix.value);
850 str = number.format(value, options) + ' ';
851 str += bestPrefix.name + this.unit.name;
852 }
853 else {
854- value = this._unnormalize(this.value);
855+ value = this._denormalize(this.value);
856 str = (this.value !== null) ? (number.format(value, options) + ' ') : '';
857 str += this.prefix.name + this.unit.name;
858 }
859@@ -3221,9 +3473,9 @@
860 ampere: {name: 'ampere', base: BASE_UNITS.CURRENT, prefixes: PREFIXES.LONG, value: 1, offset: 0},
861
862 // Temperature
863- // K(C) = °C + 273.15
864- // K(F) = (°F + 459.67) / 1.8
865- // K(R) = °R / 1.8
866+ // K(C) = °C + 273.15
867+ // K(F) = (°F + 459.67) / 1.8
868+ // K(R) = °R / 1.8
869 K: {name: 'K', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 0},
870 degC: {name: 'degC', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 273.15},
871 degF: {name: 'degF', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1/1.8, offset: 459.67},
872@@ -3339,34 +3591,33 @@
873
874
875 /***/ },
876-/* 11 */
877+/* 12 */
878 /***/ function(module, exports, __webpack_require__) {
879
880 'use strict';
881
882- var util = __webpack_require__(160),
883- object = util.object,
884- string = util.string;
885+ var util = __webpack_require__(171);
886+ var object = util.object;
887+ var string = util.string;
888
889 /**
890 * Documentation object
891- * @param {Object} math The math.js namespace
892 * @param {Object} doc Object containing properties:
893 * {String} name
894 * {String} category
895+ * {String} description
896 * {String[]} syntax
897 * {String[]} examples
898 * {String[]} seealso
899 * @constructor
900 */
901- function Help (math, doc) {
902+ function Help (doc) {
903 if (!(this instanceof Help)) {
904 throw new SyntaxError('Constructor must be called with the new operator');
905 }
906
907- // TODO: throw an error when math or doc is not provided
908+ if (!doc) throw new Error('Argument "doc" missing');
909
910- this.math = math;
911 this.doc = doc;
912 }
913
914@@ -3381,10 +3632,11 @@
915
916 /**
917 * Generate readable description from a Help object
918+ * @param {Object} [math] A math instance, used to evaluate the examples
919 * @return {String} readableDoc
920 * @private
921 */
922- Help.prototype.toString = function () {
923+ Help.prototype.toText = function (math) {
924 var doc = this.doc || {};
925 var desc = '\n';
926
927@@ -3401,20 +3653,23 @@
928 desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n';
929 }
930 if (doc.examples) {
931- var parser = this.math.parser();
932+ var parser = math && math.parser();
933 desc += 'Examples:\n';
934 for (var i = 0; i < doc.examples.length; i++) {
935 var expr = doc.examples[i];
936- var res;
937- try {
938- res = parser.eval(expr);
939- }
940- catch (e) {
941- res = e;
942- }
943 desc += ' ' + expr + '\n';
944- if (res !== undefined && !(res instanceof Help)) {
945- desc += ' ' + string.format(res, {precision: 14}) + '\n';
946+
947+ if (parser) {
948+ var res;
949+ try {
950+ res = parser.eval(expr);
951+ }
952+ catch (e) {
953+ res = e;
954+ }
955+ if (res !== undefined && !(res instanceof Help)) {
956+ desc += ' ' + string.format(res, {precision: 14}) + '\n';
957+ }
958 }
959 }
960 desc += '\n';
961@@ -3426,13 +3681,37 @@
962 return desc;
963 };
964
965- // TODO: implement a toHTML function in Help
966+ /**
967+ * Generate a string representation of the Help object
968+ * @return {String} Returns a string
969+ * @private
970+ */
971+ Help.prototype.toString = function () {
972+ return this.toText();
973+ };
974
975 /**
976 * Export the help object to JSON
977 */
978 Help.prototype.toJSON = function () {
979- return object.clone(this.doc);
980+ var obj = object.clone(this.doc);
981+ obj.mathjs = 'Help';
982+ return obj;
983+ };
984+
985+ /**
986+ * Instantiate a Help object from a JSON object
987+ * @param {Object} json
988+ * @returns {Help} Returns a new Help object
989+ */
990+ Help.fromJSON = function (json) {
991+ var doc = {};
992+ for (var prop in json) {
993+ if (prop !== 'mathjs') { // ignore mathjs field
994+ doc[prop] = json[prop];
995+ }
996+ }
997+ return new Help(doc);
998 };
999
1000 /**
1001@@ -3445,7 +3724,7 @@
1002
1003
1004 /***/ },
1005-/* 12 */
1006+/* 13 */
1007 /***/ function(module, exports, __webpack_require__) {
1008
1009 'use strict';
1010@@ -3479,22 +3758,44 @@
1011 return '[' + this.entries.join(', ') + ']';
1012 };
1013
1014+ /**
1015+ * Get a JSON representation of the ResultSet
1016+ * @returns {Object} Returns a JSON object structured as:
1017+ * `{"mathjs": "ResultSet", "entries": [...]}`
1018+ */
1019+ ResultSet.prototype.toJSON = function () {
1020+ return {
1021+ mathjs: 'ResultSet',
1022+ entries: this.entries
1023+ };
1024+ };
1025+
1026+ /**
1027+ * Instantiate a ResultSet from a JSON object
1028+ * @param {Object} json A JSON object structured as:
1029+ * `{"mathjs": "ResultSet", "entries": [...]}`
1030+ * @return {ResultSet}
1031+ */
1032+ ResultSet.fromJSON = function (json) {
1033+ return new ResultSet(json.entries);
1034+ };
1035+
1036 module.exports = ResultSet;
1037
1038
1039 /***/ },
1040-/* 13 */
1041+/* 14 */
1042 /***/ function(module, exports, __webpack_require__) {
1043
1044 // utility methods for arrays and matrices
1045 'use strict';
1046
1047- var util = __webpack_require__(160),
1048-
1049- IndexError = __webpack_require__(157),
1050- DimensionError = __webpack_require__(156),
1051-
1052- Matrix = __webpack_require__(9),
1053+ var util = __webpack_require__(171),
1054+
1055+ IndexError = __webpack_require__(169),
1056+ DimensionError = __webpack_require__(168),
1057+
1058+ Matrix = __webpack_require__(10),
1059
1060 array = util.array,
1061 isArray = util.array.isArray,
1062@@ -3750,38 +4051,59 @@
1063
1064
1065 /***/ },
1066-/* 14 */
1067-/***/ function(module, exports, __webpack_require__) {
1068-
1069- 'use strict';
1070-
1071- var util = __webpack_require__(160),
1072-
1073- ArgumentsError = __webpack_require__(155),
1074+/* 15 */
1075+/***/ function(module, exports, __webpack_require__) {
1076+
1077+ 'use strict';
1078+
1079+ exports.ArrayNode = __webpack_require__(172);
1080+ exports.AssignmentNode = __webpack_require__(173);
1081+ exports.BlockNode = __webpack_require__(174);
1082+ exports.ConditionalNode = __webpack_require__(175);
1083+ exports.ConstantNode = __webpack_require__(176);
1084+ exports.IndexNode = __webpack_require__(177);
1085+ exports.FunctionAssignmentNode = __webpack_require__(178);
1086+ exports.FunctionNode = __webpack_require__(179);
1087+ exports.Node = __webpack_require__(180);
1088+ exports.OperatorNode = __webpack_require__(181);
1089+ exports.RangeNode = __webpack_require__(182);
1090+ exports.SymbolNode = __webpack_require__(183);
1091+ exports.UpdateNode = __webpack_require__(184);
1092+
1093+
1094+/***/ },
1095+/* 16 */
1096+/***/ function(module, exports, __webpack_require__) {
1097+
1098+ 'use strict';
1099+
1100+ var util = __webpack_require__(171),
1101+
1102+ ArgumentsError = __webpack_require__(167),
1103
1104 isString = util.string.isString,
1105 isArray = Array.isArray,
1106 type = util.types.type,
1107
1108 // types
1109- Complex = __webpack_require__(6),
1110- Matrix = __webpack_require__(9),
1111- Unit = __webpack_require__(10),
1112- collection = __webpack_require__(13),
1113+ Complex = __webpack_require__(7),
1114+ Matrix = __webpack_require__(10),
1115+ Unit = __webpack_require__(11),
1116+ collection = __webpack_require__(14),
1117
1118 // scope and nodes
1119- ArrayNode = __webpack_require__(161),
1120- AssignmentNode = __webpack_require__(162),
1121- BlockNode = __webpack_require__(163),
1122- ConditionalNode = __webpack_require__(164),
1123- ConstantNode = __webpack_require__(165),
1124- FunctionAssignmentNode = __webpack_require__(166),
1125- IndexNode = __webpack_require__(167),
1126- OperatorNode = __webpack_require__(168),
1127- FunctionNode = __webpack_require__(169),
1128- RangeNode = __webpack_require__(170),
1129- SymbolNode = __webpack_require__(171),
1130- UpdateNode = __webpack_require__(172);
1131+ ArrayNode = __webpack_require__(172),
1132+ AssignmentNode = __webpack_require__(173),
1133+ BlockNode = __webpack_require__(174),
1134+ ConditionalNode = __webpack_require__(175),
1135+ ConstantNode = __webpack_require__(176),
1136+ FunctionAssignmentNode = __webpack_require__(178),
1137+ IndexNode = __webpack_require__(177),
1138+ OperatorNode = __webpack_require__(181),
1139+ FunctionNode = __webpack_require__(179),
1140+ RangeNode = __webpack_require__(182),
1141+ SymbolNode = __webpack_require__(183),
1142+ UpdateNode = __webpack_require__(184);
1143
1144 /**
1145 * Parse an expression. Returns a node tree, which can be evaluated by
1146@@ -5136,12 +5458,12 @@
1147
1148
1149 /***/ },
1150-/* 15 */
1151+/* 17 */
1152 /***/ function(module, exports, __webpack_require__) {
1153
1154 'use strict';
1155
1156- var _parse = __webpack_require__(14);
1157+ var _parse = __webpack_require__(16);
1158
1159 /**
1160 * @constructor Parser
1161@@ -5287,207 +5609,237 @@
1162
1163
1164 /***/ },
1165-/* 16 */
1166-/***/ function(module, exports, __webpack_require__) {
1167-
1168- 'use strict';
1169-
1170- exports.ArrayNode = __webpack_require__(161);
1171- exports.AssignmentNode = __webpack_require__(162);
1172- exports.BlockNode = __webpack_require__(163);
1173- exports.ConditionalNode = __webpack_require__(164);
1174- exports.ConstantNode = __webpack_require__(165);
1175- exports.IndexNode = __webpack_require__(167);
1176- exports.FunctionAssignmentNode = __webpack_require__(166);
1177- exports.FunctionNode = __webpack_require__(169);
1178- exports.Node = __webpack_require__(173);
1179- exports.OperatorNode = __webpack_require__(168);
1180- exports.RangeNode = __webpack_require__(170);
1181- exports.SymbolNode = __webpack_require__(171);
1182- exports.UpdateNode = __webpack_require__(172);
1183-
1184-
1185-/***/ },
1186-/* 17 */
1187+/* 18 */
1188 /***/ function(module, exports, __webpack_require__) {
1189
1190 // constants
1191- exports.e = __webpack_require__(177);
1192- exports.E = __webpack_require__(177);
1193- exports['false'] = __webpack_require__(178);
1194- exports.i = __webpack_require__(179);
1195- exports['Infinity'] = __webpack_require__(180);
1196- exports.LN2 = __webpack_require__(181);
1197- exports.LN10 = __webpack_require__(182);
1198- exports.LOG2E = __webpack_require__(183);
1199- exports.LOG10E = __webpack_require__(184);
1200- exports.NaN = __webpack_require__(185);
1201- exports['null'] = __webpack_require__(186);
1202- exports.pi = __webpack_require__(187);
1203- exports.PI = __webpack_require__(187);
1204- exports.phi = __webpack_require__(188);
1205- exports.SQRT1_2 = __webpack_require__(189);
1206- exports.SQRT2 = __webpack_require__(190);
1207- exports.tau = __webpack_require__(191);
1208- exports['true'] = __webpack_require__(192);
1209- exports.version = __webpack_require__(193);
1210+ exports.e = __webpack_require__(185);
1211+ exports.E = __webpack_require__(185);
1212+ exports['false'] = __webpack_require__(186);
1213+ exports.i = __webpack_require__(187);
1214+ exports['Infinity'] = __webpack_require__(188);
1215+ exports.LN2 = __webpack_require__(189);
1216+ exports.LN10 = __webpack_require__(190);
1217+ exports.LOG2E = __webpack_require__(191);
1218+ exports.LOG10E = __webpack_require__(192);
1219+ exports.NaN = __webpack_require__(193);
1220+ exports['null'] = __webpack_require__(194);
1221+ exports.pi = __webpack_require__(195);
1222+ exports.PI = __webpack_require__(195);
1223+ exports.phi = __webpack_require__(196);
1224+ exports.SQRT1_2 = __webpack_require__(197);
1225+ exports.SQRT2 = __webpack_require__(198);
1226+ exports.tau = __webpack_require__(199);
1227+ exports['true'] = __webpack_require__(200);
1228+ exports.version = __webpack_require__(201);
1229
1230 // functions - arithmetic
1231- exports.abs = __webpack_require__(197);
1232- exports.add = __webpack_require__(198);
1233- exports.ceil = __webpack_require__(199);
1234- exports.cube = __webpack_require__(200);
1235- exports.divide = __webpack_require__(201);
1236- exports.dotDivide = __webpack_require__(202);
1237- exports.dotMultiply = __webpack_require__(203);
1238- exports.dotPow = __webpack_require__(204);
1239- exports.exp = __webpack_require__(205);
1240- exports.fix = __webpack_require__(206);
1241- exports.floor = __webpack_require__(207);
1242- exports.gcd = __webpack_require__(208);
1243- exports.lcm = __webpack_require__(209);
1244- exports.log = __webpack_require__(210);
1245- exports.log10 = __webpack_require__(211);
1246- exports.mod = __webpack_require__(212);
1247- exports.multiply = __webpack_require__(213);
1248- exports.norm = __webpack_require__(214);
1249- exports.nthRoot = __webpack_require__(215);
1250- exports.pow = __webpack_require__(216);
1251- exports.round = __webpack_require__(217);
1252- exports.sign = __webpack_require__(218);
1253- exports.sqrt = __webpack_require__(219);
1254- exports.square = __webpack_require__(220);
1255- exports.subtract = __webpack_require__(221);
1256- exports.unaryMinus = __webpack_require__(222);
1257- exports.unaryPlus = __webpack_require__(223);
1258- exports.xgcd = __webpack_require__(224);
1259+ exports.abs = __webpack_require__(206);
1260+ exports.add = __webpack_require__(207);
1261+ exports.ceil = __webpack_require__(208);
1262+ exports.cube = __webpack_require__(209);
1263+ exports.divide = __webpack_require__(210);
1264+ exports.dotDivide = __webpack_require__(211);
1265+ exports.dotMultiply = __webpack_require__(212);
1266+ exports.dotPow = __webpack_require__(213);
1267+ exports.exp = __webpack_require__(214);
1268+ exports.fix = __webpack_require__(215);
1269+ exports.floor = __webpack_require__(216);
1270+ exports.gcd = __webpack_require__(217);
1271+ exports.lcm = __webpack_require__(218);
1272+ exports.log = __webpack_require__(219);
1273+ exports.log10 = __webpack_require__(220);
1274+ exports.mod = __webpack_require__(221);
1275+ exports.multiply = __webpack_require__(222);
1276+ exports.norm = __webpack_require__(223);
1277+ exports.nthRoot = __webpack_require__(224);
1278+ exports.pow = __webpack_require__(225);
1279+ exports.round = __webpack_require__(226);
1280+ exports.sign = __webpack_require__(227);
1281+ exports.sqrt = __webpack_require__(228);
1282+ exports.square = __webpack_require__(229);
1283+ exports.subtract = __webpack_require__(230);
1284+ exports.unaryMinus = __webpack_require__(231);
1285+ exports.unaryPlus = __webpack_require__(232);
1286+ exports.xgcd = __webpack_require__(233);
1287
1288 // functions - bitwise
1289- exports.bitAnd = __webpack_require__(225);
1290- exports.bitNot = __webpack_require__(226);
1291- exports.bitOr = __webpack_require__(227);
1292- exports.bitXor = __webpack_require__(228);
1293- exports.leftShift = __webpack_require__(229);
1294- exports.rightArithShift = __webpack_require__(230);
1295- exports.rightLogShift = __webpack_require__(231);
1296+ exports.bitAnd = __webpack_require__(234);
1297+ exports.bitNot = __webpack_require__(235);
1298+ exports.bitOr = __webpack_require__(236);
1299+ exports.bitXor = __webpack_require__(237);
1300+ exports.leftShift = __webpack_require__(238);
1301+ exports.rightArithShift = __webpack_require__(239);
1302+ exports.rightLogShift = __webpack_require__(240);
1303
1304 // functions - complex
1305- exports.arg = __webpack_require__(232);
1306- exports.conj = __webpack_require__(233);
1307- exports.re = __webpack_require__(234);
1308- exports.im = __webpack_require__(235);
1309+ exports.arg = __webpack_require__(241);
1310+ exports.conj = __webpack_require__(242);
1311+ exports.re = __webpack_require__(243);
1312+ exports.im = __webpack_require__(244);
1313
1314 // functions - construction
1315- exports.bignumber = __webpack_require__(236);
1316- exports['boolean'] = __webpack_require__(237);
1317- exports.complex = __webpack_require__(238);
1318- exports.index = __webpack_require__(239);
1319- exports.matrix = __webpack_require__(240);
1320- exports.number = __webpack_require__(241);
1321- exports.string = __webpack_require__(242);
1322- exports.unit = __webpack_require__(243);
1323+ exports.bignumber = __webpack_require__(245);
1324+ exports['boolean'] = __webpack_require__(246);
1325+ exports.complex = __webpack_require__(247);
1326+ exports.index = __webpack_require__(248);
1327+ exports.matrix = __webpack_require__(249);
1328+ exports.number = __webpack_require__(250);
1329+ exports.string = __webpack_require__(251);
1330+ exports.unit = __webpack_require__(252);
1331
1332 // functions - expression
1333- exports['eval'] = __webpack_require__(244);
1334- exports.help = __webpack_require__(245);
1335+ exports['eval'] = __webpack_require__(253);
1336+ exports.help = __webpack_require__(254);
1337
1338 // functions - logical
1339- exports['and'] = __webpack_require__(246);
1340- exports['not'] = __webpack_require__(247);
1341- exports['or'] = __webpack_require__(248);
1342- exports['xor'] = __webpack_require__(249);
1343+ exports['and'] = __webpack_require__(255);
1344+ exports['not'] = __webpack_require__(256);
1345+ exports['or'] = __webpack_require__(257);
1346+ exports['xor'] = __webpack_require__(258);
1347
1348 // functions - matrix
1349- exports['concat'] = __webpack_require__(250);
1350- exports.cross = __webpack_require__(251);
1351- exports.det = __webpack_require__(252);
1352- exports.diag = __webpack_require__(253);
1353- exports.dot = __webpack_require__(254);
1354- exports.eye = __webpack_require__(255);
1355- exports.flatten = __webpack_require__(256);
1356- exports.inv = __webpack_require__(257);
1357- exports.ones = __webpack_require__(258);
1358- exports.range = __webpack_require__(259);
1359- exports.resize = __webpack_require__(260);
1360- exports.size = __webpack_require__(261);
1361- exports.squeeze = __webpack_require__(262);
1362- exports.subset = __webpack_require__(263);
1363- exports.transpose = __webpack_require__(264);
1364- exports.zeros = __webpack_require__(265);
1365+ exports['concat'] = __webpack_require__(259);
1366+ exports.cross = __webpack_require__(260);
1367+ exports.det = __webpack_require__(261);
1368+ exports.diag = __webpack_require__(262);
1369+ exports.dot = __webpack_require__(263);
1370+ exports.eye = __webpack_require__(264);
1371+ exports.flatten = __webpack_require__(265);
1372+ exports.inv = __webpack_require__(266);
1373+ exports.ones = __webpack_require__(267);
1374+ exports.range = __webpack_require__(268);
1375+ exports.resize = __webpack_require__(269);
1376+ exports.size = __webpack_require__(270);
1377+ exports.squeeze = __webpack_require__(271);
1378+ exports.subset = __webpack_require__(272);
1379+ exports.trace = __webpack_require__(273);
1380+ exports.transpose = __webpack_require__(274);
1381+ exports.zeros = __webpack_require__(275);
1382
1383 // functions - probability
1384- exports.combinations = __webpack_require__(266);
1385+ exports.combinations = __webpack_require__(276);
1386 //exports.distribution = require('./function/probability/distribution');
1387- exports.factorial = __webpack_require__(267);
1388- exports.gamma = __webpack_require__(268);
1389- exports.permutations = __webpack_require__(269);
1390- exports.pickRandom = __webpack_require__(270);
1391- exports.random = __webpack_require__(271);
1392- exports.randomInt = __webpack_require__(272);
1393+ exports.factorial = __webpack_require__(277);
1394+ exports.gamma = __webpack_require__(278);
1395+ exports.permutations = __webpack_require__(279);
1396+ exports.pickRandom = __webpack_require__(280);
1397+ exports.random = __webpack_require__(281);
1398+ exports.randomInt = __webpack_require__(282);
1399
1400 // functions - relational
1401- exports.compare = __webpack_require__(273);
1402- exports.deepEqual = __webpack_require__(274);
1403- exports['equal'] = __webpack_require__(275);
1404- exports.larger = __webpack_require__(276);
1405- exports.largerEq = __webpack_require__(277);
1406- exports.smaller = __webpack_require__(278);
1407- exports.smallerEq = __webpack_require__(279);
1408- exports.unequal = __webpack_require__(280);
1409+ exports.compare = __webpack_require__(283);
1410+ exports.deepEqual = __webpack_require__(284);
1411+ exports['equal'] = __webpack_require__(285);
1412+ exports.larger = __webpack_require__(286);
1413+ exports.largerEq = __webpack_require__(287);
1414+ exports.smaller = __webpack_require__(288);
1415+ exports.smallerEq = __webpack_require__(289);
1416+ exports.unequal = __webpack_require__(290);
1417
1418 // functions - statistics
1419- exports.max = __webpack_require__(281);
1420- exports.mean = __webpack_require__(282);
1421- exports.median = __webpack_require__(283);
1422- exports.min = __webpack_require__(284);
1423- exports.prod = __webpack_require__(285);
1424- exports.std = __webpack_require__(286);
1425- exports.sum = __webpack_require__(287);
1426- exports['var'] = __webpack_require__(288);
1427+ exports.max = __webpack_require__(291);
1428+ exports.mean = __webpack_require__(292);
1429+ exports.median = __webpack_require__(293);
1430+ exports.min = __webpack_require__(294);
1431+ exports.prod = __webpack_require__(295);
1432+ exports.std = __webpack_require__(296);
1433+ exports.sum = __webpack_require__(297);
1434+ exports['var'] = __webpack_require__(298);
1435
1436 // functions - trigonometry
1437- exports.acos = __webpack_require__(289);
1438- exports.asin = __webpack_require__(290);
1439- exports.atan = __webpack_require__(291);
1440- exports.atan2 = __webpack_require__(292);
1441- exports.cos = __webpack_require__(293);
1442- exports.cosh = __webpack_require__(294);
1443- exports.cot = __webpack_require__(295);
1444- exports.coth = __webpack_require__(296);
1445- exports.csc = __webpack_require__(297);
1446- exports.csch = __webpack_require__(298);
1447- exports.sec = __webpack_require__(299);
1448- exports.sech = __webpack_require__(300);
1449- exports.sin = __webpack_require__(301);
1450- exports.sinh = __webpack_require__(302);
1451- exports.tan = __webpack_require__(303);
1452- exports.tanh = __webpack_require__(304);
1453+ exports.acos = __webpack_require__(299);
1454+ exports.acosh = __webpack_require__(300);
1455+ exports.acot = __webpack_require__(301);
1456+ exports.acoth = __webpack_require__(302);
1457+ exports.acsc = __webpack_require__(303);
1458+ exports.acsch = __webpack_require__(304);
1459+ exports.asec = __webpack_require__(305);
1460+ exports.asech = __webpack_require__(306);
1461+ exports.asin = __webpack_require__(307);
1462+ exports.asinh = __webpack_require__(308);
1463+ exports.atan = __webpack_require__(309);
1464+ exports.atanh = __webpack_require__(310);
1465+ exports.atan2 = __webpack_require__(311);
1466+ exports.cos = __webpack_require__(312);
1467+ exports.cosh = __webpack_require__(313);
1468+ exports.cot = __webpack_require__(314);
1469+ exports.coth = __webpack_require__(315);
1470+ exports.csc = __webpack_require__(316);
1471+ exports.csch = __webpack_require__(317);
1472+ exports.sec = __webpack_require__(318);
1473+ exports.sech = __webpack_require__(319);
1474+ exports.sin = __webpack_require__(320);
1475+ exports.sinh = __webpack_require__(321);
1476+ exports.tan = __webpack_require__(322);
1477+ exports.tanh = __webpack_require__(323);
1478
1479 // functions - units
1480- exports.to = __webpack_require__(305);
1481+ exports.to = __webpack_require__(324);
1482
1483 // functions - utils
1484- exports.clone = __webpack_require__(306);
1485- exports.map = __webpack_require__(307);
1486- exports.filter = __webpack_require__(308);
1487- exports.forEach = __webpack_require__(309);
1488- exports.format = __webpack_require__(310);
1489+ exports.clone = __webpack_require__(325);
1490+ exports.map = __webpack_require__(326);
1491+ exports.filter = __webpack_require__(327);
1492+ exports.forEach = __webpack_require__(328);
1493+ exports.format = __webpack_require__(329);
1494 // exports.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects.
1495- exports['import'] = __webpack_require__(311);
1496- exports.sort = __webpack_require__(312);
1497- exports['typeof'] = __webpack_require__(313);
1498-
1499-
1500-/***/ },
1501-/* 18 */
1502-/***/ function(module, exports, __webpack_require__) {
1503-
1504- 'use strict';
1505-
1506- var BigNumber = __webpack_require__(159);
1507- var errorTransform = __webpack_require__(174).transform;
1508- var isNumber = __webpack_require__(4).isNumber;
1509- var argsToArray = __webpack_require__(153).argsToArray;
1510+ exports['import'] = __webpack_require__(330);
1511+ exports.sort = __webpack_require__(331);
1512+ exports['typeof'] = __webpack_require__(332);
1513+
1514+
1515+/***/ },
1516+/* 19 */
1517+/***/ function(module, exports, __webpack_require__) {
1518+
1519+ 'use strict';
1520+
1521+ var BigNumber = __webpack_require__(5);
1522+ var Complex = __webpack_require__(7);
1523+ var Help = __webpack_require__(12);
1524+ var Index = __webpack_require__(9);
1525+ var Matrix = __webpack_require__(10);
1526+ var Range = __webpack_require__(8);
1527+ var ResultSet = __webpack_require__(13);
1528+ var Unit = __webpack_require__(11);
1529+
1530+ /**
1531+ * Instantiate mathjs data types from their JSON representation
1532+ * @param {string} key
1533+ * @param {*} value
1534+ * @returns {*} Returns the revived object
1535+ */
1536+ function reviver(key, value) {
1537+ var type = value && value.mathjs;
1538+
1539+ switch (type) {
1540+ case 'BigNumber': return BigNumber.fromJSON(value);
1541+ case 'Complex': return Complex.fromJSON(value);
1542+ case 'Help': return Help.fromJSON(value);
1543+ case 'Index': return Index.fromJSON(value);
1544+ case 'Matrix': return Matrix.fromJSON(value);
1545+ case 'Range': return Range.fromJSON(value);
1546+ case 'ResultSet': return ResultSet.fromJSON(value);
1547+ case 'Unit': return Unit.fromJSON(value);
1548+ }
1549+
1550+ return value;
1551+ }
1552+
1553+ module.exports = reviver;
1554+
1555+
1556+/***/ },
1557+/* 20 */
1558+/***/ function(module, exports, __webpack_require__) {
1559+
1560+ 'use strict';
1561+
1562+ var BigNumber = __webpack_require__(5);
1563+ var errorTransform = __webpack_require__(203).transform;
1564+ var isNumber = __webpack_require__(3).isNumber;
1565+ var argsToArray = __webpack_require__(165).argsToArray;
1566
1567 /**
1568 * Attach a transform function to math.range
1569@@ -5498,7 +5850,7 @@
1570 * @param {Object} math
1571 */
1572 module.exports = function (math) {
1573- math.concat.transform = function () {
1574+ var transform = function () {
1575 // copy arguments into an array
1576 var args = argsToArray(arguments);
1577
1578@@ -5519,19 +5871,23 @@
1579 throw errorTransform(err);
1580 }
1581 };
1582+
1583+ math.concat.transform = transform;
1584+
1585+ return transform;
1586 };
1587
1588
1589 /***/ },
1590-/* 19 */
1591+/* 21 */
1592 /***/ function(module, exports, __webpack_require__) {
1593
1594 'use strict';
1595
1596- var SymbolNode = __webpack_require__(171);
1597- var isBoolean = __webpack_require__(175).isBoolean;
1598- var argsToArray = __webpack_require__(153).argsToArray;
1599- var ArgumentsError = __webpack_require__(155);
1600+ var SymbolNode = __webpack_require__(183);
1601+ var isBoolean = __webpack_require__(204).isBoolean;
1602+ var argsToArray = __webpack_require__(165).argsToArray;
1603+ var ArgumentsError = __webpack_require__(167);
1604
1605 /**
1606 * Attach a transform function to math.filter
1607@@ -5544,7 +5900,7 @@
1608 module.exports = function (math) {
1609 var _filter = math.filter;
1610
1611- _filter.transform = function (args, math, scope) {
1612+ var transform = function (args, math, scope) {
1613 if (args.length !== 2) {
1614 throw new ArgumentsError('filter', arguments.length, 2);
1615 }
1616@@ -5585,17 +5941,20 @@
1617 return _filter(x, test);
1618 };
1619
1620- math.filter.transform.rawArgs = true;
1621+ transform.rawArgs = true;
1622+ math.filter.transform = transform;
1623+
1624+ return transform;
1625 };
1626
1627
1628 /***/ },
1629-/* 20 */
1630+/* 22 */
1631 /***/ function(module, exports, __webpack_require__) {
1632
1633 'use strict';
1634
1635- var Matrix = __webpack_require__(9);
1636+ var Matrix = __webpack_require__(10);
1637
1638 /**
1639 * Attach a transform function to math.forEach
1640@@ -5605,7 +5964,7 @@
1641 * @param {Object} math
1642 */
1643 module.exports = function (math) {
1644- math.forEach.transform = function (x, callback) {
1645+ var transform = function (x, callback) {
1646 if (arguments.length != 2) {
1647 throw new math.error.ArgumentsError('forEach', arguments.length, 2);
1648 }
1649@@ -5634,20 +5993,23 @@
1650 recurse(array, []);
1651 }
1652
1653+ math.forEach.transform = transform;
1654+
1655+ return transform;
1656 };
1657
1658
1659 /***/ },
1660-/* 21 */
1661+/* 23 */
1662 /***/ function(module, exports, __webpack_require__) {
1663
1664 'use strict';
1665
1666- var BigNumber = __webpack_require__(159);
1667- var Range = __webpack_require__(7);
1668- var Index = __webpack_require__(8);
1669- var Matrix = __webpack_require__(9);
1670- var isNumber = __webpack_require__(4).isNumber;
1671+ var BigNumber = __webpack_require__(5);
1672+ var Range = __webpack_require__(8);
1673+ var Index = __webpack_require__(9);
1674+ var Matrix = __webpack_require__(10);
1675+ var isNumber = __webpack_require__(3).isNumber;
1676 var isArray = Array.isArray;
1677
1678 /**
1679@@ -5658,7 +6020,7 @@
1680 * @param {Object} math
1681 */
1682 module.exports = function (math) {
1683- math.index.transform = function () {
1684+ var transform = function () {
1685 var args = [];
1686 for (var i = 0, ii = arguments.length; i < ii; i++) {
1687 var arg = arguments[i];
1688@@ -5685,20 +6047,24 @@
1689 Index.apply(res, args);
1690 return res;
1691 };
1692+
1693+ math.index.transform = transform;
1694+
1695+ return transform;
1696 };
1697
1698
1699 /***/ },
1700-/* 22 */
1701+/* 24 */
1702 /***/ function(module, exports, __webpack_require__) {
1703
1704 'use strict';
1705
1706- var Matrix = __webpack_require__(9);
1707- var BigNumber = __webpack_require__(159);
1708- var Range = __webpack_require__(7);
1709- var Index = __webpack_require__(8);
1710- var isNumber = __webpack_require__(4).isNumber;
1711+ var Matrix = __webpack_require__(10);
1712+ var BigNumber = __webpack_require__(5);
1713+ var Range = __webpack_require__(8);
1714+ var Index = __webpack_require__(9);
1715+ var isNumber = __webpack_require__(3).isNumber;
1716 var isArray = Array.isArray;
1717
1718 /**
1719@@ -5709,7 +6075,7 @@
1720 * @param {Object} math
1721 */
1722 module.exports = function (math) {
1723- math.map.transform = function (x, callback) {
1724+ var transform = function (x, callback) {
1725 if (arguments.length != 2) {
1726 throw new math.error.ArgumentsError('map', arguments.length, 2);
1727 }
1728@@ -5738,20 +6104,24 @@
1729
1730 return recurse(arrayIn, []);
1731 }
1732+
1733+ math.map.transform = transform;
1734+
1735+ return transform;
1736 };
1737
1738
1739 /***/ },
1740-/* 23 */
1741+/* 25 */
1742 /***/ function(module, exports, __webpack_require__) {
1743
1744 'use strict';
1745
1746- var BigNumber = __webpack_require__(159);
1747- var errorTransform = __webpack_require__(174).transform;
1748- var isNumber = __webpack_require__(4).isNumber;
1749- var isCollection = __webpack_require__(13).isCollection;
1750- var argsToArray = __webpack_require__(153).argsToArray;
1751+ var BigNumber = __webpack_require__(5);
1752+ var errorTransform = __webpack_require__(203).transform;
1753+ var isNumber = __webpack_require__(3).isNumber;
1754+ var isCollection = __webpack_require__(14).isCollection;
1755+ var argsToArray = __webpack_require__(165).argsToArray;
1756
1757 /**
1758 * Attach a transform function to math.max
1759@@ -5762,7 +6132,7 @@
1760 * @param {Object} math
1761 */
1762 module.exports = function (math) {
1763- math.max.transform = function () {
1764+ var transform = function () {
1765 var args = argsToArray(arguments);
1766
1767 // change last argument dim from one-based to zero-based
1768@@ -5783,20 +6153,24 @@
1769 throw errorTransform(err);
1770 }
1771 };
1772+
1773+ math.max.transform = transform;
1774+
1775+ return transform;
1776 };
1777
1778
1779 /***/ },
1780-/* 24 */
1781+/* 26 */
1782 /***/ function(module, exports, __webpack_require__) {
1783
1784 'use strict';
1785
1786- var BigNumber = __webpack_require__(159);
1787- var errorTransform = __webpack_require__(174).transform;
1788- var isNumber = __webpack_require__(4).isNumber;
1789- var isCollection = __webpack_require__(13).isCollection;
1790- var argsToArray = __webpack_require__(153).argsToArray;
1791+ var BigNumber = __webpack_require__(5);
1792+ var errorTransform = __webpack_require__(203).transform;
1793+ var isNumber = __webpack_require__(3).isNumber;
1794+ var isCollection = __webpack_require__(14).isCollection;
1795+ var argsToArray = __webpack_require__(165).argsToArray;
1796
1797 /**
1798 * Attach a transform function to math.mean
1799@@ -5807,7 +6181,7 @@
1800 * @param {Object} math
1801 */
1802 module.exports = function (math) {
1803- math.mean.transform = function () {
1804+ var transform = function () {
1805 var args = argsToArray(arguments);
1806
1807 // change last argument dim from one-based to zero-based
1808@@ -5828,20 +6202,24 @@
1809 throw errorTransform(err);
1810 }
1811 };
1812+
1813+ math.mean.transform = transform;
1814+
1815+ return transform;
1816 };
1817
1818
1819 /***/ },
1820-/* 25 */
1821+/* 27 */
1822 /***/ function(module, exports, __webpack_require__) {
1823
1824 'use strict';
1825
1826- var BigNumber = __webpack_require__(159);
1827- var errorTransform = __webpack_require__(174).transform;
1828- var isNumber = __webpack_require__(4).isNumber;
1829- var isCollection = __webpack_require__(13).isCollection;
1830- var argsToArray = __webpack_require__(153).argsToArray;
1831+ var BigNumber = __webpack_require__(5);
1832+ var errorTransform = __webpack_require__(203).transform;
1833+ var isNumber = __webpack_require__(3).isNumber;
1834+ var isCollection = __webpack_require__(14).isCollection;
1835+ var argsToArray = __webpack_require__(165).argsToArray;
1836
1837 /**
1838 * Attach a transform function to math.min
1839@@ -5852,7 +6230,7 @@
1840 * @param {Object} math
1841 */
1842 module.exports = function (math) {
1843- math.min.transform = function () {
1844+ var transform = function () {
1845 var args = argsToArray(arguments);
1846
1847 // change last argument dim from one-based to zero-based
1848@@ -5873,17 +6251,21 @@
1849 throw errorTransform(err);
1850 }
1851 };
1852+
1853+ math.min.transform = transform;
1854+
1855+ return transform;
1856 };
1857
1858
1859 /***/ },
1860-/* 26 */
1861+/* 28 */
1862 /***/ function(module, exports, __webpack_require__) {
1863
1864 'use strict';
1865
1866- var isBoolean = __webpack_require__(175).isBoolean;
1867- var argsToArray = __webpack_require__(153).argsToArray;
1868+ var isBoolean = __webpack_require__(204).isBoolean;
1869+ var argsToArray = __webpack_require__(165).argsToArray;
1870
1871 /**
1872 * Attach a transform function to math.range
1873@@ -5893,7 +6275,7 @@
1874 * @param {Object} math
1875 */
1876 module.exports = function (math) {
1877- math.range.transform = function () {
1878+ var transform = function () {
1879 var args = argsToArray(arguments);
1880
1881 var lastIndex = args.length - 1;
1882@@ -5904,18 +6286,22 @@
1883
1884 return math.range.apply(math, args);
1885 };
1886+
1887+ math.range.transform = transform;
1888+
1889+ return transform;
1890 };
1891
1892
1893 /***/ },
1894-/* 27 */
1895+/* 29 */
1896 /***/ function(module, exports, __webpack_require__) {
1897
1898 'use strict';
1899
1900- var errorTransform = __webpack_require__(174).transform;
1901- var isBoolean = __webpack_require__(175).isBoolean;
1902- var argsToArray = __webpack_require__(153).argsToArray;
1903+ var errorTransform = __webpack_require__(203).transform;
1904+ var isBoolean = __webpack_require__(204).isBoolean;
1905+ var argsToArray = __webpack_require__(165).argsToArray;
1906
1907 /**
1908 * Attach a transform function to math.subset
1909@@ -5925,7 +6311,7 @@
1910 * @param {Object} math
1911 */
1912 module.exports = function (math) {
1913- math.subset.transform = function () {
1914+ var transform = function () {
1915 try {
1916 return math.subset.apply(math, argsToArray(arguments));
1917 }
1918@@ -5933,17 +6319,21 @@
1919 throw errorTransform(err);
1920 }
1921 };
1922+
1923+ math.subset.transform = transform;
1924+
1925+ return transform;
1926 };
1927
1928
1929 /***/ },
1930-/* 28 */
1931+/* 30 */
1932 /***/ function(module, exports, __webpack_require__) {
1933
1934 'use strict';
1935
1936 module.exports = function (math) {
1937- var string = __webpack_require__(176);
1938+ var string = __webpack_require__(205);
1939
1940 /**
1941 * @constructor Chain
1942@@ -6038,16 +6428,16 @@
1943
1944
1945 /***/ },
1946-/* 29 */
1947+/* 31 */
1948 /***/ function(module, exports, __webpack_require__) {
1949
1950 'use strict';
1951
1952 module.exports = function (math, config) {
1953- var util = __webpack_require__(160),
1954- _parse = __webpack_require__(14),
1955+ var util = __webpack_require__(171),
1956+ _parse = __webpack_require__(16),
1957
1958- collection = __webpack_require__(13),
1959+ collection = __webpack_require__(14),
1960
1961 isString = util.string.isString,
1962 isCollection = collection.isCollection;
1963@@ -6110,16 +6500,16 @@
1964
1965
1966 /***/ },
1967-/* 30 */
1968+/* 32 */
1969 /***/ function(module, exports, __webpack_require__) {
1970
1971 'use strict';
1972
1973 module.exports = function (math) {
1974- var util = __webpack_require__(160),
1975- _parse = __webpack_require__(14),
1976+ var util = __webpack_require__(171),
1977+ _parse = __webpack_require__(16),
1978
1979- collection = __webpack_require__(13),
1980+ collection = __webpack_require__(14),
1981
1982 isString = util.string.isString,
1983 isCollection = collection.isCollection;
1984@@ -6183,13 +6573,13 @@
1985
1986
1987 /***/ },
1988-/* 31 */
1989+/* 33 */
1990 /***/ function(module, exports, __webpack_require__) {
1991
1992 'use strict';
1993
1994 module.exports = function (math) {
1995- var Help = __webpack_require__(11);
1996+ var Help = __webpack_require__(12);
1997
1998 /**
1999 * Retrieve help on a function or data type.
2000@@ -6250,19 +6640,19 @@
2001 } else if (!doc) {
2002 throw new Error('No documentation found on "' + text + '"');
2003 }
2004- return new Help(math, doc);
2005+ return new Help(doc);
2006 };
2007 };
2008
2009
2010 /***/ },
2011-/* 32 */
2012+/* 34 */
2013 /***/ function(module, exports, __webpack_require__) {
2014
2015 'use strict';
2016
2017 module.exports = function (math, config) {
2018- var _parse = __webpack_require__(14);
2019+ var _parse = __webpack_require__(16);
2020
2021 /**
2022 * Parse an expression. Returns a node tree, which can be evaluated by
2023@@ -6304,18 +6694,18 @@
2024
2025
2026 /***/ },
2027-/* 33 */
2028+/* 35 */
2029 /***/ function(module, exports, __webpack_require__) {
2030
2031 'use strict';
2032
2033 module.exports = function (math) {
2034- var util = __webpack_require__(160),
2035+ var util = __webpack_require__(171),
2036
2037 BigNumber = math.type.BigNumber,
2038- Complex = __webpack_require__(6),
2039- Matrix = __webpack_require__(9),
2040- collection = __webpack_require__(13),
2041+ Complex = __webpack_require__(7),
2042+ Matrix = __webpack_require__(10),
2043+ collection = __webpack_require__(14),
2044
2045 isNumber = util.number.isNumber,
2046 isBoolean = util['boolean'].isBoolean,
2047@@ -6356,7 +6746,15 @@
2048 }
2049
2050 if (isComplex(x)) {
2051- return Math.sqrt(x.re * x.re + x.im * x.im);
2052+ // do not compute sqrt(re * re + im * im) since it will overflow with big numbers!
2053+ var re = Math.abs(x.re);
2054+ var im = Math.abs(x.im);
2055+ if (re >= im) {
2056+ var x = im / re;
2057+ return re * Math.sqrt(1 + x * x);
2058+ }
2059+ var y = re / im;
2060+ return im * Math.sqrt(1 + y * y);
2061 }
2062
2063 if (x instanceof BigNumber) {
2064@@ -6377,19 +6775,19 @@
2065
2066
2067 /***/ },
2068-/* 34 */
2069+/* 36 */
2070 /***/ function(module, exports, __webpack_require__) {
2071
2072 'use strict';
2073
2074 module.exports = function (math) {
2075- var util = __webpack_require__(160),
2076+ var util = __webpack_require__(171),
2077
2078 BigNumber = math.type.BigNumber,
2079- Complex = __webpack_require__(6),
2080- Matrix = __webpack_require__(9),
2081- Unit = __webpack_require__(10),
2082- collection = __webpack_require__(13),
2083+ Complex = __webpack_require__(7),
2084+ Matrix = __webpack_require__(10),
2085+ Unit = __webpack_require__(11),
2086+ collection = __webpack_require__(14),
2087
2088 isBoolean = util['boolean'].isBoolean,
2089 isNumber = util.number.isNumber,
2090@@ -6539,17 +6937,17 @@
2091
2092
2093 /***/ },
2094-/* 35 */
2095+/* 37 */
2096 /***/ function(module, exports, __webpack_require__) {
2097
2098 'use strict';
2099
2100 module.exports = function (math) {
2101- var util = __webpack_require__(160),
2102+ var util = __webpack_require__(171),
2103
2104 BigNumber = math.type.BigNumber,
2105- Complex = __webpack_require__(6),
2106- collection = __webpack_require__(13),
2107+ Complex = __webpack_require__(7),
2108+ collection = __webpack_require__(14),
2109
2110 isNumber = util.number.isNumber,
2111 isBoolean = util['boolean'].isBoolean,
2112@@ -6618,17 +7016,17 @@
2113
2114
2115 /***/ },
2116-/* 36 */
2117+/* 38 */
2118 /***/ function(module, exports, __webpack_require__) {
2119
2120 'use strict';
2121
2122 module.exports = function (math) {
2123- var util = __webpack_require__(160),
2124+ var util = __webpack_require__(171),
2125
2126 BigNumber = math.type.BigNumber,
2127- Complex = __webpack_require__(6),
2128- collection = __webpack_require__(13),
2129+ Complex = __webpack_require__(7),
2130+ collection = __webpack_require__(14),
2131
2132 isNumber = util.number.isNumber,
2133 isBoolean = util['boolean'].isBoolean,
2134@@ -6690,18 +7088,18 @@
2135
2136
2137 /***/ },
2138-/* 37 */
2139+/* 39 */
2140 /***/ function(module, exports, __webpack_require__) {
2141
2142 'use strict';
2143
2144 module.exports = function(math) {
2145- var util = __webpack_require__(160);
2146+ var util = __webpack_require__(171);
2147
2148 var BigNumber = math.type.BigNumber;
2149- var Complex = __webpack_require__(6);
2150- var Matrix = __webpack_require__(9);
2151- var Unit = __webpack_require__(10);
2152+ var Complex = __webpack_require__(7);
2153+ var Matrix = __webpack_require__(10);
2154+ var Unit = __webpack_require__(11);
2155
2156 var isNumber = util.number.isNumber;
2157 var isBoolean = util['boolean'].isBoolean;
2158@@ -6823,13 +7221,13 @@
2159
2160
2161 /***/ },
2162-/* 38 */
2163+/* 40 */
2164 /***/ function(module, exports, __webpack_require__) {
2165
2166 'use strict';
2167
2168 module.exports = function(math) {
2169- var collection = __webpack_require__(13);
2170+ var collection = __webpack_require__(14);
2171 var isCollection = collection.isCollection;
2172
2173 /**
2174@@ -6894,13 +7292,13 @@
2175
2176
2177 /***/ },
2178-/* 39 */
2179+/* 41 */
2180 /***/ function(module, exports, __webpack_require__) {
2181
2182 'use strict';
2183
2184 module.exports = function (math) {
2185- var collection = __webpack_require__(13);
2186+ var collection = __webpack_require__(14);
2187
2188 /**
2189 * Divide two matrices element wise. The function accepts both matrices and
2190@@ -6944,14 +7342,14 @@
2191
2192
2193 /***/ },
2194-/* 40 */
2195+/* 42 */
2196 /***/ function(module, exports, __webpack_require__) {
2197
2198 'use strict';
2199
2200 module.exports = function (math) {
2201- var util = __webpack_require__(160),
2202- collection = __webpack_require__(13);
2203+ var util = __webpack_require__(171),
2204+ collection = __webpack_require__(14);
2205
2206 /**
2207 * Multiply two matrices element wise. The function accepts both matrices and
2208@@ -6995,14 +7393,14 @@
2209
2210
2211 /***/ },
2212-/* 41 */
2213+/* 43 */
2214 /***/ function(module, exports, __webpack_require__) {
2215
2216 'use strict';
2217
2218 module.exports = function (math) {
2219- var util = __webpack_require__(160),
2220- collection = __webpack_require__(13);
2221+ var util = __webpack_require__(171),
2222+ collection = __webpack_require__(14);
2223
2224 /**
2225 * Calculates the power of x to y element wise.
2226@@ -7043,18 +7441,18 @@
2227
2228
2229 /***/ },
2230-/* 42 */
2231+/* 44 */
2232 /***/ function(module, exports, __webpack_require__) {
2233
2234 'use strict';
2235
2236 module.exports = function (math) {
2237- var util = __webpack_require__(160),
2238+ var util = __webpack_require__(171),
2239
2240 BigNumber = math.type.BigNumber,
2241- Complex = __webpack_require__(6),
2242- Matrix = __webpack_require__(9),
2243- collection = __webpack_require__(13),
2244+ Complex = __webpack_require__(7),
2245+ Matrix = __webpack_require__(10),
2246+ collection = __webpack_require__(14),
2247
2248 isNumber = util.number.isNumber,
2249 isBoolean = util['boolean'].isBoolean,
2250@@ -7124,17 +7522,17 @@
2251
2252
2253 /***/ },
2254-/* 43 */
2255+/* 45 */
2256 /***/ function(module, exports, __webpack_require__) {
2257
2258 'use strict';
2259
2260 module.exports = function (math) {
2261- var util = __webpack_require__(160),
2262+ var util = __webpack_require__(171),
2263
2264 BigNumber = math.type.BigNumber,
2265- Complex = __webpack_require__(6),
2266- collection = __webpack_require__(13),
2267+ Complex = __webpack_require__(7),
2268+ collection = __webpack_require__(14),
2269
2270 isNumber = util.number.isNumber,
2271 isBoolean = util['boolean'].isBoolean,
2272@@ -7202,17 +7600,17 @@
2273
2274
2275 /***/ },
2276-/* 44 */
2277+/* 46 */
2278 /***/ function(module, exports, __webpack_require__) {
2279
2280 'use strict';
2281
2282 module.exports = function (math) {
2283- var util = __webpack_require__(160),
2284+ var util = __webpack_require__(171),
2285
2286 BigNumber = math.type.BigNumber,
2287- Complex = __webpack_require__(6),
2288- collection = __webpack_require__(13),
2289+ Complex = __webpack_require__(7),
2290+ collection = __webpack_require__(14),
2291
2292 isNumber = util.number.isNumber,
2293 isBoolean = util['boolean'].isBoolean,
2294@@ -7280,16 +7678,16 @@
2295
2296
2297 /***/ },
2298-/* 45 */
2299+/* 47 */
2300 /***/ function(module, exports, __webpack_require__) {
2301
2302 'use strict';
2303
2304 module.exports = function (math) {
2305- var util = __webpack_require__(160),
2306+ var util = __webpack_require__(171),
2307
2308 BigNumber = math.type.BigNumber,
2309- collection = __webpack_require__(13),
2310+ collection = __webpack_require__(14),
2311
2312 isNumber = util.number.isNumber,
2313 isBoolean = util['boolean'].isBoolean,
2314@@ -7427,16 +7825,16 @@
2315
2316
2317 /***/ },
2318-/* 46 */
2319+/* 48 */
2320 /***/ function(module, exports, __webpack_require__) {
2321
2322 'use strict';
2323
2324 module.exports = function (math) {
2325- var util = __webpack_require__(160),
2326+ var util = __webpack_require__(171),
2327
2328 BigNumber = math.type.BigNumber,
2329- collection = __webpack_require__(13),
2330+ collection = __webpack_require__(14),
2331
2332 isNumber = util.number.isNumber,
2333 isBoolean = util['boolean'].isBoolean,
2334@@ -7589,17 +7987,17 @@
2335
2336
2337 /***/ },
2338-/* 47 */
2339+/* 49 */
2340 /***/ function(module, exports, __webpack_require__) {
2341
2342 'use strict';
2343
2344 module.exports = function (math) {
2345- var util = __webpack_require__(160),
2346+ var util = __webpack_require__(171),
2347
2348 BigNumber = math.type.BigNumber,
2349- Complex = __webpack_require__(6),
2350- collection = __webpack_require__(13),
2351+ Complex = __webpack_require__(7),
2352+ collection = __webpack_require__(14),
2353
2354 isNumber = util.number.isNumber,
2355 isBoolean = util['boolean'].isBoolean,
2356@@ -7692,17 +8090,17 @@
2357
2358
2359 /***/ },
2360-/* 48 */
2361+/* 50 */
2362 /***/ function(module, exports, __webpack_require__) {
2363
2364 'use strict';
2365
2366 module.exports = function (math) {
2367- var util = __webpack_require__(160),
2368+ var util = __webpack_require__(171),
2369
2370 BigNumber = math.type.BigNumber,
2371- Complex = __webpack_require__(6),
2372- collection = __webpack_require__(13),
2373+ Complex = __webpack_require__(7),
2374+ collection = __webpack_require__(14),
2375
2376 isNumber = util.number.isNumber,
2377 isBoolean = util['boolean'].isBoolean,
2378@@ -7780,16 +8178,16 @@
2379
2380
2381 /***/ },
2382-/* 49 */
2383+/* 51 */
2384 /***/ function(module, exports, __webpack_require__) {
2385
2386 'use strict';
2387
2388 module.exports = function (math) {
2389- var util = __webpack_require__(160),
2390+ var util = __webpack_require__(171),
2391
2392 BigNumber = math.type.BigNumber,
2393- collection = __webpack_require__(13),
2394+ collection = __webpack_require__(14),
2395
2396 isNumber = util.number.isNumber,
2397 isBoolean = util['boolean'].isBoolean,
2398@@ -7919,19 +8317,19 @@
2399
2400
2401 /***/ },
2402-/* 50 */
2403+/* 52 */
2404 /***/ function(module, exports, __webpack_require__) {
2405
2406 'use strict';
2407
2408 module.exports = function(math) {
2409- var util = __webpack_require__(160),
2410+ var util = __webpack_require__(171),
2411
2412 BigNumber = math.type.BigNumber,
2413- Complex = __webpack_require__(6),
2414- Matrix = __webpack_require__(9),
2415- Unit = __webpack_require__(10),
2416- collection = __webpack_require__(13),
2417+ Complex = __webpack_require__(7),
2418+ Matrix = __webpack_require__(10),
2419+ Unit = __webpack_require__(11),
2420+ collection = __webpack_require__(14),
2421
2422 array = util.array,
2423 isNumber = util.number.isNumber,
2424@@ -8350,20 +8748,20 @@
2425
2426
2427 /***/ },
2428-/* 51 */
2429+/* 53 */
2430 /***/ function(module, exports, __webpack_require__) {
2431
2432 'use strict';
2433
2434 module.exports = function (math) {
2435- var util = __webpack_require__(160),
2436+ var util = __webpack_require__(171),
2437
2438- array = __webpack_require__(153),
2439+ array = __webpack_require__(165),
2440
2441 BigNumber = math.type.BigNumber,
2442- Complex = __webpack_require__(6),
2443- Matrix = __webpack_require__(9),
2444- collection = __webpack_require__(13),
2445+ Complex = __webpack_require__(7),
2446+ Matrix = __webpack_require__(10),
2447+ collection = __webpack_require__(14),
2448
2449 isNumber = util.number.isNumber,
2450 isBoolean = util['boolean'].isBoolean,
2451@@ -8419,8 +8817,15 @@
2452 }
2453
2454 if (isComplex(x)) {
2455- // ignore p, complex numbers
2456- return Math.sqrt(x.re * x.re + x.im * x.im);
2457+ // do not compute sqrt(re * re + im * im) since it will overflow with big numbers!
2458+ var re = Math.abs(x.re);
2459+ var im = Math.abs(x.im);
2460+ if (re >= im) {
2461+ var x = im / re;
2462+ return re * Math.sqrt(1 + x * x);
2463+ }
2464+ var y = re / im;
2465+ return im * Math.sqrt(1 + y * y);
2466 }
2467
2468 if (x instanceof BigNumber) {
2469@@ -8538,16 +8943,16 @@
2470
2471
2472 /***/ },
2473-/* 52 */
2474+/* 54 */
2475 /***/ function(module, exports, __webpack_require__) {
2476
2477 'use strict';
2478
2479 module.exports = function (math) {
2480- var util = __webpack_require__(160);
2481+ var util = __webpack_require__(171);
2482
2483 var BigNumber = math.type.BigNumber;
2484- var collection = __webpack_require__(13);
2485+ var collection = __webpack_require__(14);
2486
2487 var isNumber = util.number.isNumber;
2488 var isBoolean = util['boolean'].isBoolean;
2489@@ -8737,18 +9142,18 @@
2490
2491
2492 /***/ },
2493-/* 53 */
2494+/* 55 */
2495 /***/ function(module, exports, __webpack_require__) {
2496
2497 'use strict';
2498
2499 module.exports = function (math) {
2500- var util = __webpack_require__(160),
2501+ var util = __webpack_require__(171),
2502
2503 BigNumber = math.type.BigNumber,
2504- Complex = __webpack_require__(6),
2505- Matrix = __webpack_require__(9),
2506- collection = __webpack_require__(13),
2507+ Complex = __webpack_require__(7),
2508+ Matrix = __webpack_require__(10),
2509+ collection = __webpack_require__(14),
2510
2511 array = util.array,
2512 isNumber = util.number.isNumber,
2513@@ -8921,17 +9326,17 @@
2514
2515
2516 /***/ },
2517-/* 54 */
2518+/* 56 */
2519 /***/ function(module, exports, __webpack_require__) {
2520
2521 'use strict';
2522
2523 module.exports = function (math) {
2524- var util = __webpack_require__(160),
2525+ var util = __webpack_require__(171),
2526
2527 BigNumber = math.type.BigNumber,
2528- Complex = __webpack_require__(6),
2529- collection = __webpack_require__(13),
2530+ Complex = __webpack_require__(7),
2531+ collection = __webpack_require__(14),
2532
2533 isNumber = util.number.isNumber,
2534 isInteger = util.number.isInteger,
2535@@ -9061,17 +9466,17 @@
2536
2537
2538 /***/ },
2539-/* 55 */
2540+/* 57 */
2541 /***/ function(module, exports, __webpack_require__) {
2542
2543 'use strict';
2544
2545 module.exports = function (math) {
2546- var util = __webpack_require__(160),
2547+ var util = __webpack_require__(171),
2548
2549 BigNumber = math.type.BigNumber,
2550- Complex = __webpack_require__(6),
2551- collection = __webpack_require__(13),
2552+ Complex = __webpack_require__(7),
2553+ collection = __webpack_require__(14),
2554
2555 number = util.number,
2556 isNumber = util.number.isNumber,
2557@@ -9141,17 +9546,17 @@
2558
2559
2560 /***/ },
2561-/* 56 */
2562+/* 58 */
2563 /***/ function(module, exports, __webpack_require__) {
2564
2565 'use strict';
2566
2567 module.exports = function (math) {
2568- var util = __webpack_require__(160),
2569+ var util = __webpack_require__(171),
2570
2571 BigNumber = math.type.BigNumber,
2572- Complex = __webpack_require__(6),
2573- collection = __webpack_require__(13),
2574+ Complex = __webpack_require__(7),
2575+ collection = __webpack_require__(14),
2576
2577 isNumber = util.number.isNumber,
2578 isBoolean = util['boolean'].isBoolean,
2579@@ -9247,17 +9652,17 @@
2580
2581
2582 /***/ },
2583-/* 57 */
2584+/* 59 */
2585 /***/ function(module, exports, __webpack_require__) {
2586
2587 'use strict';
2588
2589 module.exports = function (math) {
2590- var util = __webpack_require__(160),
2591+ var util = __webpack_require__(171),
2592
2593 BigNumber = math.type.BigNumber,
2594- Complex = __webpack_require__(6),
2595- collection = __webpack_require__(13),
2596+ Complex = __webpack_require__(7),
2597+ collection = __webpack_require__(14),
2598
2599 isNumber = util.number.isNumber,
2600 isBoolean = util['boolean'].isBoolean,
2601@@ -9321,19 +9726,19 @@
2602
2603
2604 /***/ },
2605-/* 58 */
2606+/* 60 */
2607 /***/ function(module, exports, __webpack_require__) {
2608
2609 'use strict';
2610
2611 module.exports = function (math) {
2612- var util = __webpack_require__(160),
2613+ var util = __webpack_require__(171),
2614
2615 BigNumber = math.type.BigNumber,
2616- Complex = __webpack_require__(6),
2617- Matrix = __webpack_require__(9),
2618- Unit = __webpack_require__(10),
2619- collection = __webpack_require__(13),
2620+ Complex = __webpack_require__(7),
2621+ Matrix = __webpack_require__(10),
2622+ Unit = __webpack_require__(11),
2623+ collection = __webpack_require__(14),
2624
2625 isBoolean = util['boolean'].isBoolean,
2626 isNumber = util.number.isNumber,
2627@@ -9481,18 +9886,18 @@
2628
2629
2630 /***/ },
2631-/* 59 */
2632+/* 61 */
2633 /***/ function(module, exports, __webpack_require__) {
2634
2635 'use strict';
2636
2637 module.exports = function (math, config) {
2638- var util = __webpack_require__(160),
2639+ var util = __webpack_require__(171),
2640
2641 BigNumber = math.type.BigNumber,
2642- Complex = __webpack_require__(6),
2643- Unit = __webpack_require__(10),
2644- collection = __webpack_require__(13),
2645+ Complex = __webpack_require__(7),
2646+ Unit = __webpack_require__(11),
2647+ collection = __webpack_require__(14),
2648
2649 isNumber = util.number.isNumber,
2650 isBoolean = util['boolean'].isBoolean,
2651@@ -9570,18 +9975,18 @@
2652
2653
2654 /***/ },
2655-/* 60 */
2656+/* 62 */
2657 /***/ function(module, exports, __webpack_require__) {
2658
2659 'use strict';
2660
2661 module.exports = function (math, config) {
2662- var util = __webpack_require__(160),
2663+ var util = __webpack_require__(171),
2664
2665 BigNumber = math.type.BigNumber,
2666- Complex = __webpack_require__(6),
2667- Unit = __webpack_require__(10),
2668- collection = __webpack_require__(13),
2669+ Complex = __webpack_require__(7),
2670+ Unit = __webpack_require__(11),
2671+ collection = __webpack_require__(14),
2672
2673 isNumber = util.number.isNumber,
2674 isBoolean = util['boolean'].isBoolean,
2675@@ -9650,15 +10055,15 @@
2676
2677
2678 /***/ },
2679-/* 61 */
2680+/* 63 */
2681 /***/ function(module, exports, __webpack_require__) {
2682
2683 'use strict';
2684
2685 module.exports = function (math, config) {
2686- var util = __webpack_require__(160),
2687+ var util = __webpack_require__(171),
2688
2689- Matrix = __webpack_require__(9),
2690+ Matrix = __webpack_require__(10),
2691 BigNumber = math.type.BigNumber,
2692
2693 isNumber = util.number.isNumber,
2694@@ -9832,18 +10237,18 @@
2695
2696
2697 /***/ },
2698-/* 62 */
2699+/* 64 */
2700 /***/ function(module, exports, __webpack_require__) {
2701
2702 'use strict';
2703
2704 module.exports = function (math, config) {
2705- var util = __webpack_require__(160),
2706+ var util = __webpack_require__(171),
2707
2708 BigNumber = math.type.BigNumber,
2709- Matrix = __webpack_require__(9),
2710- Unit = __webpack_require__(10),
2711- collection = __webpack_require__(13),
2712+ Matrix = __webpack_require__(10),
2713+ Unit = __webpack_require__(11),
2714+ collection = __webpack_require__(14),
2715
2716 isBoolean = util['boolean'].isBoolean,
2717 isInteger = util.number.isInteger,
2718@@ -9931,18 +10336,18 @@
2719
2720
2721 /***/ },
2722-/* 63 */
2723+/* 65 */
2724 /***/ function(module, exports, __webpack_require__) {
2725
2726 'use strict';
2727
2728 module.exports = function (math, config) {
2729- var util = __webpack_require__(160),
2730+ var util = __webpack_require__(171),
2731
2732 BigNumber = math.type.BigNumber,
2733- Matrix = __webpack_require__(9),
2734- Unit = __webpack_require__(10),
2735- collection = __webpack_require__(13),
2736+ Matrix = __webpack_require__(10),
2737+ Unit = __webpack_require__(11),
2738+ collection = __webpack_require__(14),
2739
2740 isBoolean = util['boolean'].isBoolean,
2741 isInteger = util.number.isInteger,
2742@@ -10004,18 +10409,18 @@
2743
2744
2745 /***/ },
2746-/* 64 */
2747+/* 66 */
2748 /***/ function(module, exports, __webpack_require__) {
2749
2750 'use strict';
2751
2752 module.exports = function (math, config) {
2753- var util = __webpack_require__(160),
2754+ var util = __webpack_require__(171),
2755
2756 BigNumber = math.type.BigNumber,
2757- Matrix = __webpack_require__(9),
2758- Unit = __webpack_require__(10),
2759- collection = __webpack_require__(13),
2760+ Matrix = __webpack_require__(10),
2761+ Unit = __webpack_require__(11),
2762+ collection = __webpack_require__(14),
2763
2764 isBoolean = util['boolean'].isBoolean,
2765 isInteger = util.number.isInteger,
2766@@ -10104,18 +10509,18 @@
2767
2768
2769 /***/ },
2770-/* 65 */
2771+/* 67 */
2772 /***/ function(module, exports, __webpack_require__) {
2773
2774 'use strict';
2775
2776 module.exports = function (math, config) {
2777- var util = __webpack_require__(160),
2778+ var util = __webpack_require__(171),
2779
2780 BigNumber = math.type.BigNumber,
2781- Matrix = __webpack_require__(9),
2782- Unit = __webpack_require__(10),
2783- collection = __webpack_require__(13),
2784+ Matrix = __webpack_require__(10),
2785+ Unit = __webpack_require__(11),
2786+ collection = __webpack_require__(14),
2787
2788 isBoolean = util['boolean'].isBoolean,
2789 isInteger = util.number.isInteger,
2790@@ -10203,18 +10608,18 @@
2791
2792
2793 /***/ },
2794-/* 66 */
2795+/* 68 */
2796 /***/ function(module, exports, __webpack_require__) {
2797
2798 'use strict';
2799
2800 module.exports = function (math, config) {
2801- var util = __webpack_require__(160),
2802+ var util = __webpack_require__(171),
2803
2804 BigNumber = math.type.BigNumber,
2805- Matrix = __webpack_require__(9),
2806- Unit = __webpack_require__(10),
2807- collection = __webpack_require__(13),
2808+ Matrix = __webpack_require__(10),
2809+ Unit = __webpack_require__(11),
2810+ collection = __webpack_require__(14),
2811
2812 isBoolean = util['boolean'].isBoolean,
2813 isInteger = util.number.isInteger,
2814@@ -10325,18 +10730,18 @@
2815
2816
2817 /***/ },
2818-/* 67 */
2819+/* 69 */
2820 /***/ function(module, exports, __webpack_require__) {
2821
2822 'use strict';
2823
2824 module.exports = function (math, config) {
2825- var util = __webpack_require__(160),
2826+ var util = __webpack_require__(171),
2827
2828 BigNumber = math.type.BigNumber,
2829- Matrix = __webpack_require__(9),
2830- Unit = __webpack_require__(10),
2831- collection = __webpack_require__(13),
2832+ Matrix = __webpack_require__(10),
2833+ Unit = __webpack_require__(11),
2834+ collection = __webpack_require__(14),
2835
2836 isBoolean = util['boolean'].isBoolean,
2837 isInteger = util.number.isInteger,
2838@@ -10449,17 +10854,17 @@
2839
2840
2841 /***/ },
2842-/* 68 */
2843+/* 70 */
2844 /***/ function(module, exports, __webpack_require__) {
2845
2846 'use strict';
2847
2848 module.exports = function (math, config) {
2849- var util = __webpack_require__(160),
2850+ var util = __webpack_require__(171),
2851
2852- Matrix = __webpack_require__(9),
2853- Unit = __webpack_require__(10),
2854- collection = __webpack_require__(13),
2855+ Matrix = __webpack_require__(10),
2856+ Unit = __webpack_require__(11),
2857+ collection = __webpack_require__(14),
2858
2859 isBoolean = util['boolean'].isBoolean,
2860 isInteger = util.number.isInteger,
2861@@ -10519,17 +10924,17 @@
2862
2863
2864 /***/ },
2865-/* 69 */
2866+/* 71 */
2867 /***/ function(module, exports, __webpack_require__) {
2868
2869 'use strict';
2870
2871 module.exports = function (math) {
2872- var util = __webpack_require__(160),
2873+ var util = __webpack_require__(171),
2874
2875 BigNumber = math.type.BigNumber,
2876- Complex = __webpack_require__(6),
2877- collection = __webpack_require__(13),
2878+ Complex = __webpack_require__(7),
2879+ collection = __webpack_require__(14),
2880
2881 isNumber = util.number.isNumber,
2882 isBoolean = util['boolean'].isBoolean,
2883@@ -10596,17 +11001,17 @@
2884
2885
2886 /***/ },
2887-/* 70 */
2888+/* 72 */
2889 /***/ function(module, exports, __webpack_require__) {
2890
2891 'use strict';
2892
2893 module.exports = function (math) {
2894- var util = __webpack_require__(160),
2895+ var util = __webpack_require__(171),
2896
2897 BigNumber = math.type.BigNumber,
2898- Complex = __webpack_require__(6),
2899- collection = __webpack_require__(13),
2900+ Complex = __webpack_require__(7),
2901+ collection = __webpack_require__(14),
2902
2903 object = util.object,
2904 isNumber = util.number.isNumber,
2905@@ -10671,17 +11076,17 @@
2906
2907
2908 /***/ },
2909-/* 71 */
2910+/* 73 */
2911 /***/ function(module, exports, __webpack_require__) {
2912
2913 'use strict';
2914
2915 module.exports = function (math) {
2916- var util = __webpack_require__(160),
2917+ var util = __webpack_require__(171),
2918
2919 BigNumber = math.type.BigNumber,
2920- Complex = __webpack_require__(6),
2921- collection = __webpack_require__(13),
2922+ Complex = __webpack_require__(7),
2923+ collection = __webpack_require__(14),
2924
2925 object = util.object,
2926 isNumber = util.number.isNumber,
2927@@ -10748,17 +11153,17 @@
2928
2929
2930 /***/ },
2931-/* 72 */
2932+/* 74 */
2933 /***/ function(module, exports, __webpack_require__) {
2934
2935 'use strict';
2936
2937 module.exports = function (math) {
2938- var util = __webpack_require__(160),
2939+ var util = __webpack_require__(171),
2940
2941 BigNumber = math.type.BigNumber,
2942- Complex = __webpack_require__(6),
2943- collection = __webpack_require__(13),
2944+ Complex = __webpack_require__(7),
2945+ collection = __webpack_require__(14),
2946
2947 isNumber = util.number.isNumber,
2948 isBoolean = util['boolean'].isBoolean,
2949@@ -10824,17 +11229,17 @@
2950
2951
2952 /***/ },
2953-/* 73 */
2954+/* 75 */
2955 /***/ function(module, exports, __webpack_require__) {
2956
2957 'use strict';
2958
2959 module.exports = function (math) {
2960- var util = __webpack_require__(160),
2961+ var util = __webpack_require__(171),
2962
2963 // take the BigNumber instance the provided math.js instance
2964 BigNumber = math.type.BigNumber,
2965- collection = __webpack_require__(13),
2966+ collection = __webpack_require__(14),
2967
2968 isCollection = collection.isCollection,
2969 isNumber = util.number.isNumber,
2970@@ -10893,16 +11298,16 @@
2971
2972
2973 /***/ },
2974-/* 74 */
2975+/* 76 */
2976 /***/ function(module, exports, __webpack_require__) {
2977
2978 'use strict';
2979
2980 module.exports = function (math) {
2981- var util = __webpack_require__(160),
2982+ var util = __webpack_require__(171),
2983
2984 BigNumber = math.type.BigNumber,
2985- collection = __webpack_require__(13),
2986+ collection = __webpack_require__(14),
2987
2988 isCollection = collection.isCollection,
2989 isNumber = util.number.isNumber,
2990@@ -10987,17 +11392,17 @@
2991
2992
2993 /***/ },
2994-/* 75 */
2995+/* 77 */
2996 /***/ function(module, exports, __webpack_require__) {
2997
2998 'use strict';
2999
3000 module.exports = function (math) {
3001- var util = __webpack_require__(160),
3002+ var util = __webpack_require__(171),
3003
3004 BigNumber = math.type.BigNumber,
3005- Complex = __webpack_require__(6),
3006- collection = __webpack_require__(13),
3007+ Complex = __webpack_require__(7),
3008+ collection = __webpack_require__(14),
3009
3010 isCollection = collection.isCollection,
3011 isNumber = util.number.isNumber,
3012@@ -11120,16 +11525,16 @@
3013
3014
3015 /***/ },
3016-/* 76 */
3017+/* 78 */
3018 /***/ function(module, exports, __webpack_require__) {
3019
3020 'use strict';
3021
3022 module.exports = function (math) {
3023- var util = __webpack_require__(160),
3024+ var util = __webpack_require__(171),
3025
3026 BigNumber = math.type.BigNumber,
3027- Index = __webpack_require__(8);
3028+ Index = __webpack_require__(9);
3029
3030 /**
3031 * Create an index. An Index can store ranges having start, step, and end
3032@@ -11194,14 +11599,14 @@
3033
3034
3035 /***/ },
3036-/* 77 */
3037+/* 79 */
3038 /***/ function(module, exports, __webpack_require__) {
3039
3040 'use strict';
3041
3042 module.exports = function (math) {
3043- var util = __webpack_require__(160),
3044- Matrix = __webpack_require__(9);
3045+ var util = __webpack_require__(171),
3046+ Matrix = __webpack_require__(10);
3047
3048 /**
3049 * Create a Matrix. The function creates a new `math.type.Matrix` object from
3050@@ -11239,17 +11644,17 @@
3051
3052
3053 /***/ },
3054-/* 78 */
3055+/* 80 */
3056 /***/ function(module, exports, __webpack_require__) {
3057
3058 'use strict';
3059
3060 module.exports = function (math) {
3061- var util = __webpack_require__(160);
3062+ var util = __webpack_require__(171);
3063
3064 var BigNumber = math.type.BigNumber;
3065 var Unit = math.type.Unit;
3066- var collection = __webpack_require__(13);
3067+ var collection = __webpack_require__(14);
3068
3069 var isCollection = collection.isCollection;
3070 var isNumber = util.number.isNumber;
3071@@ -11336,13 +11741,13 @@
3072
3073
3074 /***/ },
3075-/* 79 */
3076+/* 81 */
3077 /***/ function(module, exports, __webpack_require__) {
3078
3079 'use strict';
3080
3081 module.exports = function (math) {
3082- var Parser = __webpack_require__(15);
3083+ var Parser = __webpack_require__(17);
3084
3085 /**
3086 * Create a parser. The function creates a new `math.expression.Parser` object.
3087@@ -11394,7 +11799,7 @@
3088
3089
3090 /***/ },
3091-/* 80 */
3092+/* 82 */
3093 /***/ function(module, exports, __webpack_require__) {
3094
3095 'use strict';
3096@@ -11428,7 +11833,7 @@
3097 * .done(); // 5
3098 *
3099 * math.chain( [[1, 2], [3, 4]] )
3100- * .set([1, 1], 8)
3101+ * .subset(math.index(0, 0), 8)
3102 * .multiply(3)
3103 * .done(); // [[24, 6], [9, 12]]
3104 *
3105@@ -11457,15 +11862,15 @@
3106
3107
3108 /***/ },
3109-/* 81 */
3110+/* 83 */
3111 /***/ function(module, exports, __webpack_require__) {
3112
3113 'use strict';
3114
3115 module.exports = function (math) {
3116- var util = __webpack_require__(160),
3117+ var util = __webpack_require__(171),
3118
3119- collection = __webpack_require__(13),
3120+ collection = __webpack_require__(14),
3121
3122 number = util.number,
3123 isNumber = util.number.isNumber,
3124@@ -11524,17 +11929,17 @@
3125
3126
3127 /***/ },
3128-/* 82 */
3129+/* 84 */
3130 /***/ function(module, exports, __webpack_require__) {
3131
3132 'use strict';
3133
3134 module.exports = function (math) {
3135- var util = __webpack_require__(160),
3136+ var util = __webpack_require__(171),
3137
3138 BigNumber = math.type.BigNumber,
3139- Unit = __webpack_require__(10),
3140- collection = __webpack_require__(13),
3141+ Unit = __webpack_require__(11),
3142+ collection = __webpack_require__(14),
3143
3144 isCollection = collection.isCollection,
3145 isString = util.string.isString;
3146@@ -11611,18 +12016,18 @@
3147
3148
3149 /***/ },
3150-/* 83 */
3151+/* 85 */
3152 /***/ function(module, exports, __webpack_require__) {
3153
3154 'use strict';
3155
3156 module.exports = function (math) {
3157- var util = __webpack_require__(160),
3158+ var util = __webpack_require__(171),
3159
3160 BigNumber = math.type.BigNumber,
3161- Complex = __webpack_require__(6),
3162- Unit = __webpack_require__(10),
3163- collection = __webpack_require__(13),
3164+ Complex = __webpack_require__(7),
3165+ Unit = __webpack_require__(11),
3166+ collection = __webpack_require__(14),
3167
3168 isNumber = util.number.isNumber,
3169 isBoolean = util['boolean'].isBoolean,
3170@@ -11723,18 +12128,18 @@
3171
3172
3173 /***/ },
3174-/* 84 */
3175+/* 86 */
3176 /***/ function(module, exports, __webpack_require__) {
3177
3178 'use strict';
3179
3180 module.exports = function (math) {
3181- var util = __webpack_require__(160),
3182+ var util = __webpack_require__(171),
3183
3184 BigNumber = math.type.BigNumber,
3185- Complex = __webpack_require__(6),
3186- Unit = __webpack_require__(10),
3187- collection = __webpack_require__(13),
3188+ Complex = __webpack_require__(7),
3189+ Unit = __webpack_require__(11),
3190+ collection = __webpack_require__(14),
3191
3192 isNumber = util.number.isNumber,
3193 isBoolean = util['boolean'].isBoolean,
3194@@ -11798,18 +12203,18 @@
3195
3196
3197 /***/ },
3198-/* 85 */
3199+/* 87 */
3200 /***/ function(module, exports, __webpack_require__) {
3201
3202 'use strict';
3203
3204 module.exports = function (math) {
3205- var util = __webpack_require__(160),
3206+ var util = __webpack_require__(171),
3207
3208 BigNumber = math.type.BigNumber,
3209- Complex = __webpack_require__(6),
3210- Unit = __webpack_require__(10),
3211- collection = __webpack_require__(13),
3212+ Complex = __webpack_require__(7),
3213+ Unit = __webpack_require__(11),
3214+ collection = __webpack_require__(14),
3215
3216 isNumber = util.number.isNumber,
3217 isBoolean = util['boolean'].isBoolean,
3218@@ -11904,18 +12309,18 @@
3219
3220
3221 /***/ },
3222-/* 86 */
3223+/* 88 */
3224 /***/ function(module, exports, __webpack_require__) {
3225
3226 'use strict';
3227
3228 module.exports = function (math) {
3229- var util = __webpack_require__(160),
3230+ var util = __webpack_require__(171),
3231
3232 BigNumber = math.type.BigNumber,
3233- Complex = __webpack_require__(6),
3234- Unit = __webpack_require__(10),
3235- collection = __webpack_require__(13),
3236+ Complex = __webpack_require__(7),
3237+ Unit = __webpack_require__(11),
3238+ collection = __webpack_require__(14),
3239
3240 isNumber = util.number.isNumber,
3241 isBoolean = util['boolean'].isBoolean,
3242@@ -11992,23 +12397,23 @@
3243
3244
3245 /***/ },
3246-/* 87 */
3247+/* 89 */
3248 /***/ function(module, exports, __webpack_require__) {
3249
3250 'use strict';
3251
3252 module.exports = function (math) {
3253- var util = __webpack_require__(160),
3254-
3255- BigNumber = __webpack_require__(159),
3256- Matrix = __webpack_require__(9),
3257- collection = __webpack_require__(13),
3258-
3259- object = util.object,
3260- array = util.array,
3261- isNumber = util.number.isNumber,
3262- isInteger = util.number.isInteger,
3263- isCollection = collection.isCollection;
3264+ var util = __webpack_require__(171);
3265+
3266+ var BigNumber = __webpack_require__(5);
3267+ var Matrix = __webpack_require__(10);
3268+ var collection = __webpack_require__(14);
3269+
3270+ var object = util.object;
3271+ var array = util.array;
3272+ var isNumber = util.number.isNumber;
3273+ var isInteger = util.number.isInteger;
3274+ var isCollection = collection.isCollection;
3275
3276 /**
3277 * Concatenate two or more matrices.
3278@@ -12134,14 +12539,14 @@
3279
3280
3281 /***/ },
3282-/* 88 */
3283+/* 90 */
3284 /***/ function(module, exports, __webpack_require__) {
3285
3286 'use strict';
3287
3288 module.exports = function(math) {
3289- var array = __webpack_require__(153);
3290- var Matrix = __webpack_require__(9);
3291+ var array = __webpack_require__(165);
3292+ var Matrix = __webpack_require__(10);
3293
3294 /**
3295 * Calculate the cross product for two vectors in three dimensional space.
3296@@ -12219,15 +12624,15 @@
3297
3298
3299 /***/ },
3300-/* 89 */
3301+/* 91 */
3302 /***/ function(module, exports, __webpack_require__) {
3303
3304 'use strict';
3305
3306 module.exports = function (math) {
3307- var util = __webpack_require__(160),
3308+ var util = __webpack_require__(171),
3309
3310- Matrix = __webpack_require__(9),
3311+ Matrix = __webpack_require__(10),
3312
3313 object = util.object,
3314 string = util.string;
3315@@ -12380,16 +12785,16 @@
3316
3317
3318 /***/ },
3319-/* 90 */
3320+/* 92 */
3321 /***/ function(module, exports, __webpack_require__) {
3322
3323 'use strict';
3324
3325 module.exports = function (math) {
3326- var util = __webpack_require__(160),
3327+ var util = __webpack_require__(171),
3328
3329 BigNumber = math.type.BigNumber,
3330- Matrix = __webpack_require__(9),
3331+ Matrix = __webpack_require__(10),
3332
3333 object = util.object,
3334 isArray = util.array.isArray,
3335@@ -12497,14 +12902,14 @@
3336
3337
3338 /***/ },
3339-/* 91 */
3340+/* 93 */
3341 /***/ function(module, exports, __webpack_require__) {
3342
3343 'use strict';
3344
3345 module.exports = function(math) {
3346- var array = __webpack_require__(153);
3347- var Matrix = __webpack_require__(9);
3348+ var array = __webpack_require__(165);
3349+ var Matrix = __webpack_require__(10);
3350
3351 /**
3352 * Calculate the dot product of two vectors. The dot product of
3353@@ -12578,17 +12983,17 @@
3354
3355
3356 /***/ },
3357-/* 92 */
3358+/* 94 */
3359 /***/ function(module, exports, __webpack_require__) {
3360
3361 'use strict';
3362
3363 module.exports = function (math, config) {
3364- var util = __webpack_require__(160),
3365+ var util = __webpack_require__(171),
3366
3367 BigNumber = math.type.BigNumber,
3368- Matrix = __webpack_require__(9),
3369- collection = __webpack_require__(13),
3370+ Matrix = __webpack_require__(10),
3371+ collection = __webpack_require__(14),
3372
3373 isNumber = util.number.isNumber,
3374 isInteger = util.number.isInteger,
3375@@ -12681,15 +13086,15 @@
3376
3377
3378 /***/ },
3379-/* 93 */
3380+/* 95 */
3381 /***/ function(module, exports, __webpack_require__) {
3382
3383 'use strict';
3384
3385 module.exports = function (math, config) {
3386- var util = __webpack_require__(160);
3387+ var util = __webpack_require__(171);
3388
3389- var Matrix = __webpack_require__(9);
3390+ var Matrix = __webpack_require__(10);
3391
3392 var object = util.object;
3393 var array = util.array;
3394@@ -12734,14 +13139,14 @@
3395
3396
3397 /***/ },
3398-/* 94 */
3399+/* 96 */
3400 /***/ function(module, exports, __webpack_require__) {
3401
3402 'use strict';
3403
3404 module.exports = function (math) {
3405- var util = __webpack_require__(160);
3406- var Matrix = __webpack_require__(9);
3407+ var util = __webpack_require__(171);
3408+ var Matrix = __webpack_require__(10);
3409
3410 /**
3411 * Calculate the inverse of a square matrix.
3412@@ -12932,17 +13337,17 @@
3413
3414
3415 /***/ },
3416-/* 95 */
3417+/* 97 */
3418 /***/ function(module, exports, __webpack_require__) {
3419
3420 'use strict';
3421
3422 module.exports = function (math, config) {
3423- var util = __webpack_require__(160),
3424+ var util = __webpack_require__(171),
3425
3426 BigNumber = math.type.BigNumber,
3427- Matrix = __webpack_require__(9),
3428- collection = __webpack_require__(13),
3429+ Matrix = __webpack_require__(10),
3430+ collection = __webpack_require__(14),
3431
3432 array = util.array,
3433
3434@@ -13009,17 +13414,17 @@
3435
3436
3437 /***/ },
3438-/* 96 */
3439+/* 98 */
3440 /***/ function(module, exports, __webpack_require__) {
3441
3442 'use strict';
3443
3444 module.exports = function (math, config) {
3445- var util = __webpack_require__(160),
3446+ var util = __webpack_require__(171),
3447
3448 BigNumber = math.type.BigNumber,
3449- Matrix = __webpack_require__(9),
3450- collection = __webpack_require__(13),
3451+ Matrix = __webpack_require__(10),
3452+ collection = __webpack_require__(14),
3453
3454 isBoolean = util['boolean'].isBoolean,
3455 isString = util.string.isString,
3456@@ -13335,16 +13740,16 @@
3457
3458
3459 /***/ },
3460-/* 97 */
3461+/* 99 */
3462 /***/ function(module, exports, __webpack_require__) {
3463
3464 'use strict';
3465
3466 module.exports = function (math, config) {
3467- var util = __webpack_require__(160),
3468+ var util = __webpack_require__(171),
3469
3470 BigNumber = math.type.BigNumber,
3471- Matrix = __webpack_require__(9),
3472+ Matrix = __webpack_require__(10),
3473
3474 array = util.array,
3475 clone = util.object.clone,
3476@@ -13470,18 +13875,18 @@
3477
3478
3479 /***/ },
3480-/* 98 */
3481+/* 100 */
3482 /***/ function(module, exports, __webpack_require__) {
3483
3484 'use strict';
3485
3486 module.exports = function (math, config) {
3487- var util = __webpack_require__(160),
3488+ var util = __webpack_require__(171),
3489
3490 BigNumber = math.type.BigNumber,
3491- Complex = __webpack_require__(6),
3492- Unit = __webpack_require__(10),
3493- Matrix = __webpack_require__(9),
3494+ Complex = __webpack_require__(7),
3495+ Unit = __webpack_require__(11),
3496+ Matrix = __webpack_require__(10),
3497
3498 array = util.array,
3499 isNumber = util.number.isNumber,
3500@@ -13543,15 +13948,15 @@
3501
3502
3503 /***/ },
3504-/* 99 */
3505+/* 101 */
3506 /***/ function(module, exports, __webpack_require__) {
3507
3508 'use strict';
3509
3510 module.exports = function (math) {
3511- var util = __webpack_require__(160),
3512+ var util = __webpack_require__(171),
3513
3514- Matrix = __webpack_require__(9),
3515+ Matrix = __webpack_require__(10),
3516
3517 object = util.object,
3518 array = util.array,
3519@@ -13607,16 +14012,16 @@
3520
3521
3522 /***/ },
3523-/* 100 */
3524+/* 102 */
3525 /***/ function(module, exports, __webpack_require__) {
3526
3527 'use strict';
3528
3529 module.exports = function (math) {
3530- var util = __webpack_require__(160),
3531+ var util = __webpack_require__(171),
3532
3533- Matrix = __webpack_require__(9),
3534- Index = __webpack_require__(8),
3535+ Matrix = __webpack_require__(10),
3536+ Index = __webpack_require__(9),
3537
3538 array = util.array,
3539 isString = util.string.isString,
3540@@ -13824,15 +14229,123 @@
3541
3542
3543 /***/ },
3544-/* 101 */
3545-/***/ function(module, exports, __webpack_require__) {
3546-
3547- 'use strict';
3548-
3549- module.exports = function (math) {
3550- var util = __webpack_require__(160),
3551-
3552- Matrix = __webpack_require__(9),
3553+/* 103 */
3554+/***/ function(module, exports, __webpack_require__) {
3555+
3556+ 'use strict';
3557+
3558+ module.exports = function (math) {
3559+ var util = __webpack_require__(171),
3560+
3561+ Matrix = __webpack_require__(10),
3562+
3563+ object = util.object,
3564+ string = util.string;
3565+
3566+ /**
3567+ * Calculate the trace of a matrix: the sum of the elements on the main
3568+ * diagonal of a square matrix.
3569+ *
3570+ * Syntax:
3571+ *
3572+ * math.trace(x)
3573+ *
3574+ * Examples:
3575+ *
3576+ * math.trace([[1, 2], [3, 4]]); // returns 5
3577+ *
3578+ * var A = [
3579+ * [1, 2, 3],
3580+ * [-1, 2, 3],
3581+ * [2, 0, 3]
3582+ * ]
3583+ * math.trace(A); // returns 6
3584+ *
3585+ * See also:
3586+ *
3587+ * diag
3588+ *
3589+ * @param {Array | Matrix} x A matrix
3590+ * @return {Number} The trace of `x`
3591+ */
3592+ math.trace = function trace (x) {
3593+ if (arguments.length != 1) {
3594+ throw new math.error.ArgumentsError('trace', arguments.length, 1);
3595+ }
3596+
3597+ var size;
3598+ if (x instanceof Matrix) {
3599+ size = x.size();
3600+ }
3601+ else if (x instanceof Array) {
3602+ x = new Matrix(x);
3603+ size = x.size();
3604+ }
3605+ else {
3606+ // a scalar
3607+ size = [];
3608+ }
3609+
3610+ switch (size.length) {
3611+ case 0:
3612+ // scalar
3613+ return object.clone(x);
3614+
3615+ case 1:
3616+ // vector
3617+ if (size[0] == 1) {
3618+ return object.clone(x.valueOf()[0]);
3619+ }
3620+ else {
3621+ throw new RangeError('Matrix must be square ' +
3622+ '(size: ' + string.format(size) + ')');
3623+ }
3624+
3625+ case 2:
3626+ // two dimensional array
3627+ var rows = size[0];
3628+ var cols = size[1];
3629+ if (rows == cols) {
3630+ return _trace(x.clone().valueOf());
3631+ }
3632+ else {
3633+ throw new RangeError('Matrix must be square ' +
3634+ '(size: ' + string.format(size) + ')');
3635+ }
3636+
3637+ default:
3638+ // multi dimensional array
3639+ throw new RangeError('Matrix must be two dimensional ' +
3640+ '(size: ' + string.format(size) + ')');
3641+ }
3642+ };
3643+
3644+ /**
3645+ * Calculate the trace of a matrix
3646+ * @param {Array[]} matrix A square, two dimensional matrix
3647+ * @returns {Number} trace
3648+ * @private
3649+ */
3650+ function _trace (matrix) {
3651+ var sum = 0;
3652+ for (var i = 0; i < matrix.length; i++) {
3653+ sum = math.add(sum, matrix[i][i]);
3654+ }
3655+ return sum;
3656+ }
3657+ };
3658+
3659+
3660+/***/ },
3661+/* 104 */
3662+/***/ function(module, exports, __webpack_require__) {
3663+
3664+ 'use strict';
3665+
3666+ module.exports = function (math) {
3667+ var util = __webpack_require__(171),
3668+
3669+ Matrix = __webpack_require__(10),
3670
3671 object = util.object,
3672 string = util.string;
3673@@ -13907,17 +14420,17 @@
3674
3675
3676 /***/ },
3677-/* 102 */
3678+/* 105 */
3679 /***/ function(module, exports, __webpack_require__) {
3680
3681 'use strict';
3682
3683 module.exports = function (math, config) {
3684- var util = __webpack_require__(160),
3685+ var util = __webpack_require__(171),
3686
3687 BigNumber = math.type.BigNumber,
3688- Matrix = __webpack_require__(9),
3689- collection = __webpack_require__(13),
3690+ Matrix = __webpack_require__(10),
3691+ collection = __webpack_require__(14),
3692
3693 array = util.array,
3694 isArray = Array.isArray;
3695@@ -13983,16 +14496,16 @@
3696
3697
3698 /***/ },
3699-/* 103 */
3700+/* 106 */
3701 /***/ function(module, exports, __webpack_require__) {
3702
3703 'use strict';
3704
3705- module.exports = function (math) {
3706- var util = __webpack_require__(160),
3707+ module.exports = function (math, config) {
3708+ var util = __webpack_require__(171),
3709
3710 BigNumber = math.type.BigNumber,
3711- collection = __webpack_require__(13),
3712+ collection = __webpack_require__(14),
3713
3714 isNumber = util.number.isNumber,
3715 isBoolean = util['boolean'].isBoolean,
3716@@ -14022,42 +14535,56 @@
3717 * @return {Number | BigNumber | Array | Matrix} The factorial of `n`
3718 */
3719 math.factorial = function factorial (n) {
3720- var value, res;
3721+ var value, res, preciseFacs;
3722
3723 if (arguments.length != 1) {
3724 throw new math.error.ArgumentsError('factorial', arguments.length, 1);
3725 }
3726
3727 if (isNumber(n)) {
3728- return math.gamma(n + 1);
3729+ return n !== Number.POSITIVE_INFINITY
3730+ ? math.gamma(n + 1)
3731+ : Math.sqrt(2*Math.PI);
3732 }
3733
3734 if (n instanceof BigNumber) {
3735- if (!(isPositiveInteger(n)) && n.isFinite()) {
3736- return math.gamma(n.plus(1));
3737- }
3738-
3739- if (!n.isFinite()) {
3740- return new BigNumber(n);
3741- }
3742-
3743- n = n.toNumber();
3744- if (n < fac.length) {
3745- return (n < 21)
3746- ? new BigNumber(fac[n])
3747- : fac[n];
3748- }
3749-
3750- var one = new BigNumber(1);
3751- value = new BigNumber(fac.length);
3752- res = fac[fac.length - 1];
3753- for (var i = fac.length; i < n; ++i) {
3754- res = res.times(value);
3755+ if (!(isNonNegativeInteger(n))) {
3756+ return n.isNegative() || n.isFinite()
3757+ ? math.gamma(n.plus(1))
3758+ : util.bignumber.tau(config.precision).sqrt();
3759+ }
3760+
3761+ n = n.toNumber(); // should definitely be below Number.MAX_VALUE
3762+ if (n < smallBigFacs.length) {
3763+ return BigNumber.convert(smallBigFacs[n]).toSD(config.precision);
3764+ }
3765+
3766+ // be wary of round-off errors
3767+ var precision = config.precision + (Math.log(n) | 0);
3768+ var Big = BigNumber.constructor({precision: precision});
3769+
3770+ // adjust n do align with the precision specific tables
3771+ n -= smallBigFacs.length;
3772+ if (preciseFacs = bigBigFacs[precision]) {
3773+ if (preciseFacs[n]) {
3774+ return new BigNumber(preciseFacs[n].toPrecision(config.precision));
3775+ }
3776+ res = preciseFacs[preciseFacs.length-1];
3777+ } else {
3778+ preciseFacs = bigBigFacs[precision] = [];
3779+ res = new Big(smallBigFacs[smallBigFacs.length-1])
3780+ .toSD(precision);
3781+ }
3782+
3783+ var one = new Big(1);
3784+ value = new Big(preciseFacs.length + smallBigFacs.length);
3785+ for (var i = preciseFacs.length; i < n; ++i) {
3786+ preciseFacs[i] = res = res.times(value);
3787 value = value.plus(one);
3788- fac[i] = res;
3789 }
3790
3791- return fac[n] = res.times(value);
3792+ preciseFacs[n] = res.times(value);
3793+ return new BigNumber(preciseFacs[n].toPrecision(config.precision));
3794 }
3795
3796 if (isBoolean(n) || n === null) {
3797@@ -14072,16 +14599,19 @@
3798 };
3799
3800 /**
3801- * Test whether BigNumber n is a positive integer
3802+ * Test whether BigNumber n is a non-negative integer
3803 * @param {BigNumber} n
3804- * @returns {boolean} isPositiveInteger
3805+ * @returns {boolean} isNonNegativeInteger
3806 */
3807- var isPositiveInteger = function(n) {
3808+ var isNonNegativeInteger = function(n) {
3809 return n.isInteger() && (!n.isNegative() || n.isZero());
3810 };
3811
3812- // 0-21! values
3813- var fac = [
3814+ // 21! >= values for each precision
3815+ var bigBigFacs = [];
3816+
3817+ // 0-20! values
3818+ var smallBigFacs = [
3819 1,
3820 1,
3821 2,
3822@@ -14102,24 +14632,23 @@
3823 355687428096000,
3824 6402373705728000,
3825 121645100408832000,
3826- 2432902008176640000,
3827- new BigNumber('51090942171709440000')
3828+ 2432902008176640000
3829 ]
3830 };
3831
3832
3833 /***/ },
3834-/* 104 */
3835+/* 107 */
3836 /***/ function(module, exports, __webpack_require__) {
3837
3838 'use strict';
3839
3840 module.exports = function (math, config) {
3841- var util = __webpack_require__(160),
3842+ var util = __webpack_require__(171),
3843
3844 BigNumber = math.type.BigNumber,
3845- Complex = __webpack_require__(6),
3846- collection = __webpack_require__(13),
3847+ Complex = __webpack_require__(7),
3848+ collection = __webpack_require__(14),
3849
3850 isBoolean = util['boolean'].isBoolean,
3851 isComplex = Complex.isComplex,
3852@@ -14303,13 +14832,13 @@
3853
3854
3855 /***/ },
3856-/* 105 */
3857+/* 108 */
3858 /***/ function(module, exports, __webpack_require__) {
3859
3860 'use strict';
3861
3862 module.exports = function (math) {
3863- var distribution = __webpack_require__(194)(math);
3864+ var distribution = __webpack_require__(333)(math);
3865
3866 /**
3867 * Return a random number larger or equal to `min` and smaller than `max`
3868@@ -14346,13 +14875,13 @@
3869
3870
3871 /***/ },
3872-/* 106 */
3873+/* 109 */
3874 /***/ function(module, exports, __webpack_require__) {
3875
3876 'use strict';
3877
3878 module.exports = function (math) {
3879- var distribution = __webpack_require__(194)(math);
3880+ var distribution = __webpack_require__(333)(math);
3881
3882 /**
3883 * Return a random integer number larger or equal to `min` and smaller than `max`
3884@@ -14389,13 +14918,13 @@
3885
3886
3887 /***/ },
3888-/* 107 */
3889+/* 110 */
3890 /***/ function(module, exports, __webpack_require__) {
3891
3892 'use strict';
3893
3894 module.exports = function (math) {
3895- var distribution = __webpack_require__(194)(math);
3896+ var distribution = __webpack_require__(333)(math);
3897
3898 /**
3899 * Random pick a value from a one dimensional array.
3900@@ -14421,13 +14950,13 @@
3901
3902
3903 /***/ },
3904-/* 108 */
3905+/* 111 */
3906 /***/ function(module, exports, __webpack_require__) {
3907
3908 'use strict';
3909
3910 module.exports = function (math) {
3911- var util = __webpack_require__(160),
3912+ var util = __webpack_require__(171),
3913
3914 BigNumber = math.type.BigNumber,
3915
3916@@ -14534,16 +15063,16 @@
3917
3918
3919 /***/ },
3920-/* 109 */
3921+/* 112 */
3922 /***/ function(module, exports, __webpack_require__) {
3923
3924 'use strict';
3925
3926 module.exports = function (math) {
3927- var util = __webpack_require__(160),
3928+ var util = __webpack_require__(171),
3929
3930 BigNumber = math.type.BigNumber,
3931- collection = __webpack_require__(13),
3932+ collection = __webpack_require__(14),
3933
3934 isNumber = util.number.isNumber,
3935 isInteger = util.number.isInteger;
3936@@ -14631,18 +15160,18 @@
3937
3938
3939 /***/ },
3940-/* 110 */
3941+/* 113 */
3942 /***/ function(module, exports, __webpack_require__) {
3943
3944 'use strict';
3945
3946 module.exports = function (math, config) {
3947- var util = __webpack_require__(160),
3948+ var util = __webpack_require__(171),
3949
3950 BigNumber = math.type.BigNumber,
3951- Complex = __webpack_require__(6),
3952- Unit = __webpack_require__(10),
3953- collection = __webpack_require__(13),
3954+ Complex = __webpack_require__(7),
3955+ Unit = __webpack_require__(11),
3956+ collection = __webpack_require__(14),
3957
3958 isNumber = util.number.isNumber,
3959 nearlyEqual = util.number.nearlyEqual,
3960@@ -14761,13 +15290,13 @@
3961
3962
3963 /***/ },
3964-/* 111 */
3965+/* 114 */
3966 /***/ function(module, exports, __webpack_require__) {
3967
3968 'use strict';
3969
3970 module.exports = function (math) {
3971- var collection = __webpack_require__(13),
3972+ var collection = __webpack_require__(14),
3973
3974 isCollection = collection.isCollection,
3975 isArray = Array.isArray;
3976@@ -14846,18 +15375,18 @@
3977
3978
3979 /***/ },
3980-/* 112 */
3981+/* 115 */
3982 /***/ function(module, exports, __webpack_require__) {
3983
3984 'use strict';
3985
3986 module.exports = function (math, config) {
3987- var util = __webpack_require__(160),
3988+ var util = __webpack_require__(171),
3989
3990 BigNumber = math.type.BigNumber,
3991- Complex = __webpack_require__(6),
3992- Unit = __webpack_require__(10),
3993- collection = __webpack_require__(13),
3994+ Complex = __webpack_require__(7),
3995+ Unit = __webpack_require__(11),
3996+ collection = __webpack_require__(14),
3997
3998 isNumber = util.number.isNumber,
3999 nearlyEqual = util.number.nearlyEqual,
4000@@ -15010,18 +15539,18 @@
4001
4002
4003 /***/ },
4004-/* 113 */
4005+/* 116 */
4006 /***/ function(module, exports, __webpack_require__) {
4007
4008 'use strict';
4009
4010 module.exports = function (math, config) {
4011- var util = __webpack_require__(160),
4012+ var util = __webpack_require__(171),
4013
4014 BigNumber = math.type.BigNumber,
4015- Complex = __webpack_require__(6),
4016- Unit = __webpack_require__(10),
4017- collection = __webpack_require__(13),
4018+ Complex = __webpack_require__(7),
4019+ Unit = __webpack_require__(11),
4020+ collection = __webpack_require__(14),
4021
4022 isNumber = util.number.isNumber,
4023 nearlyEqual = util.number.nearlyEqual,
4024@@ -15137,18 +15666,18 @@
4025
4026
4027 /***/ },
4028-/* 114 */
4029+/* 117 */
4030 /***/ function(module, exports, __webpack_require__) {
4031
4032 'use strict';
4033
4034 module.exports = function (math, config) {
4035- var util = __webpack_require__(160),
4036+ var util = __webpack_require__(171),
4037
4038 BigNumber = math.type.BigNumber,
4039- Complex = __webpack_require__(6),
4040- Unit = __webpack_require__(10),
4041- collection = __webpack_require__(13),
4042+ Complex = __webpack_require__(7),
4043+ Unit = __webpack_require__(11),
4044+ collection = __webpack_require__(14),
4045
4046 isNumber = util.number.isNumber,
4047 nearlyEqual = util.number.nearlyEqual,
4048@@ -15265,18 +15794,18 @@
4049
4050
4051 /***/ },
4052-/* 115 */
4053+/* 118 */
4054 /***/ function(module, exports, __webpack_require__) {
4055
4056 'use strict';
4057
4058 module.exports = function (math, config) {
4059- var util = __webpack_require__(160),
4060+ var util = __webpack_require__(171),
4061
4062 BigNumber = math.type.BigNumber,
4063- Complex = __webpack_require__(6),
4064- Unit = __webpack_require__(10),
4065- collection = __webpack_require__(13),
4066+ Complex = __webpack_require__(7),
4067+ Unit = __webpack_require__(11),
4068+ collection = __webpack_require__(14),
4069
4070 isNumber = util.number.isNumber,
4071 nearlyEqual = util.number.nearlyEqual,
4072@@ -15392,18 +15921,18 @@
4073
4074
4075 /***/ },
4076-/* 116 */
4077+/* 119 */
4078 /***/ function(module, exports, __webpack_require__) {
4079
4080 'use strict';
4081
4082 module.exports = function (math, config) {
4083- var util = __webpack_require__(160),
4084+ var util = __webpack_require__(171),
4085
4086 BigNumber = math.type.BigNumber,
4087- Complex = __webpack_require__(6),
4088- Unit = __webpack_require__(10),
4089- collection = __webpack_require__(13),
4090+ Complex = __webpack_require__(7),
4091+ Unit = __webpack_require__(11),
4092+ collection = __webpack_require__(14),
4093
4094 isNumber = util.number.isNumber,
4095 nearlyEqual = util.number.nearlyEqual,
4096@@ -15519,18 +16048,18 @@
4097
4098
4099 /***/ },
4100-/* 117 */
4101+/* 120 */
4102 /***/ function(module, exports, __webpack_require__) {
4103
4104 'use strict';
4105
4106 module.exports = function (math, config) {
4107- var util = __webpack_require__(160),
4108+ var util = __webpack_require__(171),
4109
4110 BigNumber = math.type.BigNumber,
4111- Complex = __webpack_require__(6),
4112- Unit = __webpack_require__(10),
4113- collection = __webpack_require__(13),
4114+ Complex = __webpack_require__(7),
4115+ Unit = __webpack_require__(11),
4116+ collection = __webpack_require__(14),
4117
4118 isNumber = util.number.isNumber,
4119 nearlyEqual = util.number.nearlyEqual,
4120@@ -15682,14 +16211,14 @@
4121
4122
4123 /***/ },
4124-/* 118 */
4125+/* 121 */
4126 /***/ function(module, exports, __webpack_require__) {
4127
4128 'use strict';
4129
4130 module.exports = function (math) {
4131- var Matrix = __webpack_require__(9),
4132- collection = __webpack_require__(13),
4133+ var Matrix = __webpack_require__(10),
4134+ collection = __webpack_require__(14),
4135
4136 isCollection = collection.isCollection;
4137
4138@@ -15777,14 +16306,14 @@
4139
4140
4141 /***/ },
4142-/* 119 */
4143+/* 122 */
4144 /***/ function(module, exports, __webpack_require__) {
4145
4146 'use strict';
4147
4148 module.exports = function (math) {
4149- var Matrix = __webpack_require__(9),
4150- collection = __webpack_require__(13),
4151+ var Matrix = __webpack_require__(10),
4152+ collection = __webpack_require__(14),
4153
4154 isCollection = collection.isCollection;
4155
4156@@ -15872,18 +16401,18 @@
4157
4158
4159 /***/ },
4160-/* 120 */
4161+/* 123 */
4162 /***/ function(module, exports, __webpack_require__) {
4163
4164 'use strict';
4165
4166 module.exports = function (math) {
4167- var Matrix = __webpack_require__(9),
4168- collection = __webpack_require__(13),
4169+ var Matrix = __webpack_require__(10),
4170+ collection = __webpack_require__(14),
4171
4172 isCollection = collection.isCollection,
4173
4174- size = __webpack_require__(153).size,
4175+ size = __webpack_require__(165).size,
4176 isArray = Array.isArray;
4177
4178 /**
4179@@ -15976,21 +16505,21 @@
4180
4181
4182 /***/ },
4183-/* 121 */
4184+/* 124 */
4185 /***/ function(module, exports, __webpack_require__) {
4186
4187 'use strict';
4188
4189 module.exports = function (math) {
4190- var Matrix = __webpack_require__(9),
4191- Unit = __webpack_require__(10),
4192+ var Matrix = __webpack_require__(10),
4193+ Unit = __webpack_require__(11),
4194 BigNumber = math.type.BigNumber,
4195- collection = __webpack_require__(13),
4196+ collection = __webpack_require__(14),
4197
4198- isNumber = __webpack_require__(4).isNumber,
4199+ isNumber = __webpack_require__(3).isNumber,
4200 isCollection = collection.isCollection,
4201
4202- flatten = __webpack_require__(153).flatten;
4203+ flatten = __webpack_require__(165).flatten;
4204
4205 /**
4206 * Compute the median of a matrix or a list with values. The values are
4207@@ -16090,14 +16619,14 @@
4208
4209
4210 /***/ },
4211-/* 122 */
4212+/* 125 */
4213 /***/ function(module, exports, __webpack_require__) {
4214
4215 'use strict';
4216
4217 module.exports = function (math) {
4218- var Matrix = __webpack_require__(9),
4219- collection = __webpack_require__(13),
4220+ var Matrix = __webpack_require__(10),
4221+ collection = __webpack_require__(14),
4222
4223 isCollection = collection.isCollection;
4224
4225@@ -16175,7 +16704,7 @@
4226
4227
4228 /***/ },
4229-/* 123 */
4230+/* 126 */
4231 /***/ function(module, exports, __webpack_require__) {
4232
4233 'use strict';
4234@@ -16235,14 +16764,14 @@
4235
4236
4237 /***/ },
4238-/* 124 */
4239+/* 127 */
4240 /***/ function(module, exports, __webpack_require__) {
4241
4242 'use strict';
4243
4244 module.exports = function (math) {
4245- var Matrix = __webpack_require__(9),
4246- collection = __webpack_require__(13),
4247+ var Matrix = __webpack_require__(10),
4248+ collection = __webpack_require__(14),
4249
4250 isCollection = collection.isCollection;
4251
4252@@ -16318,18 +16847,18 @@
4253
4254
4255 /***/ },
4256-/* 125 */
4257+/* 128 */
4258 /***/ function(module, exports, __webpack_require__) {
4259
4260 'use strict';
4261
4262 module.exports = function (math) {
4263- var Matrix = __webpack_require__(9),
4264+ var Matrix = __webpack_require__(10),
4265 BigNumber = math.type.BigNumber,
4266- collection = __webpack_require__(13),
4267+ collection = __webpack_require__(14),
4268
4269 isCollection = collection.isCollection,
4270- isString = __webpack_require__(176).isString,
4271+ isString = __webpack_require__(205).isString,
4272
4273 DEFAULT_NORMALIZATION = 'unbiased';
4274
4275@@ -16462,22 +16991,24 @@
4276
4277
4278 /***/ },
4279-/* 126 */
4280+/* 129 */
4281 /***/ function(module, exports, __webpack_require__) {
4282
4283 'use strict';
4284
4285 module.exports = function (math) {
4286- var util = __webpack_require__(160),
4287+ var util = __webpack_require__(171),
4288
4289 BigNumber = math.type.BigNumber,
4290- Complex = __webpack_require__(6),
4291- collection = __webpack_require__(13),
4292+ Complex = __webpack_require__(7),
4293+ collection = __webpack_require__(14),
4294
4295 isNumber = util.number.isNumber,
4296 isBoolean = util['boolean'].isBoolean,
4297 isComplex = Complex.isComplex,
4298- isCollection = collection.isCollection;
4299+ isCollection = collection.isCollection,
4300+
4301+ bigArcCos = util.bignumber.arccos_arcsec;
4302
4303 /**
4304 * Calculate the inverse cosine of a value.
4305@@ -16499,8 +17030,8 @@
4306 *
4307 * cos, atan, asin
4308 *
4309- * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input
4310- * @return {Number | Complex | Array | Matrix} The arc cosine of x
4311+ * @param {Number | BigNumber Boolean | Complex | Array | Matrix | null} x Function input
4312+ * @return {Number | BigNumber | Complex | Array | Matrix} The arc cosine of x
4313 */
4314 math.acos = function acos(x) {
4315 if (arguments.length != 1) {
4316@@ -16545,9 +17076,7 @@
4317 }
4318
4319 if (x instanceof BigNumber) {
4320- // TODO: implement BigNumber support
4321- // downgrade to Number
4322- return acos(x.toNumber());
4323+ return bigArcCos(x, BigNumber, false);
4324 }
4325
4326 throw new math.error.UnsupportedTypeError('acos', math['typeof'](x));
4327@@ -16556,22 +17085,672 @@
4328
4329
4330 /***/ },
4331-/* 127 */
4332-/***/ function(module, exports, __webpack_require__) {
4333-
4334- 'use strict';
4335-
4336- module.exports = function (math) {
4337- var util = __webpack_require__(160),
4338-
4339- BigNumber = math.type.BigNumber,
4340- Complex = __webpack_require__(6),
4341- collection = __webpack_require__(13),
4342-
4343- isNumber = util.number.isNumber,
4344- isBoolean = util['boolean'].isBoolean,
4345- isComplex = Complex.isComplex,
4346- isCollection = collection.isCollection;
4347+/* 130 */
4348+/***/ function(module, exports, __webpack_require__) {
4349+
4350+ 'use strict';
4351+
4352+ module.exports = function (math) {
4353+ var util = __webpack_require__(171),
4354+
4355+ BigNumber = math.type.BigNumber,
4356+ Complex = __webpack_require__(7),
4357+ Unit = __webpack_require__(11),
4358+ collection = __webpack_require__(14),
4359+
4360+ isNumber = util.number.isNumber,
4361+ isBoolean = util['boolean'].isBoolean,
4362+ isComplex = Complex.isComplex,
4363+ isUnit = Unit.isUnit,
4364+ isCollection = collection.isCollection,
4365+
4366+ bigAcosh = util.bignumber.acosh_asinh_asech_acsch;
4367+
4368+ /**
4369+ * Calculate the hyperbolic arccos of a value,
4370+ * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.
4371+ *
4372+ * For matrices, the function is evaluated element wise.
4373+ *
4374+ * Syntax:
4375+ *
4376+ * math.acosh(x)
4377+ *
4378+ * Examples:
4379+ *
4380+ * math.acosh(1.5); // returns 0.9624236501192069
4381+ *
4382+ * See also:
4383+ *
4384+ * cosh, asinh, atanh
4385+ *
4386+ * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input
4387+ * @return {Number | Complex | Array | Matrix} Hyperbolic arccosine of x
4388+ */
4389+ math.acosh = function acosh(x) {
4390+ if (arguments.length != 1) {
4391+ throw new math.error.ArgumentsError('acosh', arguments.length, 1);
4392+ }
4393+
4394+ if (isNumber(x)) {
4395+ if (x >= 1) {
4396+ return Math.log(Math.sqrt(x*x - 1) + x);
4397+ }
4398+ if (x <= -1) {
4399+ return new Complex(Math.log(Math.sqrt(x*x - 1) - x), Math.PI);
4400+ }
4401+ return acosh(new Complex(x, 0));
4402+ }
4403+
4404+ if (isComplex(x)) {
4405+ // acosh(z) = (-acos(z).im, acos(z).re) for acos(z).im <= 0
4406+ // ( acos(z).im, -acos(z).re) otherwise
4407+ var temp;
4408+ var acos = math.acos(x);
4409+ if (acos.im <= 0) {
4410+ temp = acos.re;
4411+ acos.re = -acos.im;
4412+ acos.im = temp;
4413+ } else {
4414+ temp = acos.im;
4415+ acos.im = -acos.re;
4416+ acos.re = temp;
4417+ }
4418+
4419+ return acos;
4420+ }
4421+
4422+ if (isCollection(x)) {
4423+ return collection.deepMap(x, acosh);
4424+ }
4425+
4426+ if (isBoolean(x) || x === null) {
4427+ return (x) ? 0 : new Complex(0, 1.5707963267948966);
4428+ }
4429+
4430+ if (x instanceof BigNumber) {
4431+ return bigAcosh(x, BigNumber, false, false);
4432+ }
4433+
4434+ throw new math.error.UnsupportedTypeError('acosh', math['typeof'](x));
4435+ };
4436+ };
4437+
4438+
4439+/***/ },
4440+/* 131 */
4441+/***/ function(module, exports, __webpack_require__) {
4442+
4443+ 'use strict';
4444+
4445+ module.exports = function (math) {
4446+ var util = __webpack_require__(171),
4447+
4448+ BigNumber = math.type.BigNumber,
4449+ Complex = __webpack_require__(7),
4450+ collection = __webpack_require__(14),
4451+
4452+ isNumber = util.number.isNumber,
4453+ isBoolean = util['boolean'].isBoolean,
4454+ isComplex = Complex.isComplex,
4455+ isCollection = collection.isCollection,
4456+
4457+ bigArcCot = util.bignumber.arctan_arccot;
4458+
4459+ /**
4460+ * Calculate the inverse cotangent of a value.
4461+ *
4462+ * For matrices, the function is evaluated element wise.
4463+ *
4464+ * Syntax:
4465+ *
4466+ * math.acot(x)
4467+ *
4468+ * Examples:
4469+ *
4470+ * math.acot(0.5); // returns Number 0.4636476090008061
4471+ * math.acot(math.cot(1.5)); // returns Number 1.5
4472+ *
4473+ * math.acot(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i
4474+ *
4475+ * See also:
4476+ *
4477+ * cot, atan
4478+ *
4479+ * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input
4480+ * @return {Number | Complex | Array | Matrix} The arc cotangent of x
4481+ */
4482+ math.acot = function acot(x) {
4483+ if (arguments.length != 1) {
4484+ throw new math.error.ArgumentsError('acot', arguments.length, 1);
4485+ }
4486+
4487+ if (isNumber(x)) {
4488+ return (x) ? Math.atan(1 / x) : halfPi;
4489+ }
4490+
4491+ if (isComplex(x)) {
4492+ if (x.im == 0) {
4493+ return new Complex(x.re ? Math.atan(1 / x.re) : halfPi, 0);
4494+ }
4495+
4496+ var den = x.re*x.re + x.im*x.im;
4497+ x = (den != 0)
4498+ ? new Complex(
4499+ x.re = x.re / den,
4500+ x.im = -x.im / den)
4501+ : new Complex(
4502+ (x.re != 0) ? (x.re / 0) : 0,
4503+ (x.im != 0) ? -(x.im / 0) : 0);
4504+
4505+ return math.atan(x);
4506+ }
4507+
4508+ if (isCollection(x)) {
4509+ return collection.deepMap(x, acot);
4510+ }
4511+
4512+ if (isBoolean(x) || x === null) {
4513+ return (x) ? 0.7853981633974483 : halfPi;
4514+ }
4515+
4516+ if (x instanceof BigNumber) {
4517+ return bigArcCot(x, BigNumber, true);
4518+ }
4519+
4520+ throw new math.error.UnsupportedTypeError('acot', math['typeof'](x));
4521+ };
4522+
4523+ var halfPi = 1.5707963267948966;
4524+ };
4525+
4526+
4527+/***/ },
4528+/* 132 */
4529+/***/ function(module, exports, __webpack_require__) {
4530+
4531+ 'use strict';
4532+
4533+ module.exports = function (math) {
4534+ var util = __webpack_require__(171),
4535+
4536+ BigNumber = math.type.BigNumber,
4537+ Complex = __webpack_require__(7),
4538+ Unit = __webpack_require__(11),
4539+ collection = __webpack_require__(14),
4540+
4541+ isNumber = util.number.isNumber,
4542+ isBoolean = util['boolean'].isBoolean,
4543+ isComplex = Complex.isComplex,
4544+ isUnit = Unit.isUnit,
4545+ isCollection = collection.isCollection,
4546+
4547+ bigAcoth = util.bignumber.atanh_acoth;
4548+
4549+ /**
4550+ * Calculate the hyperbolic arccotangent of a value,
4551+ * defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.
4552+ *
4553+ * For matrices, the function is evaluated element wise.
4554+ *
4555+ * Syntax:
4556+ *
4557+ * math.acoth(x)
4558+ *
4559+ * Examples:
4560+ *
4561+ * math.acoth(0.5); // returns 0.8047189562170503
4562+ *
4563+ * See also:
4564+ *
4565+ * acsch, asech
4566+ *
4567+ * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input
4568+ * @return {Number | Complex | Array | Matrix} Hyperbolic arccotangent of x
4569+ */
4570+ math.acoth = function acoth(x) {
4571+ if (arguments.length != 1) {
4572+ throw new math.error.ArgumentsError('acoth', arguments.length, 1);
4573+ }
4574+
4575+ if (isNumber(x)) {
4576+ if (x >= 1 || x <= -1) {
4577+ return isFinite(x) ? (Math.log((x+1)/x) + Math.log(x/(x-1))) / 2 : 0;
4578+ }
4579+ return (x) ? acoth(new Complex(x, 0)) : new Complex(0, halfPi);
4580+ }
4581+
4582+ if (isComplex(x)) {
4583+ if (x.re == 0 && x.im == 0) {
4584+ return new Complex(0, halfPi);
4585+ }
4586+
4587+ // acoth(z) = -i*atanh(1/z)
4588+ var den = x.re*x.re + x.im*x.im;
4589+ x = (den != 0)
4590+ ? new Complex(
4591+ x.re / den,
4592+ -x.im / den
4593+ )
4594+ : new Complex(
4595+ (x.re != 0) ? (x.re / 0) : 0,
4596+ (x.im != 0) ? -(x.im / 0) : 0
4597+ );
4598+
4599+ return math.atanh(x);
4600+ }
4601+
4602+ if (isCollection(x)) {
4603+ return collection.deepMap(x, acoth);
4604+ }
4605+
4606+ if (isBoolean(x) || x === null) {
4607+ return (x) ? Infinity : new Complex(0, halfPi);
4608+ }
4609+
4610+ if (x instanceof BigNumber) {
4611+ return bigAcoth(x, BigNumber, true);
4612+ }
4613+
4614+ throw new math.error.UnsupportedTypeError('acoth', math['typeof'](x));
4615+ };
4616+
4617+ var halfPi = 1.5707963267948966;
4618+ };
4619+
4620+
4621+/***/ },
4622+/* 133 */
4623+/***/ function(module, exports, __webpack_require__) {
4624+
4625+ 'use strict';
4626+
4627+ module.exports = function (math) {
4628+ var util = __webpack_require__(171),
4629+
4630+ BigNumber = math.type.BigNumber,
4631+ Complex = __webpack_require__(7),
4632+ collection = __webpack_require__(14),
4633+
4634+ isNumber = util.number.isNumber,
4635+ isBoolean = util['boolean'].isBoolean,
4636+ isComplex = Complex.isComplex,
4637+ isCollection = collection.isCollection,
4638+
4639+ bigArcCsc = util.bignumber.arcsin_arccsc;
4640+
4641+ /**
4642+ * Calculate the inverse cosecant of a value.
4643+ *
4644+ * For matrices, the function is evaluated element wise.
4645+ *
4646+ * Syntax:
4647+ *
4648+ * math.acsc(x)
4649+ *
4650+ * Examples:
4651+ *
4652+ * math.acsc(0.5); // returns Number 0.5235987755982989
4653+ * math.acsc(math.csc(1.5)); // returns Number ~1.5
4654+ *
4655+ * math.acsc(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i
4656+ *
4657+ * See also:
4658+ *
4659+ * csc, asin, asec
4660+ *
4661+ * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input
4662+ * @return {Number | Complex | Array | Matrix} The arc cosecant of x
4663+ */
4664+ math.acsc = function acsc(x) {
4665+ if (arguments.length != 1) {
4666+ throw new math.error.ArgumentsError('acsc', arguments.length, 1);
4667+ }
4668+
4669+ if (isNumber(x)) {
4670+ if (x <= -1 || x >= 1) {
4671+ return Math.asin(1 / x);
4672+ }
4673+ return acsc(new Complex(x, 0));
4674+ }
4675+
4676+ if (isComplex(x)) {
4677+ if (x.re == 0 && x.im == 0) {
4678+ return new Complex(halfPi, Infinity);
4679+ }
4680+
4681+ var den = x.re*x.re + x.im*x.im;
4682+ x = (den != 0)
4683+ ? new Complex(
4684+ x.re = x.re / den,
4685+ x.im = -x.im / den)
4686+ : new Complex(
4687+ (x.re != 0) ? (x.re / 0) : 0,
4688+ (x.im != 0) ? -(x.im / 0) : 0);
4689+
4690+ return math.asin(x);
4691+ }
4692+
4693+ if (isCollection(x)) {
4694+ return collection.deepMap(x, acsc);
4695+ }
4696+
4697+ if (isBoolean(x) || x === null) {
4698+ return (x) ? halfPi : new Complex(halfPi, Infinity);
4699+ }
4700+
4701+ if (x instanceof BigNumber) {
4702+ return bigArcCsc(x, BigNumber, true);
4703+ }
4704+
4705+ throw new math.error.UnsupportedTypeError('acsc', math['typeof'](x));
4706+ };
4707+
4708+ var halfPi = 1.5707963267948966;
4709+ };
4710+
4711+
4712+/***/ },
4713+/* 134 */
4714+/***/ function(module, exports, __webpack_require__) {
4715+
4716+ 'use strict';
4717+
4718+ module.exports = function (math) {
4719+ var util = __webpack_require__(171),
4720+
4721+ BigNumber = math.type.BigNumber,
4722+ Complex = __webpack_require__(7),
4723+ Unit = __webpack_require__(11),
4724+ collection = __webpack_require__(14),
4725+
4726+ isNumber = util.number.isNumber,
4727+ isBoolean = util['boolean'].isBoolean,
4728+ isComplex = Complex.isComplex,
4729+ isUnit = Unit.isUnit,
4730+ isCollection = collection.isCollection,
4731+
4732+ bigAcsch = util.bignumber.acosh_asinh_asech_acsch;
4733+
4734+ /**
4735+ * Calculate the hyperbolic arccosecant of a value,
4736+ * defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.
4737+ *
4738+ * For matrices, the function is evaluated element wise.
4739+ *
4740+ * Syntax:
4741+ *
4742+ * math.acsch(x)
4743+ *
4744+ * Examples:
4745+ *
4746+ * math.acsch(0.5); // returns 1.4436354751788103
4747+ *
4748+ * See also:
4749+ *
4750+ * asech, acoth
4751+ *
4752+ * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input
4753+ * @return {Number | Complex | Array | Matrix} Hyperbolic arccosecant of x
4754+ */
4755+ math.acsch = function acsch(x) {
4756+ if (arguments.length != 1) {
4757+ throw new math.error.ArgumentsError('acsch', arguments.length, 1);
4758+ }
4759+
4760+ if (isNumber(x)) {
4761+ x = 1 / x;
4762+ return Math.log(x + Math.sqrt(x*x + 1));
4763+ }
4764+
4765+ if (isComplex(x)) {
4766+ if (x.im == 0) {
4767+ x = (x.re != 0)
4768+ ? Math.log(x.re + Math.sqrt(x.re*x.re + 1))
4769+ : Infinity;
4770+ return new Complex(x, 0);
4771+ }
4772+
4773+ // acsch(z) = -i*asinh(1/z)
4774+ var den = x.re*x.re + x.im*x.im;
4775+ x = (den != 0)
4776+ ? new Complex(
4777+ x.re / den,
4778+ -x.im / den
4779+ )
4780+ : new Complex(
4781+ (x.re != 0) ? (x.re / 0) : 0,
4782+ (x.im != 0) ? -(x.im / 0) : 0
4783+ );
4784+
4785+ return math.asinh(x);
4786+ }
4787+
4788+ if (isCollection(x)) {
4789+ return collection.deepMap(x, acsch);
4790+ }
4791+
4792+ if (isBoolean(x) || x === null) {
4793+ return (x) ? 0.881373587019543 : Infinity;
4794+ }
4795+
4796+ if (x instanceof BigNumber) {
4797+ return bigAcsch(x, BigNumber, true, true);
4798+ }
4799+
4800+ throw new math.error.UnsupportedTypeError('acsch', math['typeof'](x));
4801+ };
4802+ };
4803+
4804+
4805+/***/ },
4806+/* 135 */
4807+/***/ function(module, exports, __webpack_require__) {
4808+
4809+ 'use strict';
4810+
4811+ module.exports = function (math) {
4812+ var util = __webpack_require__(171),
4813+
4814+ BigNumber = math.type.BigNumber,
4815+ Complex = __webpack_require__(7),
4816+ collection = __webpack_require__(14),
4817+
4818+ isNumber = util.number.isNumber,
4819+ isBoolean = util['boolean'].isBoolean,
4820+ isComplex = Complex.isComplex,
4821+ isCollection = collection.isCollection,
4822+
4823+ bigArcSec = util.bignumber.arccos_arcsec;
4824+
4825+ /**
4826+ * Calculate the inverse secant of a value.
4827+ *
4828+ * For matrices, the function is evaluated element wise.
4829+ *
4830+ * Syntax:
4831+ *
4832+ * math.asec(x)
4833+ *
4834+ * Examples:
4835+ *
4836+ * math.asec(0.5); // returns 1.0471975511965979
4837+ * math.asec(math.sec(1.5)); // returns 1.5
4838+ *
4839+ * math.asec(2); // returns 0 + 1.3169578969248166 i
4840+ *
4841+ * See also:
4842+ *
4843+ * acos, acot, acsc
4844+ *
4845+ * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input
4846+ * @return {Number | Complex | Array | Matrix} The arc secant of x
4847+ */
4848+ math.asec = function asec(x) {
4849+ if (arguments.length != 1) {
4850+ throw new math.error.ArgumentsError('asec', arguments.length, 1);
4851+ }
4852+
4853+ if (isNumber(x)) {
4854+ if (x <= -1 || x >= 1) {
4855+ return Math.acos(1 / x);
4856+ }
4857+ return asec(new Complex(x, 0));
4858+ }
4859+
4860+ if (isComplex(x)) {
4861+ if (x.re == 0 && x.im == 0) {
4862+ return new Complex(0, Infinity);
4863+ }
4864+
4865+ var den = x.re*x.re + x.im*x.im;
4866+ x = (den != 0)
4867+ ? new Complex(
4868+ x.re = x.re / den,
4869+ x.im = -x.im / den)
4870+ : new Complex(
4871+ (x.re != 0) ? (x.re / 0) : 0,
4872+ (x.im != 0) ? -(x.im / 0) : 0);
4873+
4874+ return math.acos(x);
4875+ }
4876+
4877+ if (isCollection(x)) {
4878+ return collection.deepMap(x, asec);
4879+ }
4880+
4881+ if (isBoolean(x) || x === null) {
4882+ return (x) ? 0 : new Complex(0, Infinity);
4883+ }
4884+
4885+ if (x instanceof BigNumber) {
4886+ return bigArcSec(x, BigNumber, true);
4887+ }
4888+
4889+ throw new math.error.UnsupportedTypeError('asec', math['typeof'](x));
4890+ };
4891+ };
4892+
4893+
4894+/***/ },
4895+/* 136 */
4896+/***/ function(module, exports, __webpack_require__) {
4897+
4898+ 'use strict';
4899+
4900+ module.exports = function (math) {
4901+ var util = __webpack_require__(171),
4902+
4903+ BigNumber = math.type.BigNumber,
4904+ Complex = __webpack_require__(7),
4905+ Unit = __webpack_require__(11),
4906+ collection = __webpack_require__(14),
4907+
4908+ isNumber = util.number.isNumber,
4909+ isBoolean = util['boolean'].isBoolean,
4910+ isComplex = Complex.isComplex,
4911+ isUnit = Unit.isUnit,
4912+ isCollection = collection.isCollection,
4913+
4914+ bigAsech = util.bignumber.acosh_asinh_asech_acsch;
4915+
4916+ /**
4917+ * Calculate the hyperbolic arccos of a value,
4918+ * defined as `asech(x) = ln(sqrt(1/x^2 - 1) + 1/x)`.
4919+ *
4920+ * For matrices, the function is evaluated element wise.
4921+ *
4922+ * Syntax:
4923+ *
4924+ * math.asech(x)
4925+ *
4926+ * Examples:
4927+ *
4928+ * math.asech(0.5); // returns 1.3169578969248166
4929+ *
4930+ * See also:
4931+ *
4932+ * acsch, acoth
4933+ *
4934+ * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input
4935+ * @return {Number | Complex | Array | Matrix} Hyperbolic arcsecant of x
4936+ */
4937+ math.asech = function asech(x) {
4938+ if (arguments.length != 1) {
4939+ throw new math.error.ArgumentsError('asech', arguments.length, 1);
4940+ }
4941+
4942+ if (isNumber(x)) {
4943+ if (x <= 1 && x >= -1) {
4944+ x = 1 / x;
4945+
4946+ var ret = Math.sqrt(x*x - 1);
4947+ if (x > 0) {
4948+ return Math.log(ret + x);
4949+ }
4950+
4951+ return new Complex(Math.log(ret - x), Math.PI);
4952+ }
4953+
4954+ return asech(new Complex(x, 0));
4955+ }
4956+
4957+ if (isComplex(x)) {
4958+ if (x.re == 0 && x.im == 0) {
4959+ return new Complex(Infinity, 0);
4960+ }
4961+
4962+ // acsch(z) = -i*asinh(1/z)
4963+ var den = x.re*x.re + x.im*x.im;
4964+ x = (den != 0)
4965+ ? new Complex(
4966+ x.re / den,
4967+ -x.im / den
4968+ )
4969+ : new Complex(
4970+ (x.re != 0) ? (x.re / 0) : 0,
4971+ (x.im != 0) ? -(x.im / 0) : 0
4972+ );
4973+
4974+ return math.acosh(x);
4975+ }
4976+
4977+ if (isCollection(x)) {
4978+ return collection.deepMap(x, asech);
4979+ }
4980+
4981+ if (isBoolean(x) || x === null) {
4982+ return (x) ? 0 : Infinity;
4983+ }
4984+
4985+ if (x instanceof BigNumber) {
4986+ return bigAsech(x, BigNumber, false, true);
4987+ }
4988+
4989+ throw new math.error.UnsupportedTypeError('asech', math['typeof'](x));
4990+ };
4991+ };
4992+
4993+
4994+/***/ },
4995+/* 137 */
4996+/***/ function(module, exports, __webpack_require__) {
4997+
4998+ 'use strict';
4999+
5000+ module.exports = function (math) {
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches