var checkIfSVGavailable=true;var notifyIfNoSVG=true;var alertIfNoSVG=false;var xunitlength=20;var yunitlength=20;var origin=[0,0];var defaultwidth=300;defaultheight=200;defaultborder=0;var border=defaultborder;var strokewidth,strokedasharray,stroke,fill;var fontstyle,fontfamily,fontsize,fontweight,fontstroke,fontfill;var markerstrokewidth="1";var markerstroke="black";var markerfill="yellow";var marker="none";var arrowfill=stroke;var dotradius=4;var ticklength=4;var axesstroke="black";var gridstroke="grey";var pointerpos=null;var coordinates=null;var above="above";var below="below";var left="left";var right="right";var aboveleft="aboveleft";var aboveright="aboveright";var belowleft="belowleft";var belowright="belowright";var cpi="\u03C0",ctheta="\u03B8";var pi=Math.PI,ln=Math.log,e=Math.E;var arcsin=Math.asin,arccos=Math.acos,arctan=Math.atan;var sec=function(f){return 1/Math.cos(f)};var csc=function(f){return 1/Math.sin(f)};var cot=function(f){return 1/Math.tan(f)};var xmin,xmax,ymin,ymax,xscl,yscl,xgrid,ygrid,xtick,ytick,initialized;var isIE=document.createElementNS==null;var picture,svgpicture,doc,width,height,a,b,c,d,i,n,p,t,x,y;var arcsec=function(f){return arccos(1/f)};var arccsc=function(f){return arcsin(1/f)};var arccot=function(f){return arctan(1/f)};var sinh=function(f){return(Math.exp(f)-Math.exp(-f))/2};var cosh=function(f){return(Math.exp(f)+Math.exp(-f))/2};var tanh=function(f){return(Math.exp(f)-Math.exp(-f))/(Math.exp(f)+Math.exp(-f))};var sech=function(f){return 1/cosh(f)};var csch=function(f){return 1/sinh(f)};var coth=function(f){return 1/tanh(f)};var arcsinh=function(f){return ln(f+Math.sqrt(f*f+1))};var arccosh=function(f){return ln(f+Math.sqrt(f*f-1))};var arctanh=function(f){return ln((1+f)/(1-f))/2};var sech=function(f){return 1/cosh(f)};var csch=function(f){return 1/sinh(f)};var coth=function(f){return 1/tanh(f)};var arcsech=function(f){return arccosh(1/f)};var arccsch=function(f){return arcsinh(1/f)};var arccoth=function(f){return arctanh(1/f)};var sign=function(f){return(f==0?0:(f<0?-1:1))};function factorial(f,h){if(h==null){h=1}for(var g=f-h;g>0;g-=h){f*=g}return(f<0?NaN:(f==0?1:f))}function C(f,g){var j=1;for(var h=0;h0){if(alertIfNoSVG){alert("To view the SVG pictures in Internet Explorer\ndownload the free Adobe SVGviewer from www.adobe.com/svg or\nuse Firefox 1.5 preview (called Deerpark)")}else{var ASbody=document.getElementsByTagName("body")[0];ASbody.insertBefore(nd,ASbody.childNodes[0])}}}if(nd==null){for(index=0;index",id+"script")}}}function switchTo(f){picture=document.getElementById(f);width=picture.getAttribute("width")-0;height=picture.getAttribute("height")-0;strokewidth="1";stroke="black";fill="none";marker="none";if((picture.nodeName=="EMBED"||picture.nodeName=="embed")&&isIE){svgpicture=picture.getSVGDocument().getElementById("root");doc=picture.getSVGDocument()}else{picture.setAttribute("onmousemove","updateCoords"+(f.slice(f.length-1)-1)+"()");svgpicture=picture;doc=document}xunitlength=svgpicture.getAttribute("xunitlength")-0;yunitlength=svgpicture.getAttribute("yunitlength")-0;xmin=svgpicture.getAttribute("xmin")-0;xmax=svgpicture.getAttribute("xmax")-0;ymin=svgpicture.getAttribute("ymin")-0;ymax=svgpicture.getAttribute("ymax")-0;origin=[svgpicture.getAttribute("ox")-0,svgpicture.getAttribute("oy")-0]}function updatePicture(obj){var src=document.getElementById((typeof obj=="string"?obj:"picture"+(obj+1)+"input")).value;xmin=null;xmax=null;ymin=null;ymax=null;xscl=null;xgrid=null;yscl=null;ygrid=null;initialized=false;switchTo((typeof obj=="string"?obj.slice(0,8):"picture"+(obj+1)));src=src.replace(/plot\(\x20*([^\"f\[][^\n\r]+?)\,/g,'plot("$1",');src=src.replace(/plot\(\x20*([^\"f\[][^\n\r]+)\)/g,'plot("$1")');src=src.replace(/([0-9])([a-zA-Z])/g,"$1*$2");src=src.replace(/\)([\(0-9a-zA-Z])/g,")*$1");try{with(Math){eval(src)}}catch(err){alert(err+"\n"+src)}}function showHideCode(g){var f=g.nextSibling;while(f!=null&&f.nodeName!="BUTTON"&&f.nodeName!="button"){f=f.nextSibling}if(f.style.display=="none"){f.style.display=""}else{f.style.display="none"}while(f!=null&&f.nodeName!="TEXTAREA"&&f.nodeName!="textarea"){f=f.previousSibling}if(f.style.display=="none"){f.style.display=""}else{f.style.display="none"}}function hideCode(){}function showcode(){}function nobutton(){}function setBorder(f){border=f}function initPicture(x_min,x_max,y_min,y_max){if(!initialized){strokewidth="1";strokedasharray=null;stroke="black";fill="none";fontstyle="italic";fontfamily="times";fontsize="16";fontweight="normal";fontstroke="none";fontfill="none";marker="none";initialized=true;if(x_min!=null){xmin=x_min}if(x_max!=null){xmax=x_max}if(y_min!=null){ymin=y_min}if(y_max!=null){ymax=y_max}if(xmin==null){xmin=-5}if(xmax==null){xmax=5}if(typeof xmin!="number"||typeof xmax!="number"||xmin>=xmax){alert("Picture requires at least two numbers: xmin < xmax")}else{if(y_max!=null&&(typeof y_min!="number"||typeof y_max!="number"||y_min>=y_max)){alert("initPicture(xmin,xmax,ymin,ymax) requires numbers ymin < ymax")}else{if(width==null){width=picture.getAttribute("width")}else{picture.setAttribute("width",width)}if(width==null||width==""){width=defaultwidth}if(height==null){height=picture.getAttribute("height")}else{picture.setAttribute("height",height)}if(height==null||height==""){height=defaultheight}xunitlength=(width-2*border)/(xmax-xmin);yunitlength=xunitlength;if(ymin==null){origin=[-xmin*xunitlength+border,height/2];ymin=-(height-2*border)/(2*yunitlength);ymax=-ymin}else{if(ymax!=null){yunitlength=(height-2*border)/(ymax-ymin)}else{ymax=(height-2*border)/yunitlength+ymin}origin=[-xmin*xunitlength+border,-ymin*yunitlength+border]}if(isIE){svgpicture=picture.getSVGDocument().getElementById("root");while(svgpicture.childNodes.length()>5){svgpicture.removeChild(svgpicture.lastChild)}svgpicture.setAttribute("width",width);svgpicture.setAttribute("height",height);doc=picture.getSVGDocument()}else{var qnode=document.createElementNS("http://www.w3.org/2000/svg","svg");qnode.setAttribute("id",picture.getAttribute("id"));qnode.setAttribute("style","display:inline");qnode.setAttribute("width",picture.getAttribute("width"));qnode.setAttribute("height",picture.getAttribute("height"));if(picture.parentNode!=null){picture.parentNode.replaceChild(qnode,picture)}else{svgpicture.parentNode.replaceChild(qnode,svgpicture)}svgpicture=qnode;doc=document;pointerpos=doc.getElementById("pointerpos");if(pointerpos==null){pointerpos=myCreateElementSVG("circle");pointerpos.setAttribute("id","pointerpos");pointerpos.setAttribute("cx",0);pointerpos.setAttribute("cy",0);pointerpos.setAttribute("r",0.5);pointerpos.setAttribute("fill","red");svgpicture.appendChild(pointerpos)}}svgpicture.setAttribute("xunitlength",xunitlength);svgpicture.setAttribute("yunitlength",yunitlength);svgpicture.setAttribute("xmin",xmin);svgpicture.setAttribute("xmax",xmax);svgpicture.setAttribute("ymin",ymin);svgpicture.setAttribute("ymax",ymax);svgpicture.setAttribute("ox",origin[0]);svgpicture.setAttribute("oy",origin[1]);var node=myCreateElementSVG("rect");node.setAttribute("x","0");node.setAttribute("y","0");node.setAttribute("width",width);node.setAttribute("height",height);node.setAttribute("style","stroke-width:1;fill:white");svgpicture.appendChild(node);if(!isIE&&picture.getAttribute("onmousemove")!=null){svgpicture.addEventListener("mousemove",mousemove_listener,true);var st=picture.getAttribute("onmousemove");svgpicture.addEventListener("mousemove",eval(st.slice(0,st.indexOf("("))),true);node=myCreateElementSVG("polyline");node.setAttribute("points","0,0 "+width+",0");node.setAttribute("style","stroke:white; stroke-width:3");node.addEventListener("mousemove",top_listener,true);svgpicture.appendChild(node);node=myCreateElementSVG("polyline");node.setAttribute("points","0,"+height+" "+width+","+height);node.setAttribute("style","stroke:white; stroke-width:3");node.addEventListener("mousemove",bottom_listener,true);svgpicture.appendChild(node);node=myCreateElementSVG("polyline");node.setAttribute("points","0,0 0,"+height);node.setAttribute("style","stroke:white; stroke-width:3");node.addEventListener("mousemove",left_listener,true);svgpicture.appendChild(node);node=myCreateElementSVG("polyline");node.setAttribute("points",(width-1)+",0 "+(width-1)+","+height);node.setAttribute("style","stroke:white; stroke-width:3");node.addEventListener("mousemove",right_listener,true);svgpicture.appendChild(node)}border=defaultborder}}}}function line(h,g,j){var f;if(j!=null){f=doc.getElementById(j)}if(f==null){f=myCreateElementSVG("path");f.setAttribute("id",j);svgpicture.appendChild(f)}f.setAttribute("d","M"+(h[0]*xunitlength+origin[0])+","+(height-h[1]*yunitlength-origin[1])+" "+(g[0]*xunitlength+origin[0])+","+(height-g[1]*yunitlength-origin[1]));f.setAttribute("stroke-width",strokewidth);if(strokedasharray!=null){f.setAttribute("stroke-dasharray",strokedasharray)}f.setAttribute("stroke",stroke);f.setAttribute("fill",fill);if(marker=="dot"||marker=="arrowdot"){ASdot(h,4,markerstroke,markerfill);if(marker=="arrowdot"){arrowhead(h,g)}ASdot(g,4,markerstroke,markerfill)}else{if(marker=="arrow"){arrowhead(h,g)}}}function path(j,l,k){if(k==null){k=""}var h,f,g;if(l!=null){h=doc.getElementById(l)}if(h==null){h=myCreateElementSVG("path");h.setAttribute("id",l);svgpicture.appendChild(h)}if(typeof j=="string"){f=j}else{f="M";f+=(j[0][0]*xunitlength+origin[0])+","+(height-j[0][1]*yunitlength-origin[1])+" "+k;for(g=1;g1e-8){j=[j[0]/o,j[1]/o];f=[-j[1],j[0]];var k=myCreateElementSVG("path");k.setAttribute("d","M "+(g[0]-15*j[0]-4*f[0])+" "+(g[1]-15*j[1]-4*f[1])+" L "+(g[0]-3*j[0])+" "+(g[1]-3*j[1])+" L "+(g[0]-15*j[0]+4*f[0])+" "+(g[1]-15*j[1]+4*f[1])+" z");k.setAttribute("stroke-width",markerstrokewidth);k.setAttribute("stroke",stroke);k.setAttribute("fill",stroke);svgpicture.appendChild(k)}}function chopZ(g){var f=g.indexOf(".");if(f==-1){return g}for(var h=g.length-1;h>f&&g.charAt(h)=="0";h--){}if(h==f){h--}return g.slice(0,h+1)}function grid(g,f){axes(g,f,null,g,f)}function noaxes(){if(!initialized){initPicture()}}function axes(dx,dy,labels,gdx,gdy){var x,y,ldx,ldy,lx,ly,lxp,lyp,pnode,st;if(!initialized){initPicture()}if(typeof dx=="string"){labels=dx;dx=null}if(typeof dy=="string"){gdx=dy;dy=null}if(xscl!=null){dx=xscl;gdx=xscl;labels=dx}if(yscl!=null){dy=yscl;gdy=yscl}if(xtick!=null){dx=xtick}if(ytick!=null){dy=ytick}dx=(dx==null?xunitlength:dx*xunitlength);dy=(dy==null?dx:dy*yunitlength);fontsize=Math.min(dx/2,dy/2,16);ticklength=fontsize/4;if(xgrid!=null){gdx=xgrid}if(ygrid!=null){gdy=ygrid}if(gdx!=null){gdx=(typeof gdx=="string"?dx:gdx*xunitlength);gdy=(gdy==null?dy:gdy*yunitlength);pnode=myCreateElementSVG("path");st="";for(x=origin[0];x0;x=x-gdx){st+=" M"+x+",0 "+x+","+height}for(y=height-origin[1];y0;y=y-gdy){st+=" M0,"+y+" "+width+","+y}pnode.setAttribute("d",st);pnode.setAttribute("stroke-width",0.5);pnode.setAttribute("stroke",gridstroke);pnode.setAttribute("fill",fill);svgpicture.appendChild(pnode)}pnode=myCreateElementSVG("path");st="M0,"+(height-origin[1])+" "+width+","+(height-origin[1])+" M"+origin[0]+",0 "+origin[0]+","+height;for(x=origin[0]+dx;x0;x=x-dx){st+=" M"+x+","+(height-origin[1]+ticklength)+" "+x+","+(height-origin[1]-ticklength)}for(y=height-origin[1]+dy;y0;y=y-dy){st+=" M"+(origin[0]+ticklength)+","+y+" "+(origin[0]-ticklength)+","+y}if(labels!=null){with(Math){ldx=dx/xunitlength;ldy=dy/yunitlength;lx=(xmin>0||xmax<0?xmin:0);ly=(ymin>0||ymax<0?ymin:0);lxp=(ly==0?"below":"above");lyp=(lx==0?"left":"right");var ddx=floor(1.1-log(ldx)/log(10))+1;var ddy=floor(1.1-log(ldy)/log(10))+1;for(x=ldx;x<=xmax;x=x+ldx){text([x,ly],chopZ(x.toFixed(ddx)),lxp)}for(x=-ldx;xmin<=x;x=x-ldx){text([x,ly],chopZ(x.toFixed(ddx)),lxp)}for(y=ldy;y<=ymax;y=y+ldy){text([lx,y],chopZ(y.toFixed(ddy)),lyp)}for(y=-ldy;ymin<=y;y=y-ldy){text([lx,y],chopZ(y.toFixed(ddy)),lyp)}}}pnode.setAttribute("d",st);pnode.setAttribute("stroke-width",0.5);pnode.setAttribute("stroke",axesstroke);pnode.setAttribute("fill",fill);svgpicture.appendChild(pnode)}function mathjs(h){h=h.replace(/\s/g,"");if(h.indexOf("^-1")!=-1){h=h.replace(/sin\^-1/g,"arcsin");h=h.replace(/cos\^-1/g,"arccos");h=h.replace(/tan\^-1/g,"arctan");h=h.replace(/sec\^-1/g,"arcsec");h=h.replace(/csc\^-1/g,"arccsc");h=h.replace(/cot\^-1/g,"arccot");h=h.replace(/sinh\^-1/g,"arcsinh");h=h.replace(/cosh\^-1/g,"arccosh");h=h.replace(/tanh\^-1/g,"arctanh");h=h.replace(/sech\^-1/g,"arcsech");h=h.replace(/csch\^-1/g,"arccsch");h=h.replace(/coth\^-1/g,"arccoth")}h=h.replace(/^e$/g,"(E)");h=h.replace(/^e([^a-zA-Z])/g,"(E)$1");h=h.replace(/([^a-zA-Z])e([^a-zA-Z])/g,"$1(E)$2");h=h.replace(/([0-9])([\(a-zA-Z])/g,"$1*$2");h=h.replace(/\)([\(0-9a-zA-Z])/g,")*$1");var l,g,f,m,o;while((l=h.indexOf("^"))!=-1){if(l==0){return"Error: missing argument"}g=l-1;m=h.charAt(g);if(m>="0"&&m<="9"){g--;while(g>=0&&(m=h.charAt(g))>="0"&&m<="9"){g--}if(m=="."){g--;while(g>=0&&(m=h.charAt(g))>="0"&&m<="9"){g--}}}else{if(m==")"){o=1;g--;while(g>=0&&o>0){m=h.charAt(g);if(m=="("){o--}else{if(m==")"){o++}}g--}while(g>=0&&(m=h.charAt(g))>="a"&&m<="z"||m>="A"&&m<="Z"){g--}}else{if(m>="a"&&m<="z"||m>="A"&&m<="Z"){g--;while(g>=0&&(m=h.charAt(g))>="a"&&m<="z"||m>="A"&&m<="Z"){g--}}else{return"Error: incorrect syntax in "+h+" at position "+g}}}if(l==h.length-1){return"Error: missing argument"}f=l+1;m=h.charAt(f);if(m>="0"&&m<="9"||m=="-"){f++;while(f="0"&&m<="9"){f++}if(m=="."){f++;while(f="0"&&m<="9"){f++}}}else{if(m=="("){o=1;f++;while(f0){m=h.charAt(f);if(m=="("){o++}else{if(m==")"){o--}}f++}}else{if(m>="a"&&m<="z"||m>="A"&&m<="Z"){f++;while(f="a"&&m<="z"||m>="A"&&m<="Z"){f++}}else{return"Error: incorrect syntax in "+h+" at position "+f}}}h=h.slice(0,g+1)+"pow("+h.slice(g+1,l)+","+h.slice(l+1,f)+")"+h.slice(f)}while((l=h.indexOf("!"))!=-1){if(l==0){return"Error: missing argument"}g=l-1;m=h.charAt(g);if(m>="0"&&m<="9"){g--;while(g>=0&&(m=h.charAt(g))>="0"&&m<="9"){g--}if(m=="."){g--;while(g>=0&&(m=h.charAt(g))>="0"&&m<="9"){g--}}}else{if(m==")"){o=1;g--;while(g>=0&&o>0){m=h.charAt(g);if(m=="("){o--}else{if(m==")"){o++}}g--}while(g>=0&&(m=h.charAt(g))>="a"&&m<="z"||m>="A"&&m<="Z"){g--}}else{if(m>="a"&&m<="z"||m>="A"&&m<="Z"){g--;while(g>=0&&(m=h.charAt(g))>="a"&&m<="z"||m>="A"&&m<="Z"){g--}}else{return"Error: incorrect syntax in "+h+" at position "+g}}}h=h.slice(0,g+1)+"factorial("+h.slice(g+1,l)+")"+h.slice(l+1)}return h}function plot(fun,x_min,x_max,points,id){var pth=[];var f=function(x){return x},g=fun;var name=null;if(typeof fun=="string"){eval("g = function(x){ with(Math) return "+mathjs(fun)+" }")}else{if(typeof fun=="object"){eval("f = function(t){ with(Math) return "+mathjs(fun[0])+" }");eval("g = function(t){ with(Math) return "+mathjs(fun[1])+" }")}}if(typeof x_min=="string"){name=x_min;x_min=xmin}else{name=id}var min=(x_min==null?xmin:x_min);var max=(x_max==null?xmax:x_max);var inc=max-min-0.000001*(max-min);inc=(points==null?inc/200:inc/points);var gt;for(var t=min;t<=max;t+=inc){gt=g(t);if(!(isNaN(gt)||Math.abs(gt)=="Infinity")){pth[pth.length]=[f(t),gt]}}path(pth,name);return p}function slopefield(fun,dx,dy){var g=fun;if(typeof fun=="string"){eval("g = function(x,y){ with(Math) return "+mathjs(fun)+" }")}var gxy,x,y,u,v,dz;if(dx==null){dx=1}if(dy==null){dy=1}dz=Math.sqrt(dx*dx+dy*dy)/6;var x_min=Math.ceil(xmin/dx);var y_min=Math.ceil(ymin/dy);for(x=x_min;x<=xmax;x+=dx){for(y=y_min;y<=ymax;y+=dy){gxy=g(x,y);if(!isNaN(gxy)){if(Math.abs(gxy)=="Infinity"){u=0;v=dz}else{u=dz/Math.sqrt(1+gxy*gxy);v=gxy*u}line([x-u,y-v],[x+u,y+v])}}}}function updateCoords(g){switchTo("picture"+(g+1));var h=getX(),f=getY();if((xmax-h)*xunitlength>6*fontsize||(f-ymin)*yunitlength>2*fontsize){text([xmax,ymin],"("+h.toFixed(2)+", "+f.toFixed(2)+")","aboveleft","AScoord"+g,"")}else{text([xmax,ymin]," ","aboveleft","AScoord"+g,"")}}function updateCoords0(){updateCoords(0)}function updateCoords1(){updateCoords(1)}function updateCoords2(){updateCoords(2)}function updateCoords3(){updateCoords(3)}function updateCoords4(){updateCoords(4)}function updateCoords5(){updateCoords(5)}function updateCoords6(){updateCoords(6)}function updateCoords7(){updateCoords(7)}function updateCoords8(){updateCoords(8)}function updateCoords9(){updateCoords(9)}ASfn=[function(){updatePicture(0)},function(){updatePicture(1)},function(){updatePicture(2)},function(){updatePicture(3)},function(){updatePicture(4)},function(){updatePicture(5)},function(){updatePicture(6)},function(){updatePicture(7)},function(){updatePicture(8)},function(){updatePicture(9)}];ASupdateCoords=[function(){updateCoords(0)},function(){updateCoords(1)},function(){updateCoords(2)},function(){updateCoords(3)},function(){updateCoords(4)},function(){updateCoords(5)},function(){updateCoords(6)},function(){updateCoords(7)},function(){updateCoords(8)},function(){updateCoords(9)}];function generic(){drawPictures()}if(typeof window.addEventListener!="undefined"){window.addEventListener("load",generic,false)}else{if(typeof document.addEventListener!="undefined"){document.addEventListener("load",generic,false)}else{if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",generic)}else{if(typeof window.onload=="function"){var existing=onload;window.onload=function(){existing();generic()}}else{window.onload=generic}}}};