'use strict';var LCMATH=function(){function k(){this.operators=[]}function e(a,b,c,f){this.type=a;this.op=b;this.value=c;this.children=f}function n(a,b,c,f,e,g){this.id=a;this.arity=b;this.lbp=c;this.rbp=f;this.nud=e;this.led=g}function p(a,b,c){this.msg=a;this.from=b;this.to=c?c:this.from}function r(a,b,c){this.implicit_operators="undefined"==typeof a?!1:a;this.unit_mode="undefined"==typeof b?!1:b;this.constants="undefined"==typeof c?[]:c;this.defs=new k;this.defs.define();this.operators=this.defs.operators; this.oph={};for(a=0;a=",80,80);this.infix("<", 80,80);this.infix(">",80,80);this.separator(")");this.separator(k.ARG_SEPARATOR);this.operator("(",n.BINARY,200,200,function(a){var b=a.expression(0);a.advance(")");return b},function(a,b){if(b.type!=e.NAME&&b.type!=e.SUBSCRIPT)throw new p("Function name expected before a parenthesis.",a.tokens[a.token_nr-1].from);var c=[b];if(null==a.current_token||null==a.current_token.op||")"!==a.current_token.op.id)for(;;){c.push(a.expression(0));if(null==a.current_token||null==a.current_token.op||a.current_token.op.id!== k.ARG_SEPARATOR)break;a.advance(k.ARG_SEPARATOR)}a.advance(")");return new e(e.FUNCTION,this,"(",c)});this.separator("]");this.operator("[",n.BINARY,200,70,function(a){var b=[];if(null==a.current_token||null==a.current_token.op||"]"!==a.current_token.op.id)for(;;){b.push(a.expression(0));if(null==a.current_token||null==a.current_token.op||a.current_token.op.id!==k.ARG_SEPARATOR)break;a.advance(k.ARG_SEPARATOR)}a.advance("]");return new e(e.VECTOR,this,null,b)},function(a,b){if(b.type!=e.NAME&&b.type!= e.SUBSCRIPT)throw new p("Name expected before a square bracket.",a.tokens[a.token_nr-1].from);var c=[b];if(null==a.current_token||null==a.current_token.op||"]"!==a.current_token.op.id)for(;;){c.push(a.expression(0));if(null==a.current_token||null==a.current_token.op||a.current_token.op.id!==k.ARG_SEPARATOR)break;a.advance(k.ARG_SEPARATOR)}a.advance("]");return new e(e.SUBSCRIPT,this,"[",c)})};e.UNKNOWN=0;e.NAME=1;e.NUMBER=2;e.OPERATOR=3;e.FUNCTION=4;e.VECTOR=5;e.SUBSCRIPT=6;e.COLORS="#E01010 #0010FF #009000 #FF00FF #00B0B0 #F09000 #800080 #F080A0 #6090F0 #902000 #70A050 #A07060 #5000FF #E06050 #008080 #808000".split(" "); e.prototype.toString=function(){var a="(";switch(this.type){case e.UNKNOWN:a+="UNKNOWN";break;case e.NAME:a+="NAME";break;case e.NUMBER:a+="NUMBER";break;case e.OPERATOR:a+="OPERATOR";break;case e.FUNCTION:a+="FUNCTION";break;case e.VECTOR:a+="VECTOR";break;case e.SUBSCRIPT:a+="SUBSCRIPT"}this.op&&(a+=" '"+this.op.id+"'");this.value&&(a+=" '"+this.value+"'");if(this.children){for(var a=a+" [",b=0;bthis.children.length?d.appendChild(this.mo("lim")):(b=document.createElement("munder"),b.appendChild(this.mo("lim")),h=document.createElement("mrow"),h.appendChild(f.toMathML(a)),h.appendChild(this.mo("\u2192")),h.appendChild(l.toMathML(a)),null!=g&&("plus"==g.value?h.appendChild(this.mo("+")):"minus"==g.value&&h.appendChild(this.mo("-"))),b.appendChild(h), d.appendChild(b)),d.appendChild(c.toMathML(a));else{if("binomial"==b.value){d=document.createElement("mrow");d.appendChild(this.mo("("));l=document.createElement("mtable");for(c=1;c=":"\u2265","<=":"\u2264",inf:"\u221e",minf:"-\u221e",hbar:"\u210f",G:"\ud835\udca2"};n.UNKNOWN=0;n.UNARY=1;n.BINARY=2;n.TERNARY=3;p.prototype.toString=function(){return this.msg+" at "+this.from+" - "+this.to};r.prototype.expression=function(a){var b, c=this.current_token;if(null==c)throw new p("Expected something at the end",this.tokens[this.tokens.length-1].to+1);this.advance();if(null==c.op)b=new e(c.type,null,c.value,null);else{if(null==c.op.nud)throw new p("Unexpected operator '"+c.op.id+"'",c.from);b=c.op.nud(this)}for(;null!=this.current_token&&null!=this.current_token.op&&a=this.tokens.length?this.current_token=null:(this.current_token=this.tokens[this.token_nr],this.token_nr+=1)};r.prototype.addHiddenOperators=function(){for(var a=this.defs.findOperator("*"),b=this.defs.findOperator("`"),c=!1,f=!1,e=0;ee+2&&this.tokens[e+2].type==m.NAME)){var h,k;d.type==m.NAME?(h=d,k=e+1):(k=e+2,h=this.tokens[k]);for(var q=0;qk+1&&"("==this.tokens[k+1].value)for(k="pow sqrt abs exp factorial diff integrate sum product limit binomial matrix ln log log10 mod signum ceiling floor sin cos tan asin acos atan atan2 sinh cosh tanh asinh acosh atanh".split(" "), q=0;q=a)b++,a=this.text.charAt(b);else{if("0"<=a&&"9">=a||(a===k.DECIMAL_SIGN_1||a===k.DECIMAL_SIGN_2)&&"0"<=this.text.charAt(b+1)&&"9">=this.text.charAt(b+1)){c="";if(a!==k.DECIMAL_SIGN_1&&a!==k.DECIMAL_SIGN_2)for(b++,c+=a;;){a=this.text.charAt(b);if("0">a||"9"a||"9"a||"9"=a)}var g=+c.replace(k.DECIMAL_SIGN_1,".").replace(k.DECIMAL_SIGN_2,".");if(isFinite(g)){e.push(new m(m.NUMBER,f,b-1,c,null));continue}else throw new p("syntax error in number",f,b);}for(c=0;c=a||"A"<=a&&"Z">=a){c=a;for(b++;;)if(a=this.text.charAt(b),"a"<=a&&"z">=a||"A"<=a&&"Z">=a||"0"<=a&&"9">=a||"_"===a)c+=a,b++;else break;e.push(new m(m.NAME,f,b-1,c,null))}else throw new p("unrecognized operator",f,b);}return e};m.UNKNOWN=0;m.NAME=1;m.NUMBER=2;m.OPERATOR=3;"use strict";var t=!1;return{Definitions:k,ENode:e,Operator:n,ParseException:p,Parser:r,initEditors:function(){if(!t){t=!0; for(var a=[],b=document.getElementsByClassName("math"),c=0;c