abstract class f_interval extends Mathd
{
public abstract double func(double x);
public  interval inter_func(interval X)
{
interval pp=new interval(Math.min(func(X.a),func(X.b)),Math.max(func(X.a),func(X.b)));
return pp;
}
}

class fi extends f_interval
{
 public double func(double x)
 {return Math.exp(x);}
}


public class interval
{
double a,b;

public static double min(double a,double b,double c,double d)
{ double min=1e60;
  if(a<min) min=a;
  if(b<min) min=b;
  if(c<min) min=c;
  if(d<min) min=d;
  return min;	
}

public static double max(double a,double b,double c,double d)
{ double max=-1e60;
  if(a>max) max=a;
  if(b>max) max=b;
  if(c>max) max=c;
  if(d>max) max=d;
  return max;	
}

public double midpoint()
{return (a+b)/2.0;}
public double m()
{return (a+b)/2.0;}
public static double midpoint(interval left)
{return (left.a+left.b)/2.0;}
public static double m(interval left)
{return (left.a+left.b)/2.0;}

public double width()
{return (b-a);}
public double w()
{return (b-a);}
public static double width(interval left)
{return (left.b-left.a);}
public static double w(interval left)
{return (left.b-left.a);}

public double magnitude()
{return Math.max(Math.abs(a),Math.abs(b));}

public static double magnitude(interval left)
{return Math.max(Math.abs(left.a),Math.abs(left.b));}

public static boolean equal(interval left,interval right)
{return (left.a==right.a && left.b==right.b);}
public static boolean smaller(interval left,interval right)
{return (left.b<right.a);}
public static boolean bigger(interval left,interval right)
{return (left.a<right.b);}

public interval(double ai,double bi)
{a=ai;b=bi;}
public interval()
{a=0.0;b=0.0;}
public interval(interval ci)
{a=ci.a;b=ci.b;}

public void intersection(interval  right)
{
  double c=right.a;
  double d=right.b;
  double a1=Math.max(a,c);
  double b1=Math.min(b,d);
  a=a1;
  b=b1;
}

public static interval intersection(interval  left,interval right)
{ 
  double a=left.a;
  double b=left.b;
  double c=right.a;
  double d=right.b;
  double a1=Math.max(a,c);
  double b1=Math.min(b,d);
  interval pp=new interval(a1,b1);
  return pp;
}
//====Union
public void union(interval  right)
{
  double c=right.a;
  double d=right.b;
  double a1=Math.min(a,c);
  double b1=Math.max(b,d);
  a=a1;
  b=b1;
}

public static interval union(interval  left,interval right)
{ 
  double a=left.a;
  double b=left.b;
  double c=right.a;
  double d=right.b;
  double a1=Math.min(a,c);
  double b1=Math.max(b,d);
  interval pp=new interval(a1,b1);
  return pp;
}
//====
public void add(interval  right)
{ double c=right.a;
  double d=right.b;
  double a1=min((a+c),(a+d),(b+c),(b+d));
  double b1=max((a+c),(a+d),(b+c),(b+d));
  a=a1;
  b=b1;
}

public void add(double c,double d)
{
  double a1=min((a+c),(a+d),(b+c),(b+d));
  double b1=max((a+c),(a+d),(b+c),(b+d));
  a=a1;
  b=b1;
}

public static interval add(interval  left,interval right)
{ double a1=left.a;
  double b1=left.b;
  double c=right.a;
  double d=right.b;
  double a2=min((a1+c),(a1+d),(b1+c),(b1+d));
  double b2=max((a1+c),(a1+d),(b1+c),(b1+d));
  interval dd=new interval(a2,b2);
  return dd;
}
//substract
public void substract(interval  right)
{ double c=right.a;
  double d=right.b;
  double a1=min((a-c),(a-d),(b-c),(b-d));
  double b1=max((a-c),(a-d),(b-c),(b-d));
  a=a1;
  b=b1;
}

public void substract(double c,double d)
{
  double a1=min((a-c),(a-d),(b-c),(b-d));
  double b1=max((a-c),(a-d),(b-c),(b-d));
  a=a1;
  b=b1;
}

public static interval substract(interval  left,interval right)
{ double a1=left.a;
  double b1=left.b;
  double c=right.a;
  double d=right.b;
  double a2=min((a1-c),(a1-d),(b1-c),(b1-d));
  double b2=max((a1-c),(a1-d),(b1-c),(b1-d));
  interval dd=new interval(a2,b2);
  return dd;
}
//multiply
public void multiply(interval  right)
{ double c=right.a;
  double d=right.b;
  double a1=min((a*c),(a*d),(b*c),(b*d));
  double b1=max((a*c),(a*d),(b*c),(b*d));
  a=a1;
  b=b1;
}

public void multiply(double c,double d)
{
  double a1=min((a*c),(a*d),(b*c),(b*d));
  double b1=max((a*c),(a*d),(b*c),(b*d));
  a=a1;
  b=b1;
}

public static interval multiply(interval  left,interval right)
{ double a1=left.a;
  double b1=left.b;
  double c=right.a;
  double d=right.b;
  double a2=min((a1*c),(a1*d),(b1*c),(b1*d));
  double b2=max((a1*c),(a1*d),(b1*c),(b1*d));
  interval dd=new interval(a2,b2);
  return dd;
}

//divide
public void divide(interval  right)
{ double c=right.a;
  double d=right.b;
  double a1=min((a/c),(a/d),(b/c),(b/d));
  double b1=max((a/c),(a/d),(b/c),(b/d));
  a=a1;
  b=b1;
}

public void divide(double c,double d)
{
  double a1=min((a/c),(a/d),(b/c),(b/d));
  double b1=max((a/c),(a/d),(b/c),(b/d));
  a=a1;
  b=b1;
}


public static interval divide(interval  left,interval right)
{ double a1=left.a;
  double b1=left.b;
  double c=right.a;
  double d=right.b;
  double a2=min((a1/c),(a1/d),(b1/c),(b1/d));
  double b2=max((a1/c),(a1/d),(b1/c),(b1/d));
  interval dd=new interval(a2,b2);
  return dd;
}
//power

public void pow(int n)
{   interval dd;
    int n1=n%2;
	if(n==0) {System.out.println("n="+n);dd=new interval(1.0,1.0);}
	else if(n1==0) {dd=new interval(Math.min(Math.pow(a,n),Math.pow(b,n)),
	                                  Math.min(Math.pow(a,n),Math.pow(b,n)));}
	else {dd=new interval(0.0,Math.min(Math.pow(a,n),Math.pow(b,n)));}                                 
    a=dd.a;
    b=dd.b;
}
public static interval pow(interval  left,int n)
{   interval dd;
    int n1=n%2;
	if(n==0) {System.out.println("n="+n); dd=new interval(1.0,1.0);}
	else
	{
	if(n1!=0) 
	{dd=new interval(Math.min(Math.pow(left.a,n),Math.pow(left.b,n)),
	 Math.max(Math.pow(left.a,n),Math.pow(left.b,n)));
	}
	else {dd=new interval(0.0,Math.max(Math.pow(left.a,n),Math.pow(left.b,n)));}                                 
    }
	return dd;
}

public void pow(double n)
{   interval dd;
    int n1=(int)n;
    if(n1==n) dd=pow(this,n1);
    else
    {
	if(n==0) {System.out.println("rpow n="+n);dd=new interval(1.0,1.0);}
	else dd=new interval(Math.min(Math.pow(a,n),Math.pow(b,n)),
	                     Math.max(Math.pow(a,n),Math.pow(b,n))); 
    }                                
    a=dd.a;
    b=dd.b;
}

public static interval pow(interval  left,double n)
{   interval dd;
    int n1=(int)n;
    if(n1==n) return pow(left,n1);
    else
    {
	if(n==0) {dd=new interval(1.0,1.0);}
	else 
	{dd=new interval(Math.min(Math.pow(left.a,n),Math.pow(left.b,n)),
	                 Math.max(Math.pow(left.a,n),Math.pow(left.b,n)));}                                 
    }
	return dd;
}

//square
public void sqr()
{ double c=a;
  double d=b;
  double a1=min((a*c),(a*d),(b*c),(b*d));
  if(a1<0) a1=0.0;
  double b1=max((a*c),(a*d),(b*c),(b*d));
  a=a1;
  b=b1;
}

public static interval sqr(interval  left)
{ double a1=left.a;
  double b1=left.b;
  double c=left.a;
  double d=left.b;
  double a2=min((a1*c),(a1*d),(b1*c),(b1*d));
  if(a2<0) a2=0.0;
  double b2=max((a1*c),(a1*d),(b1*c),(b1*d));
  interval dd=new interval(a2,b2);
  return dd;
}

public String toString()
{String s="["+a+","+b+"]";
return s;
}

public static void main(String arg[])
{
interval A=new interval(-1.0,2.0);
interval C=interval.pow(A,2.0);
System.out.println(C.toString());

}

}