function writeEq(degree, variable, coeffs)
{
	var x = variable;
	var equation = "";
		
	//first term (unique case)
	if(coeffs[0] == 1)
	{
		equation += x;
	}
	else if(coeffs[0] == -1)
	{
		equation += "-" + x;
	}
	else
	{
		equation += coeffs[0] + x;
	}
	equation += "<sup>" + degree + "</sup>";
	
	
	//remaining terms
	for(i = 1; i < coeffs.length - 1; i++)
	{
		if(coeffs[i] == 1)
		{
			equation += " + " + x;
		}
		else if(coeffs[i] == -1)
		{
			equation += " - " + x;
		}
		else if(coeffs[i] > 1)
		{
			equation += " + " + coeffs[i] + x;
		}
		else if(coeffs[i] < -1)
		{
			equation += " - " + Math.abs(coeffs[i]) + x;
		}
		else if(coeffs[i] > 0 && coeffs[i] < 1)
		{
			equation += " + " + coeffs[i] + x;
		}
		else if(coeffs[i] > -1 && coeffs[i] < 0)
		{
			equation += " - " + Math.abs(coeffs[i]) + x;
		}
		else
			{}
		if((degree - i) != 1 && coeffs[i] != 0)
			{equation += "<sup>" + (degree - i) + "</sup>";}
	}
	
			
	//last term (constant, unique case)
	if(coeffs[coeffs.length - 1] < 0)
	{
		equation += " - " + Math.abs(coeffs[coeffs.length - 1]);
	}
	else if(coeffs[coeffs.length - 1] > 0)
	{
		equation += " + " + coeffs[coeffs.length - 1];
	}
	else
		{}
	
	return equation;
}
