protected static Ptg calcErf( Ptg[] operands ) throws FunctionNotSupportedException
	{
		if( operands.length < 1 )
		{
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
		try
		{
			double lower_limit = operands[0].getDoubleVal();
			double upper_limit = Double.NaN;    //lower_limit;
			if( operands.length == 2 )
			{
				upper_limit = operands[1].getDoubleVal();
			}
			// If lower_limit is negative, ERF returns the #NUM! error value.
			// If upper_limit is negative, ERF returns the #NUM! error value.
//			if (lower_limit < 0 /*|| upper_limitupper_limit < 0*/) return new PtgErr(PtgErr.ERROR_NUM);
			boolean neg = (lower_limit < 0);
			lower_limit = Math.abs( lower_limit );

			double result;
			double limit = lower_limit;
			/*
			// try this: from "Computation of the error function erf in arbitrary precision with correct rounding"
			double r= 0;
			double r1= 0;
			double estimate= (2/Math.sqrt(Math.PI))*(limit - Math.pow(limit, 3)/3.0);
			double convergence= Math.pow(2, estimate-15); 
			for (int i= 0, n= 0; n < 100; i++, n++) {
				double factor= 2.0*n + 1.0;
				double z= Math.pow(limit, factor);
				double zz= (MathFunctionCalculator.factorial(n)*factor);
				double zzz= z/zz;
				if ((i % 2)!=0)
					r= r-zzz;
				else
					r= r+zzz;
				
				if (Math.abs(r)-r1) <
				
				r1= Math.abs(r1);
			}
			result= r*(2.0/Math.sqrt(Math.PI));*/

			if( limit < 0.005 )
			{
				/* A&S 7.1.1 - good to at least 6 digts ... but not for larger values ... sigh ...*/
				double r = 0;
				for( int i = 0, n = 0; n < 12; i++, n++ )
				{
					double factor = (2.0 * n) + 1.0;
					double z = Math.pow( limit, factor );
					double zz = (MathFunctionCalculator.factorial( n ) * factor);
					double zzz = z / zz;
					if( (i % 2) != 0 )
					{
						r = r - zzz;
					}
					else
					{
						r = r + zzz;
					}
				}
				result = r * (2.0 / Math.sqrt( Math.PI ));
			}
			else
			{
				result = erf_try1( limit );
			}

			if( neg )
			{
				result *= -1;
			}

			if( !Double.isNaN( upper_limit ) )
			{    // Erf(upper)-Erf(lower)
				Ptg result2 = calcErf( new Ptg[]{ operands[1] } );
				if( result2 instanceof PtgNumber )
				{
					result = result2.getDoubleVal() - result;
				}
				else
				{
					return new PtgErr( PtgErr.ERROR_VALUE );
				}
			}

			return new PtgNumber( result );

		}
		catch( Exception e )
		{
			return new PtgErr( PtgErr.ERROR_VALUE );
		}
	}