mathjs/math.min.js
2013-02-21 17:31:04 +01:00

25 lines
31 KiB
JavaScript

/**
* math.js
* An extended math library. Includes a parser, real and complex values, units,
* matrices, strings, and a large set of functions and constants.
* https://github.com/josdejong/mathjs
*
* @version @@version
* @date @@date
*
* @license
* Copyright (C) 2013 Jos de Jong <wjosdejong@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
undefined(function(){function e(a,i){if(this.constructor!=e)throw Error("Unit constructor must be called with the new operator");this.value=1,this.unit=e.UNIT_NONE,this.prefix=e.PREFIX_NONE,this.hasUnit=!1,this.hasValue=!1,this.fixPrefix=!1,this._init(a,i)}function a(e){return e instanceof String||"string"==typeof e}function i(e){return e instanceof Number||"number"==typeof e}function n(e){return e==Math.round(e)}function t(e,a){if(this.constructor!=t)throw Error("Complex constructor must be called with the new operator");this.re=e||0,this.im=a||0}function r(e,a){var i=void 0;if(2==arguments.length){var n=f(a);i="Function "+e+" does not support a parameter of type "+n}else if(arguments.length>2){for(var t=[],r=1;arguments.length>r;r++)t.push(f(arguments[r]));i="Function "+e+" does not support a parameters of type "+t.join(", ")}else i="Unsupported parameter in function "+e;return new TypeError(i)}function s(e){if(e.doc)return o(e.doc);if(e.constructor.doc)return o(e.constructor.doc);if(a(e)){var i=H[e];if(i&&i.doc)return o(i.doc);for(var n in H.type)if(H.type.hasOwnProperty(n)&&e.toLowerCase()==n.toLowerCase()&&H.type[n].doc)return o(H.type[n].doc)}return e instanceof Object&&e.name?'No documentation found on subject "'+e.name+'"':e instanceof Object&&e.constructor.name?'No documentation found on subject "'+e.constructor.name+'"':'No documentation found on subject "'+e+'"'}function o(e){var a="";if(e.name&&(a+="NAME\n"+e.name+"\n\n"),e.category&&(a+="CATEGORY\n"+e.category+"\n\n"),e.syntax&&(a+="SYNTAX\n"+e.syntax.join("\n")+"\n\n"),e.examples){a+="EXAMPLES\n";for(var i=0;e.examples.length>i;i++)a+=e.examples[i]+"\n";a+="\n"}return e.seealso&&(a+="SEE ALSO\n"+e.seealso.join(", ")+"\n"),a}function f(e){var a=typeof e;if("object"==a){if(null==e)return"null";if(e&&e.constructor&&e.constructor.name)return e.constructor.name.toLowerCase()}return a}function u(){if(0==arguments.length)throw Error("Function sum requires one or multiple parameters (0 provided)");for(var e=arguments[0],a=1,i=arguments.length;i>a;a++){var n=arguments[a];L(n,e)&&(e=n)}return c}function c(){if(0==arguments.length)throw Error("Function sum requires one or multiple parameters (0 provided)");for(var e=arguments[0],a=1,i=arguments.length;i>a;a++){var n=arguments[a];S(n,e)&&(e=n)}return e}function l(a,i){if(a instanceof e){if(i.hasValue)throw Error("Cannot convert to a unit with a value");if(!i.hasUnit)throw Error("Unit expected on the right hand side of function in");var n=i.copy();return n.value=a.value,n.fixPrefix=!0,n}throw r("in",a)}function m(a){if(i(a))return Math.sin(a);if(a instanceof t)return new t(.5*Math.sin(a.re)*(Math.exp(-a.im)+Math.exp(a.im)),.5*Math.cos(a.re)*(Math.exp(a.im)-Math.exp(-a.im)));if(a instanceof e){if(!a.hasBase(e.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.sin(a.value)}throw r("sin",a)}function p(e,a){if(i(e)){if(i(a))return Math.atan2(e,a);if(a instanceof t)return Math.atan2(e,a.re)}else if(e instanceof t){if(i(a))return Math.atan2(e.re,a);if(a instanceof t)return Math.atan2(e.re,a.re)}throw r("atan2",e,a)}function h(e){if(i(e))return e>=-1&&1>=e?Math.asin(e):h(new t(e,0));if(e instanceof t){var a=e.re,n=e.im,s=new t(n*n-a*a+1,-2*a*n),o=T(s),f=new t(o.re-n,o.im+a),u=R(f);return new t(u.im,-u.re)}throw r("asin",e)}function v(e){if(i(e))return Math.atan(e);if(e instanceof t){var a=e.re,n=e.im,s=a*a+(1-n)*(1-n),o=new t((1-n*n-a*a)/s,-2*a/s),f=R(o);return new t(-.5*f.im,.5*f.re)}throw r("atan",e)}function x(a){if(i(a))return Math.cos(a);if(a instanceof t)return new t(.5*Math.cos(a.re)*(Math.exp(-a.im)+Math.exp(a.im)),.5*Math.sin(a.re)*(Math.exp(-a.im)-Math.exp(a.im)));if(a instanceof e){if(!a.hasBase(e.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.cos(a.value)}throw r("cos",a)}function d(a){if(i(a))return Math.tan(a);if(a instanceof t){var n=Math.exp(-4*a.im)+2*Math.exp(-2*a.im)*Math.cos(2*a.re)+1;return new t(2*Math.exp(-2*a.im)*Math.sin(2*a.re)/n,(1-Math.exp(-4*a.im))/n)}if(a instanceof e){if(!a.hasBase(e.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return Math.tan(a.value)}throw r("tan",a)}function N(e){if(i(e))return e>=-1&&1>=e?Math.acos(e):N(new t(e,0));if(e instanceof t){var a=new t(e.im*e.im-e.re*e.re+1,-2*e.re*e.im),n=T(a),s=new t(n.re-e.im,n.im+e.re),o=R(s);return new t(1.5707963267948966-o.im,o.re)}throw r("acos",e)}function E(a,n){if(i(a)){if(i(n))return a/n;if(n instanceof t)return b(new t(a),n)}else if(a instanceof t){if(i(n))return b(a,new t(n));if(n instanceof t)return b(a,n)}else if(a instanceof e&&i(n)){var s=a.copy();return s.value/=n,s}throw r("divide",a,n)}function b(e,a){var i=a.re*a.re+a.im*a.im;return new t((e.re*a.re+e.im*a.im)/i,(e.im*a.re-e.re*a.im)/i)}function y(e,a){if(void 0==a){if(i(e))return Math.round(e);if(e instanceof t)return new t(Math.round(e.re),Math.round(e.im));throw r("round",e)}if(!i(a))throw new TypeError("Number of digits in function round must be an integer");if(a!==Math.round(a))throw new TypeError("Number of digits in function round must be integer");if(0>a||a>9)throw Error("Number of digits in function round must be in te range of 0-9");if(i(e))return M(e,a);if(e instanceof t)return new t(M(e.re,a),M(e.im,a));throw r("round",e,a)}function M(e,a){var i=Math.pow(10,void 0!=a?a:F.precision);return Math.round(e*i)/i}function O(e){if(i(e))return value>0?Math.floor(e):Math.ceil(e);if(e instanceof t)return new t(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im));throw r("fix",e)}function g(n,s){if(i(n)){if(i(s))return n+s;if(s instanceof t)return new t(n+s.re,s.im)}else if(n instanceof t){if(i(s))return new t(n.re+s,n.im);if(s instanceof t)return new t(n.re+s.re,n.im+s.im)}else if(n instanceof e&&s instanceof e){if(!n.equalBase(s))throw Error("Units do not match");if(!n.hasValue)throw Error("Unit on left hand side of operator + has no value");if(!s.hasValue)throw Error("Unit on right hand side of operator + has no value");var o=n.copy();return o.value+=s.value,o.fixPrefix=!1,o}if(a(n)||a(s))return n+s;throw r("add",n,s)}function w(e){if(i(e))return Math.exp(e);if(e instanceof t){var a=Math.exp(e.re);return new t(a*Math.cos(e.im),a*Math.sin(e.im))}throw r("exp",e)}function T(e){if(i(e))return e>=0?Math.sqrt(e):T(new t(e,0));if(e instanceof t){var a=Math.sqrt(e.re*e.re+e.im*e.im);return e.im>=0?new t(.5*Math.sqrt(2*(a+e.re)),.5*Math.sqrt(2*(a-e.re))):new t(.5*Math.sqrt(2*(a+e.re)),-.5*Math.sqrt(2*(a-e.re)))}throw r("sqrt",e)}function S(n,s){if(i(n)){if(i(s))return n>s;if(s instanceof t)return n>A(s)}if(n instanceof t){if(i(s))return A(n)>s;if(s instanceof t)return A(n)>A(s)}if(n instanceof e&&s instanceof e){if(!n.equalBase(s))throw Error("Cannot compare units with different base");return n.value>s.value}if(a(n)||a(s))return n>s;throw r("larger",n,s)}function U(a){if(i(a))return-a;if(a instanceof t)return new t(-a.re,-a.im);if(a instanceof e){var n=a.copy();return n.value=-a.value,n}throw r("unaryminus",a)}function L(n,s){if(i(n)){if(i(s))return s>n;if(s instanceof t)return A(s)>n}if(n instanceof t){if(i(s))return s>A(n);if(s instanceof t)return A(n)<A(s)}if(n instanceof e&&s instanceof e){if(!n.equalBase(s))throw Error("Cannot compare units with different base");return n.value<s.value}if(a(n)||a(s))return s>n;throw r("smaller",n,s)}function A(e){if(i(e))return Math.abs(e);if(e instanceof t)return Math.sqrt(e.re*e.re+e.im*e.im);throw r("abs",e)}function R(e){if(i(e))return e>=0?Math.log(e):R(new t(e,0));if(e instanceof t)return new t(Math.log(Math.sqrt(e.re*e.re+e.im*e.im)),Math.atan2(e.im,e.re));throw r("log",e)}function I(e,a){if(i(e)){if(i(a))return n(a)||e>=0?Math.pow(e,a):q(new t(e),new t(a));if(a instanceof t)return q(new t(e),a)}else if(e instanceof t){if(i(a))return q(e,new t(a));if(a instanceof t)return q(e,a)}throw r("pow",e,a)}function q(e,a){var i=R(e),n=_(i,a);return w(n)}function G(e){if(i(e))return Math.floor(e);if(e instanceof t)return new t(Math.floor(e.re),Math.floor(e.im));throw r("floor",e)}function C(e){if(i(e))return Math.ceil(e);if(e instanceof t)return new t(Math.ceil(e.re),Math.ceil(e.im));throw r("ceil",e)}function _(a,n){var s;if(i(a)){if(i(n))return a*n;if(n instanceof t)return V(new t(a),n);if(n instanceof e)return s=n.copy(),s.value*=a,s}else if(a instanceof t){if(i(n))return V(a,new t(n));if(n instanceof t)return V(a,n)}else if(a instanceof e&&i(n))return s=a.copy(),s.value*=n,s;throw r("multiply",a,n)}function V(e,a){return new t(e.re*a.re-e.im*a.im,e.re*a.im+e.im*a.re)}function P(a,n){if(i(a)){if(i(n))return a-n;if(n instanceof t)return new t(a-n.re,n.im)}else if(a instanceof t){if(i(n))return new t(a.re-n,a.im);if(n instanceof t)return new t(a.re-n.re,a.im-n.im)}else if(a instanceof e&&n instanceof e){if(!a.equalBase(n))throw Error("Units do not match");if(!a.hasValue)throw Error("Unit on left hand side of operator - has no value");if(!n.hasValue)throw Error("Unit on right hand side of operator - has no value");var s=a.copy();return s.value-=n.value,s.fixPrefix=!1,s}throw r("subtract",a,n)}function B(){return Math.random()}var H={type:{},parser:{}};"undefined"!=typeof module&&module.exports!==void 0&&(module.exports=H),"undefined"!=typeof exports&&(exports=H),"undefined"!=typeof require&&"undefined"!=typeof define&&define(function(){return H}),"undefined"!=typeof window&&(window.math=H);var F={precision:10};H.options=F;var k={};if(k.format=function(e,a){if(1/0===e)return"Infinity";if(e===-1/0)return"-Infinity";if(0/0===e)return"NaN";var i=Math.abs(e);if(i>1e-4&&1e6>i||0==i)return M(e,a)+"";var n=Math.round(Math.log(i)/Math.LN10),t=e/Math.pow(10,n);return M(t,a)+"E"+n},k.randomUUID=function(){var e=function(){return Math.floor(65536*Math.random()).toString(16)};return e()+e()+"-"+e()+"-"+e()+"-"+e()+"-"+e()+e()+e()},!Array.prototype.indexOf){Array.prototype.indexOf=function(e){for(var a=0;this.length>a;a++)if(this[a]==e)return a;return-1};try{console.log("Warning: Ancient browser detected. Please update your browser")}catch(z){}}Array.prototype.forEach||(Array.prototype.forEach=function(e,a){for(var i=0,n=this.length;n>i;++i)e.call(a||this,this[i],i,this)}),H.type.Unit=e,e.prototype.copy=function(){var a=new e;for(var i in this)this.hasOwnProperty(i)&&(a[i]=this[i]);return a},e.endsWith=function(e,a){var i=e.length-a.length,n=e.length;return e.substring(i,n)===a},e.prototype._init=function(a,i){if(void 0!==i){for(var n=e.UNITS,t=!1,r=0,s=n.length;s>r;r++){var o=n[r];if(e.endsWith(i,o.name)){var f=i.length-o.name.length,u=i.substring(0,f),c=o.prefixes[u];if(void 0!==c){this.unit=o,this.prefix=c,this.hasUnit=!0,t=!0;break}}}if(!t)throw Error('String "'+i+'" is no unit')}void 0!==a?(this.value=this._normalize(a),this.hasValue=!0):this.value=this._normalize(1)},e.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},e.prototype._unnormalize=function(e,a){return void 0===a?e/this.unit.value/this.prefix.value-this.unit.offset:e/this.unit.value/a-this.unit.offset},e.isUnit=function(a){for(var i=e.UNITS,n=i.length,t=0;n>t;t++){var r=i[t];if(e.endsWith(a,r.name)){var s=a.length-r.name.length;if(0==s)return!0;var o=a.substring(0,s),f=r.prefixes[o];if(void 0!==f)return!0}}return!1},e.prototype.hasBase=function(e){return void 0===this.unit.base?void 0===e:this.unit.base===e},e.prototype.equalBase=function(e){return this.unit.base===e.unit.base},e.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},e.prototype.toString=function(){var a;if(this.fixPrefix)return a=this._unnormalize(this.value),k.format(a)+" "+this.prefix.name+this.unit.name;var i=e.PREFIX_NONE,n=Math.abs(Math.log(this.value/i.value)/Math.LN10-1.5),t=this.unit.prefixes;for(var r in t)if(t.hasOwnProperty(r)){var s=t[r];if(s.scientific){var o=Math.abs(Math.log(this.value/s.value)/Math.LN10-1.5);n>o&&(i=s,n=o)}}return a=this._unnormalize(this.value,i.value),k.format(a)+" "+i.name+this.unit.name},e.PREFIXES={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1024,scientific:!0},M:{name:"M",value:Math.pow(1024,2),scientific:!0},G:{name:"G",value:Math.pow(1024,3),scientific:!0},T:{name:"T",value:Math.pow(1024,4),scientific:!0},P:{name:"P",value:Math.pow(1024,5),scientific:!0},E:{name:"E",value:Math.pow(1024,6),scientific:!0},Z:{name:"Z",value:Math.pow(1024,7),scientific:!0},Y:{name:"Y",value:Math.pow(1024,8),scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1024,scientific:!0},mega:{name:"mega",value:Math.pow(1024,2),scientific:!0},giga:{name:"giga",value:Math.pow(1024,3),scientific:!0},tera:{name:"tera",value:Math.pow(1024,4),scientific:!0},peta:{name:"peta",value:Math.pow(1024,5),scientific:!0},exa:{name:"exa",value:Math.pow(1024,6),scientific:!0},zetta:{name:"zetta",value:Math.pow(1024,7),scientific:!0},yotta:{name:"yotta",value:Math.pow(1024,8),scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}}},e.PREFIX_NONE={name:"",value:1,scientific:!0},e.BASE_UNITS={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}};var Y=e.BASE_UNITS,j=e.PREFIXES;e.BASE_UNIT_NONE={},e.UNIT_NONE={name:"",base:e.BASE_UNIT_NONE,value:1,offset:0},e.UNITS=[{name:"meter",base:Y.LENGTH,prefixes:j.LONG,value:1,offset:0},{name:"inch",base:Y.LENGTH,prefixes:j.NONE,value:.0254,offset:0},{name:"foot",base:Y.LENGTH,prefixes:j.NONE,value:.3048,offset:0},{name:"yard",base:Y.LENGTH,prefixes:j.NONE,value:.9144,offset:0},{name:"mile",base:Y.LENGTH,prefixes:j.NONE,value:1609.344,offset:0},{name:"link",base:Y.LENGTH,prefixes:j.NONE,value:.201168,offset:0},{name:"rod",base:Y.LENGTH,prefixes:j.NONE,value:5.02921,offset:0},{name:"chain",base:Y.LENGTH,prefixes:j.NONE,value:20.1168,offset:0},{name:"angstrom",base:Y.LENGTH,prefixes:j.NONE,value:1e-10,offset:0},{name:"m",base:Y.LENGTH,prefixes:j.SHORT,value:1,offset:0},{name:"ft",base:Y.LENGTH,prefixes:j.NONE,value:.3048,offset:0},{name:"yd",base:Y.LENGTH,prefixes:j.NONE,value:.9144,offset:0},{name:"mi",base:Y.LENGTH,prefixes:j.NONE,value:1609.344,offset:0},{name:"li",base:Y.LENGTH,prefixes:j.NONE,value:.201168,offset:0},{name:"rd",base:Y.LENGTH,prefixes:j.NONE,value:5.02921,offset:0},{name:"ch",base:Y.LENGTH,prefixes:j.NONE,value:20.1168,offset:0},{name:"mil",base:Y.LENGTH,prefixes:j.NONE,value:254e-7,offset:0},{name:"m2",base:Y.SURFACE,prefixes:j.SHORT,value:1,offset:0},{name:"sqin",base:Y.SURFACE,prefixes:j.NONE,value:64516e-8,offset:0},{name:"sqft",base:Y.SURFACE,prefixes:j.NONE,value:.09290304,offset:0},{name:"sqyd",base:Y.SURFACE,prefixes:j.NONE,value:.83612736,offset:0},{name:"sqmi",base:Y.SURFACE,prefixes:j.NONE,value:2589988.110336,offset:0},{name:"sqrd",base:Y.SURFACE,prefixes:j.NONE,value:25.29295,offset:0},{name:"sqch",base:Y.SURFACE,prefixes:j.NONE,value:404.6873,offset:0},{name:"sqmil",base:Y.SURFACE,prefixes:j.NONE,value:6.4516e-10,offset:0},{name:"m3",base:Y.VOLUME,prefixes:j.SHORT,value:1,offset:0},{name:"L",base:Y.VOLUME,prefixes:j.SHORT,value:.001,offset:0},{name:"litre",base:Y.VOLUME,prefixes:j.LONG,value:.001,offset:0},{name:"cuin",base:Y.VOLUME,prefixes:j.NONE,value:16387064e-12,offset:0},{name:"cuft",base:Y.VOLUME,prefixes:j.NONE,value:.028316846592,offset:0},{name:"cuyd",base:Y.VOLUME,prefixes:j.NONE,value:.764554857984,offset:0},{name:"teaspoon",base:Y.VOLUME,prefixes:j.NONE,value:5e-6,offset:0},{name:"tablespoon",base:Y.VOLUME,prefixes:j.NONE,value:15e-6,offset:0},{name:"minim",base:Y.VOLUME,prefixes:j.NONE,value:6.161152e-8,offset:0},{name:"fluiddram",base:Y.VOLUME,prefixes:j.NONE,value:36966911e-13,offset:0},{name:"fluidounce",base:Y.VOLUME,prefixes:j.NONE,value:2957353e-11,offset:0},{name:"gill",base:Y.VOLUME,prefixes:j.NONE,value:.0001182941,offset:0},{name:"cup",base:Y.VOLUME,prefixes:j.NONE,value:.0002365882,offset:0},{name:"pint",base:Y.VOLUME,prefixes:j.NONE,value:.0004731765,offset:0},{name:"quart",base:Y.VOLUME,prefixes:j.NONE,value:.0009463529,offset:0},{name:"gallon",base:Y.VOLUME,prefixes:j.NONE,value:.003785412,offset:0},{name:"beerbarrel",base:Y.VOLUME,prefixes:j.NONE,value:.1173478,offset:0},{name:"oilbarrel",base:Y.VOLUME,prefixes:j.NONE,value:.1589873,offset:0},{name:"hogshead",base:Y.VOLUME,prefixes:j.NONE,value:.238481,offset:0},{name:"fldr",base:Y.VOLUME,prefixes:j.NONE,value:36966911e-13,offset:0},{name:"floz",base:Y.VOLUME,prefixes:j.NONE,value:2957353e-11,offset:0},{name:"gi",base:Y.VOLUME,prefixes:j.NONE,value:.0001182941,offset:0},{name:"cp",base:Y.VOLUME,prefixes:j.NONE,value:.0002365882,offset:0},{name:"pt",base:Y.VOLUME,prefixes:j.NONE,value:.0004731765,offset:0},{name:"qt",base:Y.VOLUME,prefixes:j.NONE,value:.0009463529,offset:0},{name:"gal",base:Y.VOLUME,prefixes:j.NONE,value:.003785412,offset:0},{name:"bbl",base:Y.VOLUME,prefixes:j.NONE,value:.1173478,offset:0},{name:"obl",base:Y.VOLUME,prefixes:j.NONE,value:.1589873,offset:0},{name:"g",base:Y.MASS,prefixes:j.SHORT,value:.001,offset:0},{name:"gram",base:Y.MASS,prefixes:j.LONG,value:.001,offset:0},{name:"ton",base:Y.MASS,prefixes:j.SHORT,value:907.18474,offset:0},{name:"tonne",base:Y.MASS,prefixes:j.SHORT,value:1e3,offset:0},{name:"grain",base:Y.MASS,prefixes:j.NONE,value:6479891e-11,offset:0},{name:"dram",base:Y.MASS,prefixes:j.NONE,value:.0017718451953125,offset:0},{name:"ounce",base:Y.MASS,prefixes:j.NONE,value:.028349523125,offset:0},{name:"poundmass",base:Y.MASS,prefixes:j.NONE,value:.45359237,offset:0},{name:"hundredweight",base:Y.MASS,prefixes:j.NONE,value:45.359237,offset:0},{name:"stick",base:Y.MASS,prefixes:j.NONE,value:.115,offset:0},{name:"gr",base:Y.MASS,prefixes:j.NONE,value:6479891e-11,offset:0},{name:"dr",base:Y.MASS,prefixes:j.NONE,value:.0017718451953125,offset:0},{name:"oz",base:Y.MASS,prefixes:j.NONE,value:.028349523125,offset:0},{name:"lbm",base:Y.MASS,prefixes:j.NONE,value:.45359237,offset:0},{name:"cwt",base:Y.MASS,prefixes:j.NONE,value:45.359237,offset:0},{name:"s",base:Y.TIME,prefixes:j.SHORT,value:1,offset:0},{name:"min",base:Y.TIME,prefixes:j.NONE,value:60,offset:0},{name:"h",base:Y.TIME,prefixes:j.NONE,value:3600,offset:0},{name:"seconds",base:Y.TIME,prefixes:j.LONG,value:1,offset:0},{name:"second",base:Y.TIME,prefixes:j.LONG,value:1,offset:0},{name:"sec",base:Y.TIME,prefixes:j.LONG,value:1,offset:0},{name:"minutes",base:Y.TIME,prefixes:j.NONE,value:60,offset:0},{name:"minute",base:Y.TIME,prefixes:j.NONE,value:60,offset:0},{name:"hours",base:Y.TIME,prefixes:j.NONE,value:3600,offset:0},{name:"hour",base:Y.TIME,prefixes:j.NONE,value:3600,offset:0},{name:"day",base:Y.TIME,prefixes:j.NONE,value:86400,offset:0},{name:"days",base:Y.TIME,prefixes:j.NONE,value:86400,offset:0},{name:"rad",base:Y.ANGLE,prefixes:j.NONE,value:1,offset:0},{name:"deg",base:Y.ANGLE,prefixes:j.NONE,value:.017453292519943295,offset:0},{name:"grad",base:Y.ANGLE,prefixes:j.NONE,value:.015707963267948967,offset:0},{name:"cycle",base:Y.ANGLE,prefixes:j.NONE,value:6.283185307179586,offset:0},{name:"A",base:Y.CURRENT,prefixes:j.SHORT,value:1,offset:0},{name:"ampere",base:Y.CURRENT,prefixes:j.LONG,value:1,offset:0},{name:"K",base:Y.TEMPERATURE,prefixes:j.NONE,value:1,offset:0},{name:"degC",base:Y.TEMPERATURE,prefixes:j.NONE,value:1,offset:273.15},{name:"degF",base:Y.TEMPERATURE,prefixes:j.NONE,value:1/1.8,offset:459.67},{name:"degR",base:Y.TEMPERATURE,prefixes:j.NONE,value:1/1.8,offset:0},{name:"kelvin",base:Y.TEMPERATURE,prefixes:j.NONE,value:1,offset:0},{name:"celsius",base:Y.TEMPERATURE,prefixes:j.NONE,value:1,offset:273.15},{name:"fahrenheit",base:Y.TEMPERATURE,prefixes:j.NONE,value:1/1.8,offset:459.67},{name:"rankine",base:Y.TEMPERATURE,prefixes:j.NONE,value:1/1.8,offset:0},{name:"mol",base:Y.AMOUNT_OF_SUBSTANCE,prefixes:j.NONE,value:1,offset:0},{name:"mole",base:Y.AMOUNT_OF_SUBSTANCE,prefixes:j.NONE,value:1,offset:0},{name:"cd",base:Y.LUMINOUS_INTENSITY,prefixes:j.NONE,value:1,offset:0},{name:"candela",base:Y.LUMINOUS_INTENSITY,prefixes:j.NONE,value:1,offset:0},{name:"N",base:Y.FORCE,prefixes:j.SHORT,value:1,offset:0},{name:"newton",base:Y.FORCE,prefixes:j.LONG,value:1,offset:0},{name:"lbf",base:Y.FORCE,prefixes:j.NONE,value:4.4482216152605,offset:0},{name:"poundforce",base:Y.FORCE,prefixes:j.NONE,value:4.4482216152605,offset:0},{name:"b",base:Y.BIT,prefixes:j.BINARY_SHORT,value:1,offset:0},{name:"bits",base:Y.BIT,prefixes:j.BINARY_LONG,value:1,offset:0},{name:"B",base:Y.BIT,prefixes:j.BINARY_SHORT,value:8,offset:0},{name:"bytes",base:Y.BIT,prefixes:j.BINARY_LONG,value:8,offset:0}],H.type.Complex=t,t.prototype.copy=function(){return new t(this.re,this.im)},t.prototype.toString=function(){var e="";return e=0===this.im?k.format(this.re):0===this.re?1===this.im?"i":-1===this.im?"-i":k.format(this.im)+"i":this.im>0?1==this.im?k.format(this.re)+" + i":k.format(this.re)+" + "+k.format(this.im)+"i":-1==this.im?k.format(this.re)+" - i":k.format(this.re)+" - "+k.format(Math.abs(this.im))+"i"},t.doc={name:"Complex",category:"type",syntax:["a + bi","a + b * i"],description:"A complex value a + bi, where a is the real part and b is the complex part, and i is the imaginary number defined as sqrt(-1).",examples:["2 + 3i","sqrt(-4)","(1.2 -5i) * 2"],seealso:["abs","arg","conj","im","re"]},H.E=Math.E,H.LN2=Math.LN2,H.LN10=Math.LN10,H.LOG2E=Math.LOG2E,H.LOG10E=Math.LOG10E,H.PI=Math.PI,H.SQRT1_2=Math.SQRT1_2,H.SQRT2=Math.SQRT2,H.I=new t(0,-1),H.pi=H.PI,H.e=H.E,H.i=H.I,H.help=s,H.abs=A,s.doc={name:"help",category:"Utils",syntax:["help(object)"],description:"Display documentation on a function or data type.",examples:['help("sqrt")','help("Complex")'],seealso:[]},H["typeof"]=f,f.doc={name:"typeof",category:"Utils",syntax:["typeof(x)"],description:"Get the type of a variable.",examples:["typeof(3.5)","typeof(2 - 4i)","typeof(45 deg)",'typeof("hello world")'],seealso:[]},H.min=u,u.doc={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)"],description:"Compute the minimum value of a list of values.",examples:["max(2, 3, 4, 1)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["sum","prod","avg","var","std","min","median"]},H.max=c,c.doc={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["sum","prod","avg","var","std","min","median"]},H["in"]=l,l.doc={name:"in",category:"Units",syntax:["x in unit","in(x, unit)"],description:"Change the unit of a value.",examples:["5 inch in cm","3.2kg in g","16 bytes in bits"],seealso:[]},H.sin=m,m.doc={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]},H.atan2=p,p.doc={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]},H.asin=h,h.doc={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(2.3))"],seealso:["sin","acos","asin"]},H.atan=v,v.doc={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(2.3))"],seealso:["tan","acos","asin"]},H.cos=x,x.doc={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]},H.tan=d,d.doc={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]},H.acos=N,N.doc={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","acos","asin"]},H.divide=E,E.doc={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["2 / 3","ans * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]},H.round=y,y.doc={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]},H.fix=O,O.doc={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero.If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]},H.add=g,g.doc={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["2.1 + 3.6","ans - 3.6","3 + 2i",'"hello" + " world"',"3 cm + 2 inch"],seealso:["subtract"]},H.exp=w,w.doc={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["square","multiply","log"]},H.sqrt=T,T.doc={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","multiply"]},H.larger=S,S.doc={name:"larger",category:"Operators",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger y. Returns 1 if x is larger than y, and 0 if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallereq","largereq"]},H.unaryminus=U,U.doc={name:"unaryminus",category:"Operators",syntax:["-x","unaryminus(x)"],description:"Inverse the sign of a value.",examples:["-4.5","-(-5.6)"],seealso:["add","subtract"]},H.smaller=L,L.doc={name:"smaller",category:"Operators",syntax:["x < y","smaller(x, y)"],description:"Check if value a is smaller value b. Returns 1 if x is smaller than y, and 0 if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallereq","largereq"]},H.abs=A,A.doc={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]},H.log=R,R.doc={name:"log",category:"Arithmetic",syntax:["log(x)"],description:"Compute the natural logarithm of a value.",examples:["log(3.5)","a = log(2.4)","exp(a)","log(1000) / log(10)"],seealso:["exp","logb","log10"]},H.pow=I,I.doc={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3 = 8","2*2*2","1 + e ^ (pi * i)"],seealso:["unequal","smaller","larger","smallereq","largereq"]},H.floor=G,G.doc={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]},H.ceil=C,C.doc={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity.If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]},H.multiply=_,_.doc={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["2.1 * 3.6","ans / 3.6","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]},H.subtract=P,P.doc={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["5.3 - 2","ans + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]},H.random=B,B.doc={name:"random",category:"Probability",syntax:["random()"],description:"Return a random number between 0 and 1.",examples:["random()","100 * random()"],seealso:[]}})();