Sindbad~EG File Manager

Current Path : /usr/home/beeson/Otter-Lambda/yyy/trigcalc/
Upload File :
Current File : /usr/home/beeson/Otter-Lambda/yyy/trigcalc/arctrig.c

/* M. Beeson, for MathXpert */
/* Operators for integrating arctrig functions */
/*
5.23.95 original date
12.30.95 code last modified
1.29.98 TRIGCALC_DLL and MEXPORT_TRIGCALC
8.13.98 last modified
*/
#include <string.h>
#include <assert.h>
#define TRIGCALC_DLL
#include "globals.h"
#include "ops.h"
#include "calc.h"
#include "factor.h"
#include "prover.h"
#include "algaux.h"
#include "symbols.h"

/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intasin(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ASIN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(product(x,asin1(x)),sqrt1(sum(one,tnegate(make_power(x,two)))));
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arcsin t dt$ =          $t arcsin t + �(1-t^2)$");
  return 0;
}
/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intacos(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ACOS)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(product(x,acos1(x)),tnegate(sqrt1(sum(one,tnegate(make_power(x,two))))));
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arccos t dt$ =          $t arccos t - �(1-t^2)$");
  return 0;
}
/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intatan(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ATAN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(product(x,atan1(x)),
             tnegate(product(make_fraction(one,two),
                             ln1(sum(one,make_power(x,two)))
                            )
                    )
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arctan t dt$ =       $t arctan t-�ln(1+t^2)$");
  return 0;
}
/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intacot(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ACOT)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(product(x,acot1(x)),
             product(make_fraction(one,two),
                     ln1(sum(one,make_power(x,two)))
                    )
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arccot t dt$ =       $t arccot t+(1/2)ln(1+t^2)$");
  return 0;
}

/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intacscplus(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  term hi, lo;
  int err;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ACSC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(ARITY(t) == 2)
     { err = check(lessthan(zero,x));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check(lessthan(zero,lo));
       if(err)
          return 1;
       err = check(lessthan(zero,hi));
       if(err)
          return 1;
     }
  temp = sum(product(x,acsc1(x)),
             ln1(sum(x,sqrt1(sum(make_power(x,two),minusone))))
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arccsc t dt$ =       $t arccsc t+ln(t+�(1+t^2))$");
  return 0;
}
/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intacscminus(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  int err;
  term lo,hi;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ACSC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(ARITY(t) == 2)
     { err = check(lessthan(x,zero));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check(lessthan(hi,zero));
       if(err)
          return 1;
       err = check(lessthan(lo,zero));
       if(err)
          return 1;
     }
  temp = sum(product(x,acsc1(x)),
             tnegate(ln1(sum(x,sqrt1(sum(make_power(x,two),minusone)))))
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arccsc t dt$ =       $t arccsc t-ln(t+�(1+t^2))$");
  return 0;
}

/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intasecplus(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  term hi, lo;
  int err;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ASEC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(ARITY(t) == 2)
     { err = check(lessthan(zero,x));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check(lessthan(zero,lo));
       if(err)
          return 1;
       err = check(lessthan(zero,hi));
       if(err)
          return 1;
     }
  temp = sum(product(x,asec1(x)),
             tnegate(ln1(sum(x,sqrt1(sum(make_power(x,two),minusone)))))
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arcsec t dt$ =       $t arcsec t-ln(t+�(1+t^2))$");
  return 0;
}
/*____________________________________________________________________*/
MEXPORT_TRIGCALC int intasecminus(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  int err;
  term lo,hi;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != ASEC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(ARITY(t) == 2)
     { err = check(lessthan(x,zero));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check(lessthan(hi,zero));
       if(err)
          return 1;
       err = check(lessthan(lo,zero));
       if(err)
          return 1;
     }
  temp = sum(product(x,asec1(x)),
             ln1(sum(x,sqrt1(sum(make_power(x,two),minusone))))
            );
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = temp;
  else if (ARITY(t)==4)  /* a definite integral */
     *next = evalat(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"$�arcsec t dt$ =       $t arcsec t+ln(t+�(1+t^2))$");
  return 0;
}


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists