text: var AutoSuggestIdCounter,autoSuggestLists,autoSuggestObjects,initstack=[],loadedscripts=[],callbackstack={},imathasAssess=function($){var LivePreviews,MQsyntaxtimer,greekletters,onlyAscii,allParams={};function clearparams(e){var t;for(t in e)delete allParams[t]}function toMQwVars(e,t){var a=t.substr(2).split(/-/)[0],r=allParams[a].qtype;return"numfunc"===r&&(e=AMnumfuncPrepVar(a,e)[1]),AMtoMQ(e)}function fromMQwText(e,t){return e=(e=MQtoAM(e)).replace(/\(text\((.*?)\)\)/g,"($1)").replace(/text\((.*?)\)/g," $1 ")}function init(e,t,a){var r,i,n,s,l,c,o;for(r in MQeditor.setConfig({toMQ:toMQwVars,fromMQ:fromMQwText}),0==$("#arialive").length&&$("body").append($("<p>",{id:"arialive","aria-live":"assertive","aria-atomic":"true",class:"sr-only"})),e)if(!isNaN(parseInt(r))){if(allParams[r]=e[r],(i=e[r]).helper&&i.qtype.match(/^(calc|numfunc|string|interval|matrix)/)&&(s=document.getElementById("qn"+r),l=i.qtype,i.calcformat&&(l+=","+i.calcformat),i.displayformat&&(l+=","+i.displayformat),i.matrixsize?(l+=",matrixsized",$("input[id^=qn"+r+"-]").attr("data-mq",l)):s.setAttribute("data-mq",l),i.vars&&s.setAttribute("data-mq-vars",i.vars),t&&(i.matrixsize?MQeditor.toggleMQAll("input[id^=qn"+r+"-]",!0,!0):MQeditor.toggleMQ(s,!0,!0),$("#pbtn"+r).hide())),i.preview?(document.getElementById("pbtn"+r).addEventListener("click",function(e){return function(){showPreview(e)}}(r)),1!=i.preview||i.qtype.match(/matrix/)||(LivePreviews.hasOwnProperty(r)&&delete LivePreviews[r],setupLivePreview(r,t),document.getElementById("qn"+r).addEventListener("keyup",updateLivePreview),t&&showSyntaxCheckMQ(r))):i.matrixsize?$("input[id^=qn"+r+"-]").on("input",function(e){return function(){syntaxCheckMQ(e)}}(r)):document.getElementById("qn"+r)&&document.getElementById("qn"+r).addEventListener("keyup",function(e){return function(){syntaxCheckMQ(e)}}(r)),"debit"===i.format?document.getElementById("qn"+r).addEventListener("keyup",editdebit):"credit"===i.format?(document.getElementById("qn"+r).addEventListener("keyup",editcredit),initcreditboxes()):"normslider"===i.format&&imathasDraw.addnormslider(r,!0),i.autosuggest&&(!autoSuggestLists.hasOwnProperty(i.autosuggest)&&i.hasOwnProperty(i.autosuggest)&&(autoSuggestLists[i.autosuggest]=i[i.autosuggest]),autoSuggestLists.hasOwnProperty(i.autosuggest)&&(autoSuggestObjects[r]=new AutoSuggest(document.getElementById("qn"+r),autoSuggestLists[i.autosuggest]))),i.tip)if(s=document.getElementById("qn"+r+"-0"))for(n=0;document.getElementById("qn"+r+"-"+n);)setupTips("qn"+r+"-"+n,i.tip,i.longtip),n++;else setupTips("qn"+r,i.tip,i.longtip);"draw"===i.qtype&&setupDraw(r),"file"===i.qtype&&initFileAlt(document.getElementById("qn"+r)),"multans"===i.qtype&&initMultAns(r),i.usetinymce&&(document.getElementById("qn"+r).disabled&&!document.getElementById("tinyprev"+r)?(c=$("#qn"+r).val(),(o=$("<div>",{id:"tinyprev"+r,class:"introtext"})).html(c),$("#qn"+r).hide().after(o)):initeditor("selector","#qn"+r+".mceEditor",null,!1,function(e){e.on("blur",function(e){tinymce.triggerSave(),jQuery(e.target.targetElm).triggerHandler("change")}).on("focus",function(e){jQuery(e.target.targetElm).triggerHandler("focus")})})),"essay"==i.qtype&&$("#qnwrap"+r+".introtext img").on("click",rotateimg),initEnterHandler(r)}if(initDupRubrics(),initShowAnswer2(),a&&setScoreMarkers(a),initqsclickchange(),initClearScoreMarkers(),e.scripts){!function e(t,a){var r;if("code"==t[a][0]){try{window.eval(t[a][1])}catch(e){console.log("Error executing question script:"+t[a][1])}t.length>a+1&&e(t,a+1)}else-1==loadedscripts.indexOf(t[a][1])?jQuery.getScript(t[a][1]).always(function(){loadedscripts.push(t[a][1]),t.length>a+1&&e(t,a+1)}):t.length>a+1&&e(t,a+1);if(t.length<=a+1){for(r=0;r<initstack.length;r++)initstack[r]();initstack.length=0}}(e.scripts,0)}}function setupTips(e,t,a){var r,i=document.getElementById(e);i&&(i.setAttribute("data-tip",t),r=e.substr(2).split(/-/)[0],document.getElementById("tips"+r)||$("body").append($("<div>",{class:"hidden",id:"tips"+r}).html(a)),i.setAttribute("aria-describedby","tips"+r),i.addEventListener("focus",function(){showehdd(e,t,r)}),i.addEventListener("blur",hideeh),i.addEventListener("click",function(){reshrinkeh(e)}))}function clearTips(){hideAllEhTips()}function initqsclickchange(){$("input[id^=qs][value=spec]").each(function(e,t){$(t).siblings("input[type=text]").off("keyup.qsclickchange").on("keyup.qsclickchange",function(e){8!=e.keyCode&&46!=e.keyCode&&$(t).prop("checked",!0)})})}function clearScoreMarkers(e){var t,a,r=e.currentTarget;null!==(t=r.className.match(/(ansgrn|ansred|ansyel|ansorg)/))?($(r).removeClass(t[0]),$(r).nextAll(".scoremarker.sr-only").first().remove(),"ansorg"==t[0]&&$(r).nextAll(".scoremarker").first().remove(),"select"==r.tagName.toLowerCase()&&$(r).nextAll("svg.scoremarker").first().remove(),"hidden"==r.type&&$("#mqinput-"+r.id).removeClass(t[0])):0<(a=$(r).closest("[id^=qnwrap]")).length&&null!==(t=a[0].className.match(/(ansgrn|ansred|ansyel|ansorg)/))&&(a.removeClass(t[0]),a.find(".scoremarker").remove())}function setScoreMarkers(e){var t,a,r,i='<svg class="scoremarker" viewBox="0 0 24 24" width="16" height="16" stroke="green" stroke-width="3" fill="none" role="img" aria-hidden=true>';i+='<polyline points="20 6 9 17 4 12"></polyline></svg>',i+='<span class="sr-only scoremarker">'+_("Correct")+"</span>",t='<svg class="scoremarker" viewBox="0 0 24 24" width="16" height="16" stroke="rgb(255,187,0)" stroke-width="3" fill="none" role="img" aria-hidden=true>',t+='<path d="M 5.3,10.6 9,14.2 18.5,4.6 21.4,7.4 9,19.8 2.7,13.5 z" /></svg>',t+='<span class="sr-only scoremarker">'+_("Partially correct")+"</span>",a='<svg class="scoremarker" viewBox="0 0 24 24" width="16" height="16" stroke="rgb(153,0,0)" stroke-width="3" fill="none" role="img" aria-hidden=true>',a+='<path d="M18 6 L6 18 M6 6 L18 18" /></svg>',a+='<span class="sr-only scoremarker">'+_("Incorrect")+"</span>",r='<svg class="scoremarker" viewBox="0 0 24 24" width="16" height="16" stroke="rgb(255,85,0)" stroke-width="3" fill="none" role="img" aria-hidden=true>',r+='<path d="M18 6 L6 18 M6 6 L18 18" /></svg>',r+='<span class="sr-only scoremarker">'+_("Incorrect, wrong format")+"</span>",$(e).find(".scoremarker").remove(),$(e).find("div.ansgrn,table.ansgrn").append(i),$(e).find("div.ansyel,table.ansyel").append(t),$(e).find("div.ansred,table.ansred").append(a),$(e).find("div.ansorg,table.ansorg").append(r),$(e).find("select.ansgrn").after(i),$(e).find("select.ansyel").after(t),$(e).find("select.ansred").after(a),$(e).find("select.ansorg").after(r),$(e).find("span[id^=mqinput-].ansgrn,input[type=text].ansgrn").after('<span class="scoremarker sr-only">'+_("Correct")+"</span>"),$(e).find("span[id^=mqinput-].ansyel,input[type=text].ansyel").after('<span class="scoremarker sr-only">'+_("Partially correct")+"</span>"),$(e).find("span[id^=mqinput-].ansred,input[type=text].ansred").after('<span class="scoremarker sr-only">'+_("Incorrect")+"</span>"),$(e).find("span[id^=mqinput-].ansorg,input[type=text].ansorg").after('<span class="scoremarker sr-only">'+_("Incorrect, wrong format")+"</span>"),$(e).find("span[id^=mqinput-].ansorg,input[type=text].ansorg").after($("<span>",{role:"button",class:"scoremarker",tabindex:0,"aria-label":_("Incorrect, wrong format"),"data-tip":_("Your answer is equivalent to the correct answer, but is not simplified or is in the wrong format"),"data-tooltipclass":"dropdown-pane tooltip-pane"}).on("mouseover focus",function(){tipshow(this)}).on("mouseleave blur",tipout).html('<svg style="vertical-align:middle;margin-left:3px;" viewBox="0 0 24 24" width="18" height="18" stroke="rgb(255,85,0)" stroke-width="2" stroke-linecap="round" fill="none" role="img" aria-hidden=true><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12" y2="16"></line></svg>'))}function initClearScoreMarkers(){$("input[id^=qn]").off("input.clearmarkers").on("input.clearmarkers",clearScoreMarkers),$("input[id^=qs],select[id^=qn]").off("change.clearmarkers").on("change.clearmarkers",clearScoreMarkers)}function initEnterHandler(e){$("input[type=text][name=qn"+e+"]").off("keydown.enterhandler").on("keydown.enterhandler",function(e){if(13==e.which){var t=$(this).closest(".questionwrap").find(".submitbtnwrap .primary");0<t.length&&e.preventDefault(),t.is(":disabled")||t.trigger("click")}})}function handleMQenter(e){var t=$("#"+e).closest(".questionwrap").find(".submitbtnwrap .primary");t.is(":disabled")||t.trigger("click")}function initDupRubrics(){$(".rubriclink").each(function(e,t){var a,r,i;$(t).removeClass("rubriclink"),-1!==(a=t.id.substring(16)).indexOf("-")&&(a=1e3*(1*(r=a.split("-"))[0]+1)+1*r[1]),0<(i=$("#mqinput-qn"+a+",input[type=text]#qn"+a+",select#qn"+a+",textarea#qn"+a+",div.introtext#qnwrap"+a)).length&&(i.after(t),$(t).show())})}function initShowAnswer2(){$("input.sabtn + span.hidden, input.sabtn + div.hidden").each(function(e,t){var a,r,i,n,s,l,c=t.id.substring(3),o=c;if(a=-1!==o.indexOf("-")?(o=1e3*(1*(r=o.split("-"))[0]+1)+1*r[1],_("Question ")+(1*r[0]+1)+_(" Part ")+(1*r[1]+1)):_("Question ")+(1*o+1),i=$("<span>",{class:"keywrap"}).append($("<button>",{type:"button","aria-controls":"ans"+c,"aria-expanded":"false",class:"keybtn","aria-label":_("View Key for ")+a,title:_("View Key")}).on("click",function(e){var t="true"==e.currentTarget.getAttribute("aria-expanded");e.currentTarget.setAttribute("aria-expanded",t?"false":"true"),$("#ans"+c).toggleClass("hidden",t)}).html('<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"></path></svg>')),0<$(t).closest(".autoshowans").length){if(0<(n=$("#qnwrap"+o)).length)return $(t).prev(".sabtn").remove(),i.append($(t)).addClass("inwrap"),void n.append(i);if(0<(s=$("#mqinput-qn"+o+",input[type=text]#qn"+o+",select#qn"+o+",textarea#qn"+o)).length)return $(t).prev(".sabtn").remove(),i.append($(t)),void s.after(i)}l=$(t).parent(),i.append($(t)),l.empty().append(i)}),$("input.dsbtn + div.hidden").attr("aria-hidden",!0).attr("aria-expanded",!1),$("input.dsbtn").each(function(){var e=$(this).siblings("div:first-of-type").attr("id");$(this).attr("aria-expanded",!1).attr("aria-controls",e).off("click.sashow").on("click.sashow",function(){var e="true"==$(this).attr("aria-expanded");$(this).attr("aria-expanded",!e).siblings("div:first-of-type").attr("aria-expanded",!e).attr("aria-hidden",e).toggleClass("hidden",e)})})}function initShowAnswer(){$("input.sabtn + span.hidden").attr("aria-hidden",!0).attr("aria-expanded",!1),$("input.sabtn").each(function(){var e=$(this).siblings("span:first-of-type").attr("id");$(this).attr("aria-expanded",!1).attr("aria-controls",e).off("click.sashow").on("click.sashow",function(){$(this).attr("aria-expanded",!0).siblings("span:first-of-type").attr("aria-expanded",!0).attr("aria-hidden",!1).removeClass("hidden")})}),$("input.dsbtn + div.hidden").attr("aria-hidden",!0).attr("aria-expanded",!1),$("input.dsbtn").each(function(){var e=$(this).siblings("div:first-of-type").attr("id");$(this).attr("aria-expanded",!1).attr("aria-controls",e).off("click.sashow").on("click.sashow",function(){$(this).attr("aria-expanded",!0).siblings("div:first-of-type").attr("aria-expanded",!0).attr("aria-hidden",!1).removeClass("hidden")})})}function setupDraw(e){var t,a,r,i=document.getElementById("qn"+e).value,n=i.split(";;"),s=[];for(t=0;t<n.length;t++)if(5==t?n[t]="["+n[t].replace(/&quot;/g,'"')+"]":(n[t]="["+n[t].replace(/\(/g,"[").replace(/\)/g,"]")+"]",0==t&&2<n[t].length&&(n[t]="["+n[t].replace(/;/g,"],[")+"]")),""===n[t])s[t]=[];else try{s[t]=JSON.parse(n[t])}catch(e){s[t]=[]}window.drawla[e]=s,window.canvases[e]=allParams[e].canvas,imathasDraw.initCanvases(e),(a=document.getElementById("drawtools"+e))&&a.addEventListener("click",function(e){var t,a,r,i=e.target;i.hasAttribute("data-drawaction")&&(t=i.getAttribute("data-drawaction"),a=i.getAttribute("data-qn"),"clearcanvas"===t?imathasDraw.clearcanvas(a):"settool"===t&&(r=i.getAttribute("data-val"),imathasDraw.settool(i,a,r)))}),(r=document.getElementById("qn"+e).parentNode.querySelector(".a11ydrawadd"))&&r.addEventListener("click",function(e){var t=e.target.getAttribute("data-qn");imathasDraw.adda11ydraw(t)})}function initMultAns(e){var t,a="hasnone"==$("#qnwrap"+e).attr("data-multans");a&&(t=$('input[name^="qn'+e+'["]')).on("change",function(){this.checked&&this.value==t.length-1?t.not(":last").prop("checked",!1):this.checked&&t.last().prop("checked",!1)})}function isBlank(e){return!e||0===e.length||/^\s*$/.test(e)}function editdebit(e){var t=e.target,a=$(t).closest("tr").find("input").first();!isBlank(t.value)&&a.hasClass("iscredit")&&(a.css("padding-left"),a.is("select")?a.css("margin-right",20):a.width(""),a.css("padding-left",""),a.removeClass("iscredit"))}function editcredit(e){var t,a=e.target,r=$(a).closest("tr").find("input").first();isBlank(a.value)||r.hasClass("iscredit")||(t=parseInt(r.css("padding-left")),r.is("select")?r.css("margin-right",0):r.width(r.width()-20),r.css("padding-left",20+t),r.addClass("iscredit"))}function initcreditboxes(){$(".creditbox").each(function(e,t){editcredit({target:t})})}function setupLivePreview(r,e){var t,a;if("MathJax"==mathRenderer&&(!window.MathJax||!window.MathJax.Hub&&!window.MathJax.typesetPromise))return t=r,a=e,void setTimeout(100,function(){setupLivePreview(t,a)});LivePreviews.hasOwnProperty(r)||("MathJax"==mathRenderer||"Katex"==mathRenderer?(LivePreviews[r]={delay:"MathJax"==mathRenderer?100:0,finaldelay:1e3,preview:null,buffer:null,timeout:null,finaltimeout:null,mjRunning:!1,mjPending:!1,oldText:null,mjPromise:null,Init:function(e){$("#p"+r).css("positive","relative").append('<span id="lpbuf1'+r+'" style="visibility:hidden;position:absolute;"></span>').append('<span id="lpbuf2'+r+'" style="visibility:hidden;position:absolute;"></span>'),this.preview=document.getElementById("lpbuf1"+r),this.buffer=document.getElementById("lpbuf2"+r),"MathJax"==mathRenderer&&MathJax.typesetPromise&&(this.mjPromise=Promise.resolve()),e||showPreview(r)},SwapBuffers:function(){var e=this.preview,t=this.buffer;this.buffer=e,this.preview=t,e.style.visibility="hidden",e.style.position="absolute",t.style.position="",t.style.visibility=""},Update:function(e){this.timeout&&clearTimeout(this.timeout),this.finaltimeout&&clearTimeout(this.finaltimeout),this.timeout=setTimeout(this.callback,this.delay),this.finaltimeout=setTimeout(this.DoFinalPreview,this.finaldelay)},RenderNow:function(e){this.buffer.innerHTML=this.oldtext=e,this.mjRunning=!0,this.RenderBuffer()},RenderBuffer:function(){"MathJax"==mathRenderer?MathJax.typesetPromise?this.mjPromise=this.mjPromise.then(function(){MathJax.typesetPromise([this.buffer]).then(this.PreviewDone.bind(this))}.bind(this)):MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.buffer],["PreviewDone",this]):"Katex"==mathRenderer&&(renderMathInElement(this.buffer),"undefined"!=typeof MathJax&&MathJax.Hub&&!MathJax.typesetPromise&&0<$(this.buffer).children(".mj").length?MathJax.Hub.Queue(["PreviewDone",this]):this.PreviewDone())},DoFinalPreview:function(){$("#pbtn"+r).trigger("click")},preformat:function(e){var t=allParams[r].qtype,a=allParams[r].calcformat;return preformat(r,e,t,a)},CreatePreview:function(){if(this.timeout=null,!this.mjPending){var e=document.getElementById("qn"+r).value;e!==this.oldtext&&(this.mjRunning?(this.mjPending=!0,this.mjPromise?this.mjPromise=this.mjPromise.then(this.CreatePreview().bind(this)):MathJax.Hub&&MathJax.Hub.Queue(["CreatePreview",this])):(this.oldtext=e,this.buffer.innerHTML="`"+this.preformat(e)+"`",this.mjRunning=!0,this.RenderBuffer()))}},PreviewDone:function(){this.mjRunning=this.mjPending=!1,this.SwapBuffers(),updateehpos()}},"undefined"==typeof MathJax||MathJax.typesetPromise?LivePreviews[r].callback=function(){LivePreviews[r].CreatePreview()}:(LivePreviews[r].callback=MathJax.Callback(["CreatePreview",LivePreviews[r]]),LivePreviews[r].callback.autoReset=!0),LivePreviews[r].Init(e)):LivePreviews[r]={finaldelay:1e3,finaltimeout:null,Update:function(e){this.finaltimeout&&clearTimeout(this.finaltimeout),this.finaltimeout=setTimeout(this.DoFinalPreview,this.finaldelay)},RenderNow:function(e){var t=document.getElementById("p"+r);t.innerHTML=e,rendermathnode(t)},DoFinalPreview:function(){$("#pbtn"+r).trigger("click")}})}function updateLivePreview(e){var t=e.target.id.substr(2);setupLivePreview(t),LivePreviews[t].Update()}function clearLivePreviewTimeouts(){for(var e in LivePreviews)clearTimeout(LivePreviews[e].finaltimeout)}function normalizemathunicode(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/g,"")).replace(/\u2013|\u2014|\u2015|\u2212/g,"-")).replace(/\u2044|\u2215/g,"/")).replace(/∞/g,"oo").replace(/≤/g,"<=").replace(/≥/g,">=").replace(/∪/g,"U")).replace(/±/g,"+-").replace(/÷/g,"/").replace(/·|✕|×|⋅/g,"*")).replace(/√/g,"sqrt").replace(/∛/g,"root(3)")).replace(/⁰/g,"^0").replace(/¹/g,"^1").replace(/²/g,"^2").replace(/³/g,"^3").replace(/⁴/g,"^4").replace(/⁵/g,"^5").replace(/⁶/g,"^6").replace(/⁷/g,"^7").replace(/⁸/g,"^8").replace(/⁹/g,"^9")).replace(/\u2329/g,"<").replace(/\u232a/g,">")).replace(/₀/g,"_0").replace(/₁/g,"_1").replace(/₂/g,"_2").replace(/₃/g,"_3")).replace(/\b(OO|infty)\b/gi,"oo").replace(/°/g,"degree")).replace(/θ/g,"theta").replace(/ϕ/g,"phi").replace(/φ/g,"phi").replace(/π/g,"pi").replace(/σ/g,"sigma").replace(/μ/g,"mu")).replace(/α/g,"alpha").replace(/β/g,"beta").replace(/γ/g,"gamma").replace(/δ/g,"delta").replace(/ε/g,"epsilon").replace(/κ/g,"kappa")).replace(/λ/g,"lambda").replace(/ρ/g,"rho").replace(/τ/g,"tau").replace(/χ/g,"chi").replace(/ω/g,"omega")).replace(/Ω/g,"Omega").replace(/Γ/g,"Gamma").replace(/Φ/g,"Phi").replace(/Δ/g,"Delta").replace(/Σ/g,"Sigma")}function htmlEntities(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&/g,"&amp;")}function showPreview(e){var t,a=allParams[e],r="",i=processByType(e);i.str&&(r="`"+htmlEntities(i.str)+"`"),i.dispvalstr&&""!=i.dispvalstr&&-1!=a.calcformat.indexOf("showval")&&(r+=(""==r?"":" = ")+"`"+htmlEntities(i.dispvalstr)+"`"),i.err&&""!=i.err&&""!=i.str&&(r+="``"==r?"":". <span class=noticetext>"+i.err+"</span>"),LivePreviews.hasOwnProperty(e)?LivePreviews[e].RenderNow(r):((t=document.getElementById("p"+e)).innerHTML=r,rendermathnode(t)),a11ypreview(r)}function a11ypreview(e){var t=$("<div>",{class:"inactive"}).html(e).appendTo("body")[0];rendermathnode(t,function(){var e=document.getElementById("arialive");e.innerHTML="",t.className="",$(t).find("[aria-label]").each(function(e,t){$(t).html($(t).attr("aria-label"))}),e.appendChild(t)})}function syntaxCheckMQ(e,t){clearTimeout(MQsyntaxtimer);var a=parseInt(e.replace(/.*qn(\d+)\b.*/g,"$1"));MQsyntaxtimer=setTimeout(function(){showSyntaxCheckMQ(a)},1e3)}function showSyntaxCheckMQ(e){var t,a=allParams[e],r=processByType(e),i="";r.dispvalstr&&""!=r.dispvalstr&&"NaN"!=r.dispvalstr&&a.calcformat&&-1!=a.calcformat.indexOf("showval")&&(i+=" = "+htmlEntities(r.dispvalstr)+" "),r.err&&""!=r.err&&""!=r.str&&(i+="<span class=noticetext>"+r.err+"</span>"),!LivePreviews.hasOwnProperty(e)||"MathJax"!=mathRenderer&&"Katex"!=mathRenderer?(t=document.getElementById("p"+e))&&(t.innerHTML=i):((t=document.getElementById("p"+e).firstChild).innerHTML=i,t.style.visibility="",t.style.position=""),document.getElementById("qn"+e)?a11ypreview("`"+htmlEntities(document.getElementById("qn"+e).value)+"` "+i):a11ypreview(i)}function preSubmitForm(e){var t,a,r,i;for(a in allParams)!1!==(t=preSubmit(a))&&((r=document.getElementById("qn"+a+"-val"))?r.value=t:((i=document.createElement("input")).type="hidden",i.name="qn"+a+"-val",i.value=t,e.appendChild(i)))}function preSubmit(e){var t=processByType(e);return!!t.submitstr&&t.submitstr}function preSubmitString(e,t){var a,r=parseInt(e.substr(2));return allParams.hasOwnProperty(r)&&(a=allParams[r],t=(t=normalizemathunicode(t)).replace(/^\s+/,"").replace(/\s+$/,""),"numfunc"==a.qtype&&(t=AMnumfuncPrepVar(r,t)[3])),t}function processByType(e){var t,a,r,i;if(!allParams.hasOwnProperty(e))return!1;if(a={},"draw"==(t=allParams[e]).qtype)return imathasDraw.encodea11ydraw(),{};if("choices"==t.qtype||"multans"==t.qtype||"matching"==t.qtype)return{};if(t.hasOwnProperty("matrixsize"))a=processSizedMatrix(e);else{if(!(r=document.getElementById("qn"+e)))return!1;if((i=(i=normalizemathunicode(i=r.value)).replace(/^\s+/,"").replace(/\s+$/,"")).match(/^\s*$/))return{str:"",displvalstr:"",submitstr:""};if(i.match(/^\s*DNE\s*$/i))return{str:"DNE",displvalstr:"",submitstr:"DNE"};if(i.match(/^\s*oo\s*$/i))return{str:"oo",displvalstr:"",submitstr:"oo"};if(i.match(/^\s*\+oo\s*$/i))return{str:"+oo",displvalstr:"",submitstr:"+oo"};if(i.match(/^\s*-oo\s*$/i))return{str:"-oo",displvalstr:"",submitstr:"-oo"};switch(t.qtype){case"number":a=processNumber(i,t.calcformat);break;case"calculated":a=processCalculated(i,t.calcformat);break;case"interval":case"calcinterval":a=processCalcInterval(i,t.calcformat,t.vars);break;case"ntuple":case"calcntuple":a=processCalcNtuple(i,t.calcformat);break;case"complex":case"calccomplex":a=processCalcComplex(i,t.calcformat);break;case"calcmatrix":a=processCalcMatrix(i,t.calcformat);break;case"numfunc":a=processNumfunc(e,i,t.calcformat);break;case"matrix":a=processCalcMatrix(i,"decimal")}a.str=preformat(e,i,t.qtype,t.calcformat)}return a}function preformat(e,t,a,r){return t=normalizemathunicode(t),a.match(/interval/)?r.match(/inequality/)?(t=t.replace(/<=/g," le ").replace(/>=/g," ge ").replace(/</g," lt ").replace(/>/g," gt ")).match(/all\s*real/i)&&(t="text("+t+")"):t=t.replace(/U/g,"uu"):"numfunc"==a?t=AMnumfuncPrepVar(e,t)[1]:"calcntuple"==a?t=t.replace(/<+/g,"(:").replace(/>+/g,":)"):"calculated"==a&&(-1==r.indexOf("list")&&-1==r.indexOf("set")&&(t=t.replace(/(\d)\s*,\s*(?=\d{3}\b)/g,"$1")),-1!=r.indexOf("scinot")&&(t=t.replace(/(x|X|\u00D7)/,"xx"))),t=t.replace(/[^\u0000-\u007f]/g,"?")}function AMnumfuncPrepVar(e,t){var r,a,i,n,s,l,c,o,d,u,p,h=allParams[e].vars.slice(),g=h.map(escapeRegExp).join("|"),m=allParams[e].fvars.map(escapeRegExp).join("|");for(h.push("DNE"),g.match(/lambda/)&&(t=t.replace(/lamda/,"lambda")),r=[],a=(a=t).replace(/(arcsinh|arccosh|arctanh|arcsech|arccsch|arccoth|arcsin|arccos|arctan|arcsec|arccsc|arccot|sinh|cosh|tanh|sech|csch|coth|sqrt|ln|log|exp|sin|cos|tan|sec|csc|cot|abs|root)/g,functoindex),t=t.replace(/(arcsinh|arccosh|arctanh|arcsech|arccsch|arccoth|arcsin|arccos|arctan|arcsec|arccsc|arccot|sinh|cosh|tanh|sech|csch|coth|sqrt|ln|log|exp|sin|cos|tan|sec|csc|cot|abs|root)/g,functoindex),i=0;i<h.length;i++)if(h[i].match(/\(.+\)/)&&(t=t.replace(/\(\((.*?)\)\)/g,"($1)")),"E"==h[i]||"e"==h[i])r[i]=!0;else for(r[i]=!1,n=0;n<h.length;n++)if(i!=n&&h[n].toLowerCase()==h[i].toLowerCase()&&h[n]!=h[i]){r[i]=!0;break}for(t=(t=t.replace(new RegExp("("+g+")","gi"),function(e,t){for(var a=0;a<h.length;a++)if(h[a]==t||!r[a]&&h[a].toLowerCase()==t.toLowerCase())return"@v"+a+"@";return t})).replace(/@v(\d+)@/g,function(e,t){return h[t]}),a=(a=(a=a.replace(new RegExp("("+g+")","gi"),function(e,t){for(var a=0;a<h.length;a++)if(h[a]==t||!r[a]&&h[a].toLowerCase()==t.toLowerCase())return"@v"+a+"@";return t})).replace(/(@v(\d+)@|\d+(\.\d+)?)!/g,"{:$&:}")).replace(/@v(\d+)@/g,function(e,t){return h[t]}),s=t,l=new Array,i=0;i<h.length;i++)1<h[i].length&&(o=!1,-1!=greekletters.indexOf(h[i].toLowerCase())&&(o=!0),h[i].match(/^\w+_\w+$/)?(c=r[i]?"g":"gi",d=new RegExp(/^(\w+)_(\w+)$/,c).exec(h[i]),u=new RegExp(d[1]+"_\\("+d[2]+"\\)",c),a=a.replace(u,h[i]),t=t.replace(u,h[i]),s=(s=s.replace(new RegExp(d[0],c),d[1]+"_"+d[2])).replace(new RegExp(d[1]+"_\\("+d[2]+"\\)",c),d[1]+"_("+d[2]+")"),1<d[1].length&&-1==greekletters.indexOf(d[1].toLowerCase())&&(d[1]='"'+d[1]+'"'),1<d[2].length&&-1==greekletters.indexOf(d[2].toLowerCase())&&(d[2]='"'+d[2]+'"'),a=a.replace(new RegExp(d[0],c),d[1]+"_"+d[2]),t=t.replace(new RegExp(d[0],"g"),"repvars"+i),h[i]="repvars"+i):!o&&1<h[i].replace(/[^\w_]/g,"").length&&l.push(h[i]),(h[i].match(/[^\w_]/)||h[i].match(/^(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|and with)$/))&&(t=t.replace(new RegExp(escapeRegExp(h[i]),"g"),"repvars"+i),h[i]="repvars"+i));return 0<l.length&&(vltq=l.join("|"),p=new RegExp("("+vltq+")","g"),a=a.replace(p,'"$1"')),a=a.replace(/@(\d+)@/g,indextofunc),t=t.replace(/@(\d+)@/g,indextofunc),s=s.replace(/@(\d+)@/g,indextofunc),g.match(/\bf\b/)&&!m.match(/\bf\b/)&&(a=(a=a.replace(/([^a-zA-Z])f\^([\d\.]+)([^\d\.])/g,"$1f^$2{::}$3")).replace(/([^a-zA-Z])f\(/g,"$1f{::}(")),g.match(/\bg\b/)&&!m.match(/\bg\b/)&&(a=(a=a.replace(/([^a-zA-Z])g\^([\d\.]+)([^\d\.])/g,"$1g^$2{::}$3")).replace(/([^a-zA-Z])g\(/g,"$1g{::}(")),[t,a,h.join("|"),s]}function processNumber(e,t){var a,r,i,n,s,l,c="";for(e=e.replace(/^\s+|\s+$/g,""),-1!==t.indexOf("set")&&("{"!==e.charAt(0)||"}"!==e.substr(-1)?c+=_("Invalid set notation"):e=e.slice(1,-1)),a=-1!==t.indexOf("list")||-1!==t.indexOf("set")?e.split(/\s*,\s*/):[e.replace(/,/g,"")],i=0;i<a.length;i++)if(r=a[i],-1!=t.indexOf("units"))if(_("Units must be given as [decimal number]*[unit]^[power]*[unit]^[power].../[unit]^[power]*[unit]^[power]..."),r.match(/^\s*(-?\s*\d+\.?\d*|-?\s*\.\d+|-?\s*\d\.?\d*\s*(E|\*\s*10\s*\^)\s*[\-\+]?\d+)/)||(c+=_("Answer must start with a number. ")),r.match(/\b(sq|square|cu|cubic|squared|cubed)\s*\^\s*[\-\+]?\s*\d+/)&&(c+=_("Invalid base for exponent. "),r=r.replace(/\^/,"")),r.match(/\b(sq|square|cu|cubic)\s+per\b/)&&(c+=_('Missing unit before "per". '),r=r.replace(/per\b/,"")),r.match(/\bper\s+(squared|cubed)/)&&(c+=_('Missing unit after "per". '),r=r.replace(/\bper/,"")),(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=(r=r.replace(/([a-zA-Z]\w*\s*)(\^\s*[\-\+]?\s*\d+\s*)(?:squared|cubed)\b/g,"$1")).replace(/(?:sq|square|cu|cubic)\s+([a-zA-Z]\w*)/g,"$1")).replace(/([a-zA-Z]\w*)\s+(?:squared|cubed)/g,"$1")).replace(/\sper\s/g,"/")).replace(/^\s*(-?\s*\d\.?\d*\s*(E|\*\s*10\s*\^)\s*[\-\+]?\d+|-?\s*\d+\.?\d*|-?\s*\.\d+)\s*[\-\*]?\s*/,"")).replace(/\s*\-\s*([a-zA-Z])/g,"*$1")).replace(/\*\*/g,"^")).replace(/\s*(\/|\^|\-)\s*/g,"$1")).replace(/\(\s*(.*?)\s*\)\s*\//,"$1/").replace(/\/\s*\(\s*(.*?)\s*\)/,"/$1")).replace(/\s*[\*\s]\s*/g,"*")).replace(/([a-zA-Z]\w*)\^[\-\+]?\d+/g,"$1")).match(/\^/)&&(c+=_("Invalid exponents. "),r=r.replace(/\^/g,"")),1<(r.match(/\//g)||[]).length&&(c+=_("Only one division symbol allowed in the units. ")),0<(r=r.replace(/\//g,"*").replace(/^\s*\*/,"").trim()).length)for(n=r.split(/\s*\*\s*/),s=/^(yotta|zetta|exa|peta|tera|giga|mega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|fempto|atto|zepto|yocto)?(m|meters?|km|cm|mm|um|microns?|nm|[aA]ngstroms?|pm|fm|fermi|in|inch|inches|ft|foot|feet|mi|miles?|furlongs?|yd|yards?|s|sec|seconds?|ms|us|ns|min|minutes?|h|hrs?|hours?|days?|weeks?|mo|months?|yr|years?|fortnights?|acres?|ha|hectares?|b|barns?|l|L|liters?|litres?|dL|ml|mL|cc|gal|gallons?|cups?|pints?|quarts?|tbsp|tablespoons?|tsp|teaspoons?|rad|radians?|deg|degrees?|gradians?|knots?|kt|c|mph|kph|kg|g|grams?|mg|tonnes?|k?[hH]z|[hH]ertz|revs?|revolutions?|cycles?|N|[nN]ewtons?|kips?|dynes?|lbs?|pounds?|tons?|[kK]?J|[jJ]oules?|ergs?|lbf|lbft|ftlb|cal|calories?|kcal|eV|electronvolts?|k[wW]h|btu|BTU|W|[wW]atts?|kW|hp|horsepower|Pa|[pP]ascals?|kPa|MPa|GPa|atms?|atmospheres?|bars?|barometers?|mbars?|[tT]orr|mmHg|cmWater|psi|C|[cC]oulombs?|V|[vV]olts?|mV|MV|[fF]arads?|F|ohms?|ohms|amps?|[aA]mperes?|A|T|[tT]eslas?|G|Gauss|Wb|Weber|H|Henry|lm|lumens?|lx|lux|amu|[dD]altons?|me|mol|mole|Ci|curies?|R|roentgens?|sr|steradians?|Bq|bequerel|ls|lightsecond|ly|lightyears?|AU|au|parsecs?|kpc|solarmass|solarradius|degF|degC|degK|K|microns?|cmH2O)$/,l=0;l<n.length;l++)s.test(n[l])||(c+=_("Unknown unit ")+'"'+n[l]+'". ');else c+=_("Missing units");else-1!=t.indexOf("integer")?r.match(/^\s*\-?\d+\s*$/)||(c+=_("This is not an integer.")):r.match(/^\s*(\+|\-)?(\d+\.?\d*|\.\d+|\d*\.?\d*\s*E\s*[\-\+]?\d+)\s*$/)||(c+=_("This is not a decimal or integer value."));return{err:c,dispvalstr:e}}function processCalculated(e,t){var a,r,i,n,s,l;for(e=e.replace(/=/,""),a=-1!=t.indexOf("list")?e.split(/,/):-1!=t.indexOf("set")?e.replace(/[\{\}]/g,"").split(/,/):[e],r="",n=[],s=0;s<a.length;s++)str=a[s],r+=singlevalsyntaxcheck(str,t),r+=syntaxcheckexpr(str,t),r+=(i=singlevaleval(str,t))[1],n.push(i[0]);return l=n.join(", "),-1!=t.indexOf("set")&&(l="{"+l+"}"),{err:r,dispvalstr:l,submitstr:n.join(",")}}function processCalcInterval(e,t,a){var r,n,s,l,c,o,d,u,p,h,g,m;if(-1!=t.indexOf("inequality")){if(1<(r=ineqtointerval(e=e.replace(/or/g," or "),a)).length)return{err:"wrongvar"==r[1]?_("you may have used the wrong variable"):_("invalid inequality notation")};e=r[0]}if(n=[],s=[],l=[],c="U",-1!=t.indexOf("list")){for(e=e.replace(/\s*,\s*/g,","),c=",",o=0,d=1;d<e.length-1;d++)","==e.charAt(d)&&(")"!=e.charAt(d-1)&&"]"!=e.charAt(d-1)||"("!=e.charAt(d+1)&&"["!=e.charAt(d+1)||(n.push(e.substring(o,d)),o=d+1));n.push(e.substring(o))}else n=e.split(/\s*U\s*/i);for(u="",m=[],i=0;i<n.length;i++){if(p=n[i],sm=p.charAt(0),em=p.charAt(p.length-1),2!=(h=(h=p.substring(1,p.length-1)).split(/,/)).length||"("!=sm&&"["!=sm||")"!=em&&"]"!=em){-1!=t.indexOf("inequality")?u+=_("invalid inequality notation")+". ":u+=_("invalid interval notation")+". ";break}for(j=0;j<2;j++)-1!=t.indexOf("decimal")&&h[j].match(/[\d\.]e\-?\d/)&&(h[j]=h[j].replace(/e/,"E")),u+=singlevalsyntaxcheck(h[j],t),u+=syntaxcheckexpr(h[j],t),h[j].match(/^\s*\-?\+?oo\s*$/)?m[j]=h[j]:(u+=(g=singlevaleval(h[j],t))[1],m[j]=g[0]);s[i]=sm+m[0]+","+m[1]+em,-1!=t.indexOf("inequality")&&(m[0].toString().match(/oo/)?m[1].toString().match(/oo/)?l[i]="RR":l[i]=a+("]"==em?"le":"lt")+m[1]:m[1].toString().match(/oo/)?l[i]=a+("["==sm?"ge":"gt")+m[0]:l[i]=m[0]+("["==sm?"le":"lt")+a+("]"==em?"le":"lt")+m[1])}return-1!=t.indexOf("inequality")?{err:u,dispvalstr:l.join(' "or" '),submitstr:s.join(c)}:{err:u,dispvalstr:s.join(" uu "),submitstr:s.join(c)}}function processCalcNtuple(e,t){var a,r,i="",n=0,s=0,l="",c=!0,o=NaN;for((e=(e=e.replace(/(\s+,\s+|,\s+|\s+,)/,",")).replace(/<<(.*?)>>/g,"<$1>")).charAt(0).match(/[\(\[\<\{]/)||(c=!1),r=0;r<e.length;r++)a=!1,0==n&&(i+=e.charAt(r),s=r+1,","==e.charAt(r)?e.substring(r+1).match(/^\s*[\(\[\<\{]/)&&e.substring(0,r).match(/[\)\]\>\}]\s*$/)||(c=!1):0<r&&","!=e.charAt(r-1)&&(c=!1)),e.charAt(r).match(/[\(\[\<\{]/)?n++:e.charAt(r).match(/[\)\]\>\}]/)&&(n--,a=!0),(0==n&&a||1==n&&","==e.charAt(r))&&(sub=e.substring(s,r).replace(/^\s+/,"").replace(/\s+$/,""),l+=singlevalsyntaxcheck(sub,t),l+=syntaxcheckexpr(sub,t),l+=(o=singlevaleval(sub,t))[1],i+=o[0],i+=e.charAt(r),s=r+1);return 0!=n&&(c=!1),0==c&&(l=_("Invalid notation")+". "+l),{err:l,dispvalstr:i,submitstr:i}}function processCalcComplex(e,t){var a,r,i,n,s,l,c="",o=e.split(","),d="",u="",p=[];for(s=0;s<o.length;s++)d=o[s].replace(/^\s+/,"").replace(/\s+$/,""),-1==t.indexOf("sloppycomplex")&&("string"==typeof(l=parsecomplex(o[s]))?c+=l:(c+=singlevalsyntaxcheck(l[0],t),c+=singlevalsyntaxcheck(l[1],t))),syntaxcheckexpr(d,t),a=scopedeval("var i=0;"+(n=prepWithMath(mathjs(d,"i")))),r=scopedeval("var i=1;"+n),i=scopedeval("var i=-1;"+n),"synerr"!=a&&"synerr"!=r||(c+=_("syntax incomplete"),a=NaN),isNaN(a)||"Infinity"==a||isNaN(r)||isNaN(i)||"Infinity"==r||(r-=a,u=Math.abs(a)<1e-16?"":a,u+=Math.abs(r)<1e-16?"":(0<r&&""!=u?"+":"")+r+"i",p.push(u));return{err:c,dispvalstr:p.join(", "),submitstr:p.join(",")}}function processSizedMatrix(e){var t,a,r,i,n,s,l,c,o=allParams[e],d=o.matrixsize,u="";for(o.calcformat&&(u=o.calcformat),t=[],a=[],r=[],s="",l=i=0;l<d[0];l++){for(t[l]=[],a[l]=[],c=0;c<d[1];c++)""!==(n=normalizemathunicode(n=document.getElementById("qn"+e+"-"+i).value))&&(s+=syntaxcheckexpr(n,u),s+=singlevalsyntaxcheck(n,u)),t[l][c]=n,res=singlevaleval(n,u),s+=res[1],a[l][c]=res[0],r.push(res[0]),i++;t[l]="("+t[l].join(",")+")",a[l]="("+a[l].join(",")+")"}return{err:s,str:"["+t.join(",")+"]",dispvalstr:"calcmatrix"==o.qtype?"["+a.join(",")+"]":"",submitstr:r.join("|")}}function processCalcMatrix(e,t){var a,r,i,n,s,l,c,o,d,u,p,h,g=!0;for(((e=(e=(e=e.replace(/\[/g,"(")).replace(/\]/g,")")).replace(/\s+/g,"")).length<2||"("!==e.charAt(0)||")"!==e.charAt(e.length-1))&&(g=!1),e=e.substring(1,e.length-1),r=a="",i=[],l=s=n=0;l<e.length;l++)"("==e.charAt(l)?s++:")"==e.charAt(l)?s--:","==e.charAt(l)&&0==s&&(i.push(e.substring(n+1,l-1)),n=l+1);for(i.push(e.substring(n+1,e.length-1)),c=-1,0!==s&&(g=!1),u=[],p=[],l=0;l<i.length;l++){for(u[l]=[],o=i[l].split(","),-1<c&&o.length!=c&&(g=!1),c=o.length,h=0;h<o.length;h++)""==(d=o[h].replace(/^\s+/,"").replace(/\s+$/,""))?(r=_("No elements of the matrix should be left blank."),u[l][h]="",p.push("")):(a+=syntaxcheckexpr(d,t),a+=singlevalsyntaxcheck(d,t),res=singlevaleval(d,t),a+=res[1],u[l][h]=res[0],p.push(res[0]));u[l]="("+u[l].join(",")+")"}return g||(a=_("Invalid matrix format")+". "),{err:a+=r,dispvalstr:"["+u.join(",")+"]",submitstr:p.join("|")}}function processNumfunc(e,t,a){var r,i,n,s,l,c,o,d,u,p=allParams[e],h=p.vars,g=p.fvars,m=p.domain,f=a.match(/equation/),v=a.match(/inequality/),y="",b=AMnumfuncPrepVar(e,t);for(i=a.match(/list/)?b[0].split(/,/):[b[0]],d=o=0;d<i.length;d++){for(r=(r=i[d]).replace(/,/g,"").replace(/^\s+/,"").replace(/\s+$/,"").replace(/degree/g,""),u=b[2].split("|"),r.match(/(<=|>=|<|>)/)?(v?1<r.match(/(<=|>=|<|>)/g).length&&(y+=_("syntax error: your inequality should only contain one inequality symbol")+". "):y+=f?_("syntax error: you gave an inequality, not an equation")+". ":_("syntax error: you gave an inequality, not an expression")+". ",r=r.replace(/(.*)(<=|>=|<|>)(.*)/,"$1-($3)")):r.match(/=/)?(v?y+=_("syntax error: you gave an equation, not an inequality")+". ":f?1<r.match(/=/g).length&&(y+=_("syntax error: your equation should only contain one equal sign")+". "):y+=_("syntax error: you gave an equation, not an expression")+". ",r=r.replace(/(.*)=(.*)/,"$1-($2)")):f?y+=_("syntax error: this is not an equation")+". ":v&&(y+=_("syntax error: this is not an inequality")+". "),0<g.length&&(reg=new RegExp("("+g.join("|")+")\\(","g"),r=r.replace(reg,"$1*sin($1+")),r=prepWithMath(mathjs(r,u.join("|"))),s=o=0;s<20;s++){for(l="var DNE=1;",n=0;n<u.length-1;n++)c=m[n][2]?Math.floor(Math.random()*(m[n][0]-m[n][1]+1)+m[n][0]):Math.random()*(m[n][0]-m[n][1])+m[n][0],l+="var "+u[n]+"="+c+";";if("synerr"!==scopedeval(l+r)){o++;break}}0===o&&(y+=_("syntax error")+". "),y+=syntaxcheckexpr(b[0],a,h.map(escapeRegExp).join("|"))}return{err:y}}function simplifyVariable(e){return e.replace(/[^\w_\^\-+]/g,"")}function ineqtointerval(e,t){var a,r,i,n,s,l=simplifyVariable(t);if((e=e.replace(/(\d)\s*,\s*(?=\d{3}\b)/g,"$1")).match(/all\s*real/i))return["(-oo,oo)"];if(e.match(/DNE/))return["DNE"];for(i=[],n=e.split(/\s*or\s*/),s=0;s<n.length;s++)if(str=n[s],a=str.match(/^(.*?)(<=?|>=?)(.*?)(<=?|>=?)(.*?)$/)){if(simplifyVariable(a[3])!=l)return["","wrongvar"];if(a[2].charAt(0)!=a[4].charAt(0))return["","invalid"];if(""==a[1].trim()||""==a[5].trim())return["","invalid"];r="<"==a[2].charAt(0)?("<"==a[2]?"(":"[")+a[1]+","+a[5]+("<"==a[4]?")":"]"):(">"==a[4]?"(":"[")+a[5]+","+a[1]+(">"==a[2]?")":"]"),i.push(r)}else{if(!(a=str.match(/^(.*?)(<=?|>=?)(.*?)$/)))return["","invalid"];if(simplifyVariable(a[1])==l)r="<"==a[2].charAt(0)?"(-oo,"+a[3]+("<"==a[2]?")":"]"):(">"==a[2]?"(":"[")+a[3]+",oo)",i.push(r);else{if(simplifyVariable(a[3])!=l)return["","wrongvar"];r="<"==a[2].charAt(0)?("<"==a[2]?"(":"[")+a[1]+",oo)":"(-oo,"+a[1]+(">"==a[2]?")":"]"),i.push(r)}}return[i.join("U")]}function parsecomplex(e){var t,a,r,i,n,s,l,c;if(c=(e=(e=(e=(e=e.replace(/\s/,"")).replace(/\((\d+\*?i|i)\)\/(\d+)/g,"$1/$2")).replace(/sin/,"s$n")).replace(/pi/,"p$")).length,2<e.split("i").length)return _("error - more than 1 i in expression");if(-1==(n=e.indexOf("i")))t=e,a="0";else{for(i=0,l=n-1;0<l;l--)if(")"==(r=e.charAt(l)))i++;else if("("==r)i--;else if(("+"==r||"-"==r)&&0==i)break;if(l<0&&(l=0),0!=i)return _("error - invalid form");for(i=0,s=n+1;s<c;s++)if("("==(r=e.charAt(s)))i++;else if(")"==r)i--;else if(("+"==r||"-"==r)&&0==i)break;if(0!=i)return _("error - invalid form");if(0<n-l&&0<s-n&&(s==c||0==l)){if(s==c)t=e.substr(0,l),a=e.substr(l,n-l);else{if(0!=l)return _("error - invalid form");t=e.substr(s),a=e.substr(0,n)}a=(a=(a+="*"+e.substr(n+1+("*"==e.charAt(n+1)?1:0),s-n-1)).replace("-*","-1*").replace("+*","+1*")).replace(/(\+|-)1\*(.+)/g,"$1$2")}else if(1<n-l)a=e.substr(l,n-l),t=e.substr(0,l)+e.substr(n+1);else if(1<s-n)if(0<n){if("+"!=e.charAt(n-1)&&"-"!=e.charAt(n-1))return _("error - invalid form");a=e.charAt(n-1)+e.substr(n+1+("*"==e.charAt(n+1)?1:0),s-n-1),t=e.substr(0,n-1)+e.substr(s)}else a=e.substr(n+1,s-n-1),t=e.substr(0,n)+e.substr(s);else a="+"==e.charAt(l)?"1":"-"==e.charAt(l)?"-1":0==n?"1":e.charAt(l),t=(0<n?e.substr(0,l):"")+e.substr(n+1);""==t&&(t="0"),"/"==a.charAt(0)?a="1"+a:"+"!=a.charAt(0)&&"-"!=a.charAt(0)||"/"!=a.charAt(1)||(a=a.charAt(0)+"1"+a.substr(1)),"*"==a.charAt(a.length-1)&&(a=a.substr(0,a.length-1)),"+"==a.charAt(0)&&(a=a.substr(1)),"+"==t.charAt(0)&&(t=t.substr(1))}return[t=(t=t.replace("s$n","sin")).replace("p$","pi"),a=(a=(a=a.replace("s$n","sin")).replace("p$","pi")).replace(/\*\//g,"/")]}function singlevalsyntaxcheck(e,t){if((e=e.replace(/(\d)\s*,\s*(?=\d{3}\b)/g,"$1")).match(/DNE/i))return"";if(e.match(/-?\+?oo$/)||e.match(/-?\+?oo\W/))return"";if(e.match(/,/))return _("Invalid use of a comma.");if(-1!=t.indexOf("allowmixed")&&e.match(/^\s*\-?\s*\d+\s*(_|\s)\s*(\d+|\(\d+\))\s*\/\s*(\d+|\(\d+\))\s*$/))return"";if(-1!=t.indexOf("fracordec")){if(!((e=e.replace(/([0-9])\s+([0-9])/g,"$1*$2").replace(/\s/g,"")).match(/^\(?\-?\(?\d+\)?\/\(?\d+\)?$/)||e.match(/^\(?\d+\)?\/\(?\-?\d+\)?$/)||e.match(/^\-?\d+$/)||e.match(/^\-?(\d+|\d+\.\d*|\d*\.\d+)$/)))return _(" invalid entry format")+". "}else if(-1!=t.indexOf("fraction")||-1!=t.indexOf("reducedfraction")){if(!(e=e.replace(/([0-9])\s+([0-9])/g,"$1*$2").replace(/\s/g,"")).match(/^\(?\-?\(?\d+\)?\/\(?\d+\)?$/)&&!e.match(/^\(?\d+\)?\/\(?\-?\d+\)?$/)&&!e.match(/^\s*?\-?\d+\s*$/))return _("not a valid fraction")+". "}else if(-1!=t.indexOf("mixednumber")){if(!(e.match(/^\(?\-?\s*\(?\d+\)?\/\(?\d+\)?$/)||e.match(/^\(?\d+\)?\/\(?\-?\d+\)?$/)||e.match(/^\s*\-?\s*\d+\s*(_|\s)\s*(\d+|\(\d+\))\s*\/\s*(\d+|\(\d+\))\s*$/)||e.match(/^\s*\-?\s*\d+\s*$/)))return _("not a valid mixed number")+". ";e=e.replace(/_/," ")}else if(-1!=t.indexOf("scinot")){if(!(e=(e=e.replace(/\s/g,"")).replace(/(xx|x|X|\u00D7)/,"xx")).match(/^\-?[1-9](\.\d*)?(\*|xx)10\^(\(?\-?\d+\)?)$/)){if(-1==t.indexOf("scinotordec"))return _("not valid scientific notation")+". ";if(!e.match(/^\-?(\d+|\d+\.\d*|\d*\.\d+)$/))return _("not valid decimal or scientific notation")+". "}}else if(-1!=t.indexOf("decimal")&&-1==t.indexOf("nodecimal")){if(!e.match(/^\-?(\d+|\d+\.\d*|\d*\.\d+)([eE]\-?\d+)?$/))return _(" not a valid integer or decimal number")+". "}else if(!onlyAscii.test(e))return _("Your answer contains an unrecognized symbol")+". ";return""}function syntaxcheckexpr(e,t,a){var r,i,n,s,l,c,o="";for(-1!=t.indexOf("notrig")&&e.match(/(sin|cos|tan|cot|sec|csc)/i)?o+=_("no trig functions allowed")+". ":-1!=t.indexOf("nodecimal")&&-1!=e.indexOf(".")?o+=_("no decimals allowed")+". ":-1==t.indexOf("mixed")&&e.match(/\-?\s*\d+\s*(_|\s)\s*(\d+|\(\d+\))\s*\/\s*(\d+|\(\d+\))/)?o+=_("mixed numbers are not allowed")+". ":-1==t.indexOf("allowdegrees")&&e.match(/degree/)&&(o+=_("no degree symbols allowed")+". "),s=n=i=r=0;s<e.length;s++)"("==e.charAt(s)?r++:")"==e.charAt(s)?r--:"["==e.charAt(s)?i++:"]"==e.charAt(s)?i--:"|"==e.charAt(s)&&(n=1-n);if(0==r&&0==i||(o+=" ("+_("unmatched parens")+"). "),0!=n&&(o+=" ("+_("unmatched absolute value bars")+"). "),reg=a?new RegExp("(sqrt|ln|log|exp|sinh|cosh|tanh|sech|csch|coth|sin|cos|tan|sec|csc|cot|abs)s*("+a+"|\\d+)","i"):new RegExp("(sqrt|ln|log|exp|sinh|cosh|tanh|sech|csch|coth|sin|cos|tan|sec|csc|cot|abs)s*(\\d+)","i"),errstuff=e.match(reg),null!=errstuff&&(o+="["+_("use function notation")+" - "+_("use $1 instead of $2",errstuff[1]+"("+errstuff[2]+")",errstuff[0])+"]. "),a&&((l="degree|arc|sqrt|root|ln|log|exp|sinh|cosh|tanh|sech|csch|coth|sin|cos|tan|sec|csc|cot|abs|pi|sign|DNE|e|oo".split("|").concat(a.split("|"))).sort(function(e,t){return t.length-e.length}),reg=new RegExp("(repvars\\d+|"+l.join("|")+")","ig"),e.replace(reg,"").match(/[a-zA-Z]/)&&(o+=_(" Check your variables - you might be using an incorrect one")+". ")),2<(e.match(/\|/g)||[]).length)for(c=/\|.*?\|\s*(.|$)/g;match=c.exec(e);)if(""!=match[1]&&match[1].match(/[^+\-\*\/\^\)]/)){o+=_(" You may want to use abs(x) instead of |x| for absolute values to avoid ambiguity")+". ";break}return e.match(/%/)&&!e.match(/^\s*[+-]?\s*((\d+(\.\d*)?)|(\.\d+))\s*%\s*$/)&&(o+=_(" Do not use the percent symbol, %")+". "),o}function singlevaleval(e,t){if((e=e.replace(/(\d)\s*,\s*(?=\d{3}\b)/g,"$1")).match(/,/))return[NaN,_("syntax incomplete")+". "];e.match(/^\s*[+-]?\s*((\d+(\.\d*)?)|(\.\d+))\s*%\s*$/)&&(e=e.replace(/%/g,"")+"/100"),-1!=t.indexOf("mixed")&&(e=e.replace(/(\d+)\s+(\d+|\(\d+\))\s*\/\s*(\d+|\(\d+\))/g,"($1+$2/$3)")),-1!=t.indexOf("allowxtimes")&&(e=e.replace(/(xx|x|X|\u00D7)/,"*")),-1!=t.indexOf("scinot")&&(e=e.replace("xx","*"));try{var a=scopedmatheval(e);return""===a?[NaN,_("syntax incomplete")+". "]:[a,""]}catch(e){return[NaN,_("syntax incomplete")+". "]}}function escapeRegExp(e){return e.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function scopedeval(c){try{return eval(c)}catch(e){return"synerr"}}function scopedmatheval(c){if(c.match(/^\s*[a-df-zA-Z]\s*$/))return"";try{return eval(prepWithMath(mathjs(c)))}catch(e){return""}}return LivePreviews=[],MQsyntaxtimer=null,greekletters=["alpha","beta","chi","delta","epsilon","gamma","varphi","phi","psi","sigma","rho","theta","lambda","mu","nu","omega","tau"],onlyAscii=/^[\u0000-\u007f]*$/,{init:init,clearparams:clearparams,preSubmitForm:preSubmitForm,preSubmit:preSubmit,preSubmitString:preSubmitString,clearLivePreviewTimeouts:clearLivePreviewTimeouts,syntaxCheckMQ:syntaxCheckMQ,clearTips:clearTips,handleMQenter:handleMQenter}}(jQuery);function prepWithMath(e){return e=(e=(e=e.replace(/\b(abs|acos|asin|atan|ceil|floor|cos|sin|tan|sqrt|exp|max|min|pow)\(/g,"Math.$1(")).replace(/\(E\)/g,"(Math.E)")).replace(/\((PI|pi)\)/g,"(Math.PI)")}function toggleinlinebtn(e,t){var a,r=document.getElementById(t),i=document.getElementById(e);"none"==i.style.display?(i.style.display="",i.setAttribute("aria-hidden",!1),r.setAttribute("aria-expanded",!0)):(i.style.display="none",i.setAttribute("aria-hidden",!0),r.setAttribute("aria-expanded",!1)),a=r.innerHTML,r.innerHTML=a.match(/\[\+\]/)?a.replace(/\[\+\]/,"[-]"):a.replace(/\[\-\]/,"[+]")}function AutoSuggest(e,t){var a,r,n,s,l,c,o=this;this.elem=e,this.suggestions=t,this.eligible=new Array,this.inputText=null,this.highlighted=-1,this.div=document.getElementById("autosuggest"),null==this.div&&(this.div=document.createElement("div"),this.div.id="autosuggest",document.getElementsByTagName("body")[0].appendChild(this.div),this.div.appendChild(document.createElement("ul"))),a=9,r=27,n=38,s=40,l=13,e.setAttribute("autocomplete","off"),e.id||(c="autosuggest"+AutoSuggestIdCounter,AutoSuggestIdCounter++,e.id=c),e.onkeydown=function(e){var t=o.getKeyCode(e);switch(t){case a:o.useSuggestion("tab");break;case l:return-1<o.highlighted&&e.stopImmediatePropagation(),o.useSuggestion("enter"),!1;case r:o.hideDiv();break;case n:0<o.highlighted&&o.highlighted--,o.changeHighlight(t);break;case s:o.highlighted<o.eligible.length-1&&o.highlighted++,o.changeHighlight(t)}},e.onkeyup=function(e){switch(o.getKeyCode(e)){case a:case r:case n:case s:return;default:1<this.value.length?(o.inputText=this.value,o.getEligible(),0<o.eligible.length?o.highlighted=0:o.highlighted=-1,o.createDiv(),o.positionDiv(),o.showDiv()):(o.hideDiv(),0==this.value.length&&(o.inputText=""))}},e.onblur=function(e){o.hideDiv()},this.useSuggestion=function(e){-1<this.highlighted&&(this.elem.value=this.eligible[this.highlighted]),this.hideDiv()},this.showDiv=function(){this.div.style.display="block"},this.hideDiv=function(){o.div.style.display="none",o.highlighted=-1},this.changeHighlight=function(){var e,t=this.div.getElementsByTagName("LI");for(i in t)e=t[i],this.highlighted==i?e.className="selected":e.className=""},this.positionDiv=function(){var e=this.elem,t=findPos(e);t[1]+=e.offsetHeight,this.div.style.left=t[0]+"px",this.div.style.top=t[1]+"px"},this.createDiv=function(){var e,t,a,r=document.createElement("ul");for(i in this.eligible)e=this.eligible[i],t=document.createElement("li"),(a=document.createElement("a")).href="#",a.onclick=function(){return!1},a.innerHTML=e,t.appendChild(a),o.highlighted==i&&(t.className="selected"),r.appendChild(t);this.div.replaceChild(r,this.div.childNodes[0]),this.setHighlight=function(e){for(var t,a=o.getEventSource(e);a.parentNode&&"LI"!=a.tagName.toUpperCase();)a=a.parentNode;for(i in t=o.div.getElementsByTagName("LI"))if(t[i]==a){o.highlighted=i;break}o.changeHighlight()},r.onmouseover=o.setHighlight,r.onmousedown=r.ontouchstart=function(e){return o.setHighlight(e),o.useSuggestion("click"),o.hideDiv(),o.cancelEvent(e),!1},this.div.className="suggestion_list",this.div.style.position="absolute"},this.getEligible=function(){var e,t;if(this.eligible=new Array,",",-1==this.inputText.indexOf(" "))for(i in e=new RegExp("\\b"+this.inputText.toLowerCase()),this.suggestions)(t=this.suggestions[i]).toLowerCase().match(e)&&(this.eligible[this.eligible.length]=t,i+",")},this.getKeyCode=function(e){return e?e.keyCode:window.event?window.event.keyCode:void 0},this.getEventSource=function(e){return e?e.target:window.event?window.event.srcElement:void 0},this.cancelEvent=function(e){e&&(e.preventDefault(),e.stopPropagation()),window.event&&(window.event.returnValue=!1)}}AutoSuggestIdCounter=0,autoSuggestLists={},autoSuggestObjects={},document.write=function(){};
  