text: /**
   * @module Maths
   * @description Maths stuff
   * @version 1.0
   * @since 1.1
   * @license MIT
   * @author Maximilian Berkmann <maxieberkmann@gmail.com>
   * @copyright Maximilian Berkmann 2016
   * @requires module:essence
   * @requires Misc
   * @type {Module}
   * @exports Maths
   */
  function xor(e,r){return e&&!r||!e&&r}function timesLiteral(e){switch(e){case 1:return"once"
  case 2:return"twice"
  default:return e+" times"}}function rand(e,r,a){return a?Math.floor(Math.random()*(r-e+1)+e):Math.random()*(r-e+1)+e}function randTo(e){return rand(0,e,!0)}function baseRand(e,r,a,t){return parseFloat(rand(e,r,t)).toString(a||10)}function randVar(e,r,a){return rand(Math.min(e,r),Math.max(e,r),a)}function lenRand(e,r){return Math.floor(Math.random()*(r?e+1:e))}function random16(){return(65280*Math.random()+255*Math.random())/65535}function random(e){return e||(e=32),((Math.pow(2,e)-Math.pow(2,e/2))*Math.random()+Math.pow(2,e/2-1)*Math.random())/(Math.pow(2,e)-1)}function randFloatSpread(e){return e*(.5-Math.random())}function randNum(e,r,a,t,n){for(var o=[],c=0;c<(e||10);c++)o[c]=n?conv(rand(r||0,a||100,!t||!0),10,n):rand(r||0,a||100,!t)
  return o}function genNearlySortedArr(e,r,a){var t,n=range(r,1,a).slice(0,e),o=[]
  t=n.getIncrement(0)
  for(var c=0;c<n.length;c++){var s=randTo(t)
  o.push(n[c]),c>0&&0===s?swap(o,c,c-1):c>1&&s===t&&swap(o,c,c-2)}return o}function sumPow2(e,r){return!!isType(e,"Array")&&e.map(function(e){return e*e}).sum().toNDec(r)}function conv(e,r,a,t){return t?parseFloat(e,r||2).toString(a||10):parseInt(e,r||2).toString(a||10)}function negateBin(e,r){for(var a=[],t=0;t<e.length;t++)a[t]=1-parseInt(e[t])
  var n=conv(a.join(""))
  return n++,r?conv(n,10,2).split(""):conv(n,10,2)}function floatingPtBin(e){var r,a,t=1===e[0]?-1:1,n=function(e,r){for(var a=0,t=0;t<r;t++)a+=parseInt(e[t])*Math.pow(2,-t-1)
  return a}
  switch(e.length){case 8:r=(1===e[1]?1:-1)*conv(e.get(2,4)),a=n(e.get(5),3)
  break
  case 16:r=(1===e[1]?1:-1)*conv(e.get(2,6)),a=n(e.get(7),9)
  break
  case 32:r=(1===e[1]?1:-1)*conv(e.get(2,8)),a=n(e.get(9),23)
  break
  case 64:r=(1===e[1]?1:-1)*conv(e.get(2,11)),a=n(e.get(12),52)
  break
  case 128:r=(1===e[1]?1:-1)*conv(e.get(2,14)),a=n(e.get(15),112)
  break
  default:throw new Error("Invalid binary number")}return t*Math.pow(2,r)*a}function min2dec(e){return 50*e/30}function dec2min(e){return 30*e/50}function toS(e){if(e==parseFloat(e))return parseFloat(e)
  var r=2===e.count(":")
  if(e||(e=r?"00:00:00.000":"00:00.000"),isType(e,"String")||(e+=""),e.length>=4&&1==e.indexOf(":"))return toS("0"+e)
  var a=e.split(":")
  if(r){var t,n,o
  return t=parseInt(a[0]),n=parseInt(a[1]),o=parseFloat(a[2]),3600*t+60*n+o.toNDec()}return n=parseInt(a[0]),o=parseFloat(a[1]),60*n+o}function sec2time(e,r){var a=0,t=0,n=e
  return r?(n=(e%60).toNDigits(),a=e>=3600?Math.floor(e/3600):0,t=Math.floor((e-n-3600*a)/60),t=t<=0?"00":t.toNDigits(),a=a<=0?"00":a.toNDigits(),a+":"+t+":"+n.toNDec().toNDigits()):(n=(e%60).toNDigits(),t=Math.floor(e/60).toNDigits(),t<=0?n:t+":"+n.toNDec().toNDigits())}function timeDiff(e,r){var a=2===r.count(":")
  if(e||(e=getTime(!0)),xor(2===e.count(":"),2===r.count(":")))throw new Error("Both times needs to be in the same format")
  return s2t(toS(r)-toS(e||getTime(!0)),a)}function markConv(e,r,a,t){return(e/r*(a||100)).toNDec(t||2)}function nthroot(e,r,a){for(var t=getClosestRoot(e,r),n=0;n<60;n++)t+=(e-Math.pow(t,r))/(Math.pow(t+1,r)-Math.pow(t,r))
  return t.toNDec(a||20)}function log(e,r){return Math.log(e)/Math.log(r||10)}function ln(e){return log(e,Math.E)}function gcd(e,r){return r?gcd(r,e%r):Math.abs(e)}function lcm(e,r){var a=e
  return range(e,1,r).forEach(function(e){a=a*e/gcd(a,e)}),a}function Bin(e,r,a){return C(e,a)*Math.pow(r,a)*Math.pow(1-r,e-a)}function BinCumul(e,r,a){for(var t=[],n=0;n<a;n++)t.push(Bin(e,r,a))
  return t.sum()}function BinCumulLT(e,r,a){for(var t=1-r,n=e-a,o=a+1,c=n+o-1,s=0,i=n;i<c+1;i++)s+=factorial(c)/(factorial(i)*factorial(c-i))*Math.pow(t,i)*Math.pow(1-t,c-i)
  return s}function Norm(e){var r=1/(1+.2316419*Math.abs(e)),a=.3989423*Math.exp(-e*e/2),t=a*r*(.3193815+r*(-.3565638+r*(1.781478+r*(-1.821256+1.330274*r))))
  return t.toNDec(4)}function StdNorm(e,r,a){return Norm((a-e)/r)}function InvNorm(e){var r,a=[2.50662823884,-18.61500062529,41.39119773534,-25.44106049637],t=[-8.4735109309,23.08336743743,-21.06224101826,3.13082909833],n=[.3374754822726147,.9761690190917186,.1607979714918209,.0276438810333863,.0038405729373609,.0003951896511919,321767881768e-16,2.888167364e-7,3.960315187e-7],o=e-.5,c=Math.abs(o),s=o*o
  return c<.42?r=o*(((a[3]*s+a[2])*s+a[1])*s+a[0])/((((t[3]*s+t[2])*s+t[1])*s+t[0])*s+1):(r=Math.log(-Math.log(o>0?1-e:e)),r=n[0]+r*(n[1]+r*(n[2]+r*(n[3]+r*(n[4]+r*(n[5]+r*(n[6]+r*(n[7]+r*n[8]))))))),o<0&&(r=-r)),r}function Po(e,r){return Math.exp(-e)*Math.pow(e,r)/factorial(r).toNDec(4)}function PoCumul(e,r){return Po(e,r)*e}function factorial(e){return e<=1?e:e*factorial(e-1)}function C(e,r){return factorial(e)/(factorial(r)*factorial(e-r))}function Bin2Norm(e,r,a,t){return e*r>5&&e*(1-r)>5?(a+=">="===t?-.5:.5,StdNorm(e*r,Math.sqrt(e*r*(1-r)),a)):null}function Bin2Po(e,r,a){return e>50&&r<.1&&Po(e*r,a)}function Po2Norm(e,r){return e>10&&StdNorm(e,Math.sqrt(r),r)}function erf(e){var r,a=1/(1+.5*Math.abs(e))
  return r=1-a*Math.exp(-e*e-1.26551223+a*(1.00002368+a*(.37409196+a*(.09678418+a*(-.18628806+a*(.27886807+a*(-1.13520398+a*(1.48851587+a*(-.82215223+.17087277*a))))))))),e>0?r:-r}function NormEstimate(e,r,a){var t,n=e*r
  return t=Math.pow(n*(1-r),.5),.5*(1+erf((a-n)/(t*Math.pow(2,.5))))}function clamp(e,r,a){return e<r?r:e>a?a:e}function revClamp(e,r,a){return r<=e&&e<=a?getClosest(e,[r,a]):e}function clampBottom(e,r){return e<r?r:e}function clampTop(e,r){return e>r?r:e}function abcClamp(e){return 32===e?32:revClamp(clamp(e,65,122),90,97)}function mapLinear(e,r,a,t,n){return t+(e-r)*(n-t)/(a-r)}function deg2rad(e){return e*Math.PI/180}function rad2deg(e){return 180*e/Math.PI}function isPrime(e){return primeN(range(1,1,e)).has(e)}function primeN(e){for(var r=e.quickSort(),a=0;a<e.length;a++){e[a]%2===0&&2!=e[a]&&(r[a]="x")
  for(var t=0;t<a;t++)primeCheck(r[t],r[a])&&(r[a]="x")}return r.remove()}function primeCheck(e,r){return e>1&&r>1&&r%e===0&&r!=e}function getClosestRoot(e,r){r||(r=2)
  var a=0,t=0
  if(a=e/2*e/2/2-2<=e?e/2:e/3*e/3<=e?e/3:e/4,Math.pow(a,r)===e)return a
  for(var n=1;n<=r;n++)for(var o=1;o<e;o++)Math.pow(o,n)===e||Math.pow(o,n-1)*o===e?t=o:(Math.pow(o,n)>e||Math.pow(o,n-1)*o>e)&&(t=o-.5)
  if(Math.pow(t,r)<=e)return t
  t=(Math.pow(r,-2)+e/Math.pow(r,4)-e/Math.pow(r,5)+Math.pow(e,r)/Math.pow(r,Math.pow(r,3)+3)+e/Math.pow(r,2))/2,Math.pow(t,r)>e&&(t=(t+a)/2)
  var c=[a,t,(e/t+t)/2,(t+a)/2],s=c.map(function(e){return Math.pow(e,r)})
  return.9956973041*c[s.lookFor(getClosest(e,s))]}function simpleInterest(e,r,a){return e*(1+r*(a||1))}function compoundInterest(e,r,a,t){return t>1?e*Math.pow(1+r/t,(a||1)*t):e*Math.pow(1+r,a||1)}function non0(e){return 0===e?Essence.eps:e}function toFrac(e,r,a){var t=e.toString(),n=t.indexOf(".")
  if(n===-1)return t
  var o=Math.floor(e)||"",c=t.substring(n),s=r||Math.pow(10,c.length-1),i=a?Math.ceil(c*s):Math.round(c*s),u=s,f=gcd(i,u)
  return u/f===1?String(o+i/f):(o&&(o+=" and "),o+String(i/f)+"/"+u/f)}function clearNum(e,r,a){for(var t=(Math.floor(e)+"").length/3,n="",o=0;o<t;o++)n=(e-e%Math.pow(1e3,o))%Math.pow(1e3,o+1)/Math.pow(1e3,o)+" "+n
  return n=n.split(" "),n.pop(),n.join(a?",":" ")+(e%1).toNDec(r||3)}function getStep(e,r,a){return[e,r].getIncrement(a)}function quadraticSolver(e,r,a,t){var n=Math.sqrt(r)-4*e*a
  return 0===n?(-r/(2*e)).toNDec(t):[((-r-Math.sqrt(Math.abs(n)))/(2*e)+(n<0?"i":0)).toNDec(t),(-r+Math.sqrt(Math.abs(n)))/(2*e)+(n<0?"i":0).toNDec(t)]}function eqSolver(formula,res,a,b){a=a||-100,b=b||200
  var r=mkArray(a>0?b-a:b-a+1,2,1)
  if(formula.search(/\^[0-9]/g)>0){var expr="([(]. * ?[)]|\\d + \\.\\d + |\\d + |[a-z] + )",reg=new RegExp(expr+"\\^"+expr)
  formula=formula.replace(reg,"Math.pow($1, $2)")}else formula.search(/e\^/g)>0&&(expr="([(]. * ?[)]|\\d + \\.\\d + |\\d + |[a-z] + )",reg=new RegExp("end\\^"+expr),formula=formula.replace(reg,"Math.exp($1)"))
  Essence.say("Formula now converted to %c"+formula,"info","color: #00f;")
  for(var x=a;x<=b;x++)for(var y=a;y<=b;y++)r[x][y]="("+x+","+y+") "+eval(formula)
  return r.filter(function(e){if(e.split(") ")[1]==res)return e.split(") ")[0]+")"})}function manuEqSolver(eq,max,dim,r){for(var res=mkArray(max+1,dim,1),p=[],x=0;x<res.length;x++)if(2===dim)for(var y=0;y<res.length;y++)res[x][y]=eval(eq),res[x][y]===r&&p.push("x = "+x+", y = "+y)
  else if(3===dim)for(y=0;y<res.length;y++)for(var z=0;z<res.length;z++)res[x][y][z]=eval(eq),res[x][y][z]===r&&p.push("x = "+x+", y = "+y+", z = "+z)
  else res[x]=eval(eq),res[x]===r&&p.push("x = "+x)
  return p}function getNumFromStr(e){return isNon(e)?NaN:parseFloat(e.replace(/[A-Za-z_ ]+/g,""))}function toPixel(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"em":r=16
  break
  case"km":r=3779527.5593333
  break
  case"hm":r=377952.75593333
  break
  case"m":r=3779.5275593333
  break
  case"dm":r=377.95275593333
  break
  case"cm":r=37.795275593333
  break
  case"mm":r=3.7795275593333
  break
  case"ɥm":r=.0037795275593333
  break
  case"nm":r=37795275593333e-19
  break
  case"ex":r=7.156
  break
  case"in":r=96
  break
  case"pt":r=1.3333333333333
  break
  case"pc":r=16
  break
  case"ft":r=1152
  break
  case"twip":r=15
  break
  case"mi":r=6082636.631643
  break
  case"yd":r=3456.043540706}return getNumFromStr(e)*r}function fromPixel(e,r){var a=1
  switch(r){case"em":a=1/16
  break
  case"km":a=1/3779527.5593333
  break
  case"hm":a=1/377952.75593333
  break
  case"m":a=1/3779.5275593333
  break
  case"dm":a=1/377.95275593333
  break
  case"cm":a=1/37.795275593333
  break
  case"mm":a=.2645833333138594
  break
  case"ɥm":a=264.5833333138594
  break
  case"nm":a=264583.3333138594
  break
  case"ex":a=1/7.156
  break
  case"in":a=1/96
  break
  case"pt":a=.7500000000000188
  break
  case"pc":a=1/16
  break
  case"ft":a=1/1152
  break
  case"twip":a=1/15
  break
  case"mi":a=1/6082636.631643
  break
  case"yd":a=1/3456.043540706}return e*a+r}function convLength(e,r){return fromPixel(toPixel(e),r)}function toBit(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"Kb":r=.001
  break
  case"Mb":r=1e-6
  break
  case"Gb":r=1e-9
  break
  case"Tb":r=1e-12
  break
  case"Pb":r=1e-15
  break
  case"Eb":r=1e-18
  break
  case"Zb":r=1e-21
  break
  case"Yb":r=1e-24
  break
  case"o":r=8
  break
  case"Ko":r=.008
  break
  case"Mo":r=8e-6
  break
  case"Go":r=8e-9
  break
  case"To":r=8e-12
  break
  case"Po":r=8e-15
  break
  case"Eo":r=8e-18
  break
  case"Zo":r=8e-21
  break
  case"Yo":r=8e-24
  break
  case"Kio":r=8*Math.pow(2,-10)
  break
  case"Mio":r=8*Math.pow(2,-20)
  break
  case"Gio":r=8*Math.pow(2,-30)
  break
  case"Tio":r=8*Math.pow(2,-40)
  break
  case"Pio":r=8*Math.pow(2,-50)
  break
  case"Eio":r=8*Math.pow(2,-60)
  break
  case"Zio":r=8*Math.pow(2,-70)
  break
  case"Yio":r=8*Math.pow(2,-80)
  break
  case"Kib":r=Math.pow(2,-10)
  break
  case"Mib":r=Math.pow(2,-20)
  break
  case"Gib":r=Math.pow(2,-30)
  break
  case"Tib":r=Math.pow(2,-40)
  break
  case"Pib":r=Math.pow(2,-50)
  break
  case"Eib":r=Math.pow(2,-60)
  break
  case"Zib":r=Math.pow(2,-70)
  break
  case"Yib":r=Math.pow(2,-80)
  break
  default:r=1}return getNumFromStr(e)*r}function fromBit(e,r){var a=1
  switch(r){case"Kb":a=1e3
  break
  case"Mb":a=1e6
  break
  case"Gb":a=1e9
  break
  case"Tb":a=1e12
  break
  case"Pb":a=1e15
  break
  case"Eb":a=1e18
  break
  case"Zb":a=1e21
  break
  case"Yb":a=1e24
  break
  case"o":a=1/8
  break
  case"Ko":a=125
  break
  case"Mo":a=125e3
  break
  case"Go":a=125e6
  break
  case"To":a=125e9
  break
  case"Po":a=125e12
  break
  case"Eo":a=125e15
  break
  case"Zo":a=125e18
  break
  case"Yo":a=1e24/8
  break
  case"Kio":a=Math.pow(2,10)/8
  break
  case"Mio":a=Math.pow(2,20)/8
  break
  case"Gio":a=Math.pow(2,30)/8
  break
  case"Tio":a=Math.pow(2,40)/8
  break
  case"Pio":a=Math.pow(2,50)/8
  break
  case"Eio":a=Math.pow(2,60)/8
  break
  case"Zio":a=Math.pow(2,70)/8
  break
  case"Yio":a=Math.pow(2,80)/8
  break
  case"Kib":a=Math.pow(2,10)
  break
  case"Mib":a=Math.pow(2,20)
  break
  case"Gib":a=Math.pow(2,30)
  break
  case"Tib":a=Math.pow(2,40)
  break
  case"Pib":a=Math.pow(2,50)
  break
  case"Eib":a=Math.pow(2,60)
  break
  case"Zib":a=Math.pow(2,70)
  break
  case"Yib":a=Math.pow(2,80)
  break
  default:a=1}return e*a+r}function convSize(e,r){return fromBit(toBit(e),r)}function toSqMetre(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"ha":r=1e4
  break
  case"a":r=100
  break
  case"km^2":r=1e6
  break
  case"dm^2":r=.01
  break
  case"cm^2":r=1e-4
  break
  case"mm^2":r=1e-6
  break
  case"mi^2":r=2589988.11
  break
  case"acre":r=4046856422
  break
  case"yd^2":r=.83612736
  break
  case"ft^2":r=.09290304
  break
  case"in^2":r=64516e-8}return getNumFromStr(e)*r}function fromSqMetre(e,r){var a=1
  switch(r){case"ha":a=1e-4
  break
  case"a":a=.01
  break
  case"km^2":a=1e-6
  break
  case"dm^2":a=100
  break
  case"cm^2":a=1e4
  break
  case"mm^2":a=1e6
  break
  case"mi^2":a=1/2589988.11
  break
  case"acre":a=1/4046856422
  break
  case"yd^2":a=1/.83612736
  break
  case"ft^2":a=1/.09290304
  break
  case"in^2":a=1/64516e-8}return e*a+r}function convArea(e,r){return fromPixel(toPixel(e),r)}function toLpkm(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"mipgalUK":r=2.352392798
  break
  case"mipgal":r=2.352392798
  break
  case"mipgalUS":r=2.825364894}return getNumFromStr(e)*r}function fromLpkm(e,r){var a=1
  switch(r){case"mipgalUK":a=1/2.352392798
  break
  case"mipgal":a=1/2.352392798
  break
  case"mipgalUS":a=1/2.825364894}return e*a+r}function convFuel(e,r){return fromLpkm(toLpkm(e),r)}function toW(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"btuph":r=.2930710703
  break
  case"hp":r=735.4990028
  break
  case"kW":r=1e3
  break
  case"tonpref":r=3516.852842}return getNumFromStr(e)*r}function fromW(e,r){var a=1
  switch(r){case"btuph":a=1/.2930710703
  break
  case"hp":a=1/735.4990028
  break
  case"kW":a=.001
  break
  case"tonpref":a=1/3516.852842}return e*a+r}function convPower(e,r){return fromW(toW(e),r)}function toBar(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"atm":r=1.01325
  break
  case"mbar":r=.001
  break
  case"inHg":r=.03386388158
  break
  case"mmHg":r=.001333223684
  break
  case"MPa":r=10
  break
  case"KPa":r=.01
  break
  case"Pa":r=1e-5
  break
  case"psf":r=.0004788025898
  break
  case"psi":r=.06894757293}return getNumFromStr(e)*r}function fromBar(e,r){var a=1
  switch(r){case"atm":a=1/1.01325
  break
  case"mbar":a=1e3
  break
  case"inHg":a=1/.03386388158
  break
  case"mmHg":a=1/.001333223684
  break
  case"MPa":a=.1
  break
  case"KPa":a=100
  break
  case"Pa":a=1e5
  break
  case"psf":a=2088.5434233296623
  break
  case"psi":a=1/.06894757293}return e*a+r}function convPressure(e,r){return fromBar(toBar(e),r)}function toMps(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"kmph":r=.277777778
  break
  case"mph":r=.44704
  break
  case"ftpmin":r=.00508
  break
  case"ftps":r=.3048
  break
  case"knot":r=.5144444444
  break
  case"c(v)":r=299792458
  break
  case"Mach(a)":r=343.2
  break
  case"Mach(width)":r=1484}return getNumFromStr(e)*r}function fromMps(e,r){var a=1
  switch(r){case"kmph":a=1/.277777778
  break
  case"mph":a=1/.44704
  break
  case"ftpmin":a=1/.00508
  break
  case"ftps":a=1/.3048
  break
  case"knot":a=1/.5144444444
  break
  case"c(v)":a=1/299792458
  break
  case"Mach(a)":a=1/343.2
  break
  case"Mach(width)":a=1/1484}return e*a+r}function convSpeed(e,r){return fromMps(toMps(e),r)}function toCelsius(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"°F":r=-17.22222222
  break
  case"K":r=-272.15
  break
  case"°Ra":r=-272.5944444}return getNumFromStr(e)*r}function fromCelsius(e,r){var a=1
  switch(r){case"°F":a=1/-17.22222222
  break
  case"K":a=1/-272.15
  break
  case"°Ra":a=1/-272.5944444}return e*a+r}function convTemperature(e,r){return fromCelsius(toCelsius(e),r)}function toCbMetre(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"L":r=.001
  break
  case"dm^3":r=.001
  break
  case"dL":r=1e-4
  break
  case"cL":r=1e-5
  break
  case"mL":r=1e-6
  break
  case"cm^3":r=1e-6
  break
  case"mm^3":r=1e-9
  break
  case"tblspn":r=15e-6
  break
  case"tspn":r=5e-6
  break
  case"yd^3":r=.764554858
  break
  case"ft^3":r=.02831684659
  break
  case"in^3":r=16387064e-12
  break
  case"bushel":r=.03523907017
  break
  case"barrel":r=.16365924
  break
  case"gal":r=.00454609
  break
  case"fl oz":r=284130625e-13
  break
  case"pint":r=.00056826125
  break
  case"quart":r=.0011365225
  break
  case"cup":r=.0002365882365}return getNumFromStr(e)*r}function fromCbMetre(e,r){var a=1
  switch(r){case"L":a=1e3
  break
  case"dm^3":a=1e3
  break
  case"dL":a=1e4
  break
  case"cL":a=1e5
  break
  case"mL":a=1e6
  break
  case"cm^3":a=1e6
  break
  case"mm^3":a=1e9
  break
  case"tblspn":a=1/15e-6
  break
  case"tspn":a=1/5e-6
  break
  case"yd^3":a=1/.764554858
  break
  case"ft^3":a=1/.02831684659
  break
  case"in^3":a=1/16387064e-12
  break
  case"bushel":a=1/.03523907017
  break
  case"barrel":a=1/.16365924
  break
  case"gal":a=1/.00454609
  break
  case"fl oz":a=1/284130625e-13
  break
  case"pint":a=1/.00056826125
  break
  case"quart":a=1/.0011365225
  break
  case"cup":a=1/.0002365882365}return e*a+r}function convVolume(e,r){return fromCbMetre(toCbMetre(e),r)}function toGram(e){var r=1
  switch(e.substring(String(getNumFromStr(e)).length,e.length).remove()){case"kg":r=1e3
  break
  case"mg":r=.001
  break
  case"lb":r=453.59237
  break
  case"oz":r=28.34952312
  break
  case"ton":r=1e6
  break
  case"st":r=6350.29318}return getNumFromStr(e)*r}function fromGram(e,r){var a=1
  switch(r){case"kg":a=.001
  break
  case"mg":a=1e3
  break
  case"lb":a=1/453.59237
  break
  case"oz":a=1/28.34952312
  break
  case"ton":a=1e-6
  break
  case"st":a=1/6350.29318}return e*a+r}function convWeight(e,r){return fromGram(toGram(e),r)}function range(e,r,a,t){var n=[],o=0
  if(e&&!r&&!a&&0!=a)return range(0,1,e)
  if(e&&r&&!a&&0!=a)return range(0,r,e)
  if(e||(e=0),r||(r=1),a||(a=100),r>0)for(var c=e;c<=a;c+=r)n[o++]=Number(c).toNDec(t)
  else for(c=e;c>=a;c-=r)n[o++]=Number(c).toNDec(t)
  return n}function range2base(e,r,a,t){var n=[],o=0
  if(r>0)for(var c=e;c<=a;c+=r)n[o++]=conv(c,10,t)
  else for(c=e;c>=a;c+=r)n[o++]=conv(c,10,t)
  return n}function mixedRange(e,r,a,t){var n=range(e,r,a)
  return t?n.shuffle():n.rand()}function fisherYatesShuffle(e){for(var r=e.length;r>0;)e.hasOwnProperty(r)&&swap(e,r,Math.floor(Math.random()*r--))
  return e}function vectorProd(e,r){var a=[],t=[0,0,0]
  return a[0]=["i","j","k"],a[1]=[e.x,e.y,e.z],a.last([r.x,r.y,r.z]),t[0]=e.y*r.z-e.z*r.y,t[1]=e.x*r.z-e.z*r.x,t.last(e.x*r.y-e.y*r.x),t[0]+"i + "+t[1]+"j + "+t.last()+"k"}function vector2Point(e){return new Pt(e.x,e.y,e.z)}function vector2PointForm(e){return"("+e.split("i")[0].clean()+", "+e.split("i")[1].split("j")[0].slice(1,e.split("i")[1].split("j")[0].length).clean()+", "+e.split("i")[1].split("j")[1].split("k")[0].clean()+")"}function scalarProd(e,r){return e.x*r.x+e.y*r.y+e.z*r.z}function union(e,r,a,t){return t?rmDuplicates(e.concat(r,a)).quickSort():rmDuplicates(e.concat(r,a))}function intersection(e,r,a,t){var n=[]
  e=e.quickSort(),r=r.quickSort(),a=!!a&&a.quickSort()
  for(var o in e)e.hasOwnProperty(o)&&(r.has(e[o])&&isNon(a)?n.push(e[o]):r.has(e[o])&&a.has(e[o])&&n.push(e[o]))
  return t?rmDuplicates(n).quickSort():rmDuplicates(n)}function complement(e,r,a,t){var n=[]
  e=e.quickSort(),r=r.quickSort(),a=!!a&&a.quickSort()
  for(var o in e)e.hasOwnProperty(o)&&(r.indexOf(e[o])===-1&&isNon(a)?n.push(e[o]):r.indexOf(e[o])===-1&&a.indexOf(e[o])===-1&&n.push(e[o]))
  return t?rmDuplicates(n).quickSort():rmDuplicates(n)}function symDif(e,r,a,t){var n=[]
  e=e.quickSort(),r=r.quickSort(),a=!!a&&a.quickSortort()
  for(var o in e)e.hasOwnProperty(o)&&(r.indexOf(e[o])===-1&&isNon(a)?n.push(e[o]):r.indexOf(e[o])===-1&&a.indexOf(e[o])===-1&&n.push(e[o]))
  for(o in r)r.hasOwnProperty(o)&&(e.indexOf(r[o])===-1&&isNon(a)?n.push(r[o]):e.indexOf(r[o])===-1&&a.indexOf(r[o])===-1&&n.push(r[o]))
  if(a)for(o in a)a.hasOwnProperty(o)&&e.indexOf(a[o])===-1&&r.indexOf(a[o])===-1&&n.push(a[o])
  return t?rmDuplicates(n).quickSort():rmDuplicates(n)}function bitStr(e,r){var a=[]
  for(var t in e)e.hasOwnProperty(t)&&(a[t]=e[t]===r[t]?1:0)
  return a}function And(e,r,a,t){toSameLength(e,r,a||null)
  var n=t?new Array(e.length):e[0]&&r[0]
  for(var o in e)e.hasOwnProperty(o)&&(t?n[o]=e[o]&&r[o]:n=n&&e[o]&&r[o])
  return n}function Or(e,r,a,t){toSameLength(e,r,a||null)
  var n=t?new Array(e.length):e[0]||r[0]
  for(var o in e)e.hasOwnProperty(o)&&(t?n[o]=e[o]||r[o]:n=n||e[o]||r[o])
  return n}function Xor(e,r,a,t){toSameLength(e,r,a||null)
  var n=t?new Array(e.length):xor(e[0],r[0])
  for(var o in e)e.hasOwnProperty(o)&&(t?n[o]=xor(e[o],r[o]):n=xor(n,xor(e[o],r[o])))
  return n}function Imply(e,r,a,t){toSameLength(e,r,a||null)
  var n=t?new Array(e.length):!e[0]||r[0]
  for(var o in e)e.hasOwnProperty(o)&&(t?n[o]=!e[o]||r[o]:n=!n||!e[o]||r[o])
  return n}function manhattanDist(e,r){return Math.abs(Math.abs(e[0]-r[0])+Math.abs(e[1]-r[1]))}function euclidianDist(e,r){return Math.sqrt(Math.pow(e[0]-r[0],2)+Math.pow(e[1]-r[1],2))}function diagDist(e,r){return Math.max(Math.abs(e[0]-r[0]),Math.abs(e[1]-r[1]))}function h(e,r,a){for(var t=new Array(e.length),n=0;n<e.length;n++){t[n]=new Array(e[n].length)
  for(var o=0;o<e[n].length;o++)t[n][o]=a([n,o],lookfor(e[n][o],r))||euclidianDist([n,o],lookfor(e[n][o],r))}return Essence.say(console.table(t)),t.sum2d()}function equivalent(e,r){return Math.round(e)===Math.round(r)||Math.floor(e)===Math.floor(r)||Math.ceil(e)===Math.floor(r)||Math.floor(e)===Math.ceil(r)}function approxEqual(e,r,a){return a||(a=Essence.eps),e>=r-a&&e<=r+a||r>=e-a&&r<=e+a}function P(e,r){var a=[]
  return e.map(function(e){a.push(!!r.replace(/x/gm,e))}),a}function forAll(e,r){for(var a=!0,t=0;t<e.length;t++)if(a&=r.replace(/x/gm,e[t]),!a)return!1
  return!!a}function forSome(e,r){for(var a=r.replace(/x/gm,e[0]),t=1;t<e.length;t++)if(a&=r.replace(/x/gm,e[t]))return!0
  return!1}function forOne(e,r){return 1===P(e,r).count(!0)}function readCoord(e,r){var a=e.slice(1,e.length-1).split(", ")
  return r?[parseInt(a[0]),parseInt(a[1])]:a}function modRange(e,r,a){var t=e%(a+1)
  return t+(t<r)?r+t:0}function abcModulus(e){var r=e%123
  return 90<r&&r<97?r+abcModulus(Math.abs(getClosest(r,[90,97])-r)):r+(r<65&&32!=r?65+r:0)}function bruteForceNum(min,cond,max){for(var x=min;x<=max;x++)if(eval(cond.replace(RegExpify("x"),x+"")))return x
  return!1}function bruteForceFloat(min,cond,max,precision){for(var x=min;x<=max;x+=precision||.001)if(eval(cond.replace(RegExpify("x"),x+"")))return x
  return!1}function doubleBruteForceNum(min,cond,max){for(var x=min;x<=max;x++)for(var y=min;y<=max;y++)if(eval(cond.replace(RegExpify("x"),x+"").replace(RegExpify("y"),y+"")))return[x,y]
  return!1}function doubleBruteForceFloat(min,cond,max,precision){precision||(precision=.001)
  for(var x=min;x<=max;x+=precision)for(var y=min;y<=max;y+=precision)if(eval(cond.replace(RegExpify("x"),x+"").replace(RegExpify("y"),y+"")))return[x,y]
  return!1}function isCloser(e,r,a){return Math.abs(e-r)<Math.abs(e-a)}function getClosest(e,r){for(var a=r[0],t=1;t<r.length;t++)a=isCloser(e,a,r[t])?a:r[t]
  return a}function Equation(formula){return this.formula=formula.normal()||"y=x",this.leftSide=this.formula.split("=")[0],this.rightSide=this.formula.split("=")[1],this.compute=function(data){return eval(this.rightSide.multiReplace([[/x/g,data.x||0],[/y/g,data.y||0],[/z/g,data.z||0],[/pi/gi,Math.PI],[/e/gi,Math.E],[/sqrt(2)/gi,Math.SQRT2],[/(pow|max|min)\((.*?),(.*?)\)/,"Math.$1($2, $3)"],[/(sqrt|cbrt|cos|sin|tan|acos|asin|cosh|sinh|tanh|acosh|asinh|atanh|exp|abs|e\^)\((.*?)\)/,"Math.$1($2)"],[/(ln|log|nthroot|clampTop|clampBottom)\((.*?),(.*?)\)/,"$1($2, $3)"],[/(clamp)\((.*?),(.*?),(.*?)\)/,"$1($2, $3, $4)"]]))},this.toString=function(){return"Equation("+this.formula+")"},this}function binaryCases(e){var r=parseInt("1".repeat(e)),a=[],t=0
  do a.push(conv(t++,10,2))
  while(t<=conv(r))
  return a}function truthTable(exp){for(var ascii=asciiTable("a-z"),vars=[],rows,res=[],i=0;i<ascii.length;i++)exp.has(ascii[i])&&vars.push(ascii[i])
  for(Essence.say("variables: "+vars.toStr(!0),"info"),rows=binaryCases(vars.length),i=0;i<rows.length;i++){for(var cexp=exp,j=0;j<vars.length;j++)cexp=cexp.multiReplace([[vars[j],rows[i][j]]])
  Essence.say("current exp: "+cexp,"info"),res.push(eval(cexp))}return[vars,rows,res]}function getDNF(e){var r=(truthTable(e),"")
  return r}function getCNF(e){var r=(truthTable(e),"")
  return r}function timeCI(e,r,a){return[e+InvNorm(r/200)*a/Math.sqrt(r),e-InvNorm(r/200)*a/Math.sqrt(r)]}function sampleMean(e){return Math.sqrt(sumPow2(e)/e.length-e.mean())}function confidenceInterval(e,r,a,t){var n=InvNorm(r||.95)
  return isType(e,"Array")&&(t=e.stddev(),a=e.length,e=sampleMean(e)),[e-n*t/Math.sqrt(a),e+n*t/Math.sqrt(a)]}function Fibonacci(e){return e<=1?e:Fibonacci(e-1)+Fibonacci(e-2)}function revPolishCalc(exp){var values=new Stack,chars=exp.split(" "),res=0,nbOfNums=0,signs=["+","-","*","/","%",">>","<<",">>>","&","|","^"]
  if(1===chars.length)return parseFloat(chars[0])
  if(2===chars.length)throw new InvalidExpressionError("Unsufficient amount of values!")
  for(var i=0;i<chars.length;i++)if(isNaN(chars[i])){if(!signs.has(chars[i]))throw new InvalidExpressionError("WTF is the "+chars[i]+" character doing here?")
  var num0=values.pop(),num1=values.pop()
  res=eval(num1+chars[i]+num0),values.push(res),nbOfNums=0}else{if(values.push(parseFloat(chars[i])),!(nbOfNums<=2))throw new InvalidExpressionError("Too many numbers without operations!!")
  nbOfNums++}return res}var Maths=new Module("Maths","Maths stuff",["Misc"]),s2t=sec2time
  