/* RCS $Id: j_atan.c,v 1.2 1997/07/15 14:57:04 ae13 Exp $ */
/*
$Log: j_atan.c,v $
 * Revision 1.2  1997/07/15  14:57:04  ae13
 * *** empty log message ***
 *
 * Revision 1.1  1997/05/16  13:26:20  ae13
 * Initial revision
 *
 */
/****************************************************************/
/*                                                              */
/*      Entries         : a_intv j_atan(a_intv x)               */
/*                        a_intv x  ;                           */
/*                                                              */
/*      Arguments       : x = interval argument of atan(x)      */
/*                                                              */
/*      Description     : Fast interval arcus tangent           */
/*                        function for double IEEE              */
/*                        Floating-Point Arithmetic             */
/*                                                              */
/*      Date            : 1996-03-08                            */
/*                                                              */
/*      Author          : W. Hofschuster                        */
/*                                                              */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif


#include "q_defs.h"
#include "q_fcth.h"

#ifdef LINT_ARGS
local a_intv j_atan(a_intv x)
#else
local a_intv j_atan(x)

a_intv x;
#endif
{
  a_intv res;
  if (x.INF==x.SUP)             /* point interval */
    { 
       if (x.INF<0)
        {
          if (x.INF>-q_atnt)
            {
               res.INF=x.INF;
               res.SUP=r_succ(x.INF);
            }
          else
            {
              res.INF=q_atan(x.INF);
              res.SUP=res.INF*q_ctnm;
              res.INF*=q_ctnp;
              if (res.INF<x.INF) res.INF=x.INF;
            } 
        }
       else 
         {
           if (x.INF<q_atnt)
             {         
               res.SUP=x.INF;
               if (x.INF==0)
                  res.INF=0; 
               else
                  res.INF=r_pred(x.INF);
             }
           else
             {
                res.INF=q_atan(x.INF);
                res.SUP=res.INF*q_ctnp;
                res.INF*=q_ctnm;
                if (res.SUP>x.INF) res.SUP=x.INF;
             }
        }
    }
  else
    {
      if (x.INF<=0)
        {
          if (x.INF>-q_atnt)
            res.INF=x.INF;         /* includes the case x.INF=0 */
          else
            {
              res.INF=q_atan(x.INF)*q_ctnp;
              if (res.INF<x.INF) res.INF=x.INF;
            }          
        }
      else  /* now x.INF>0 */
        {
          if (x.INF<q_atnt)
            res.INF=r_pred(x.INF);      
          else 
            res.INF=q_atan(x.INF)*q_ctnm;
        }
      if (x.SUP<0)
        {
          if (x.SUP>-q_atnt)
            res.SUP=r_succ(x.SUP);
          else
            res.SUP=q_atan(x.SUP)*q_ctnm;          
        }
      else  /* x.SUP>=0 */
        {
          if (x.SUP<q_atnt)
            res.SUP=x.SUP;          /* includes the case x.SUP=0  */       
          else
            { 
              res.SUP=q_atan(x.SUP)*q_ctnp;
              if (res.SUP>x.SUP) res.SUP=x.SUP;
            }
        }
    }   
  return(res);
}

