Sindbad~EG File Manager

Current Path : /usr/home/beeson/MathXpert/trigcalc/
Upload File :
Current File : /usr/home/beeson/MathXpert/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 moved to trigcalc.dll
8.13.98 last modified
10.24.23  eliminated OEM symbol for \int and \sqrt
*/
#include <string.h>
#include <assert.h>

#include "globals.h"
#include "ops.h"
#include "calc.h"
#include "factor.h"
#include "prover.h"
#include "algaux.h"
#include "symbols.h"

/*____________________________________________________________________*/
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,"$$integral(arcsin t, t) = t arcsin t + sqrt(1-t^2)$$");
  return 0;
}
/*____________________________________________________________________*/
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,"$$integral(arccos t,t) = t arccos t - sqrt(1-t^2)$$");
  return 0;
}
/*____________________________________________________________________*/
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,"$$ integral(arctan t,t) = t arctan t - (1/2) ln(1+t^2)$$");
  return 0;
}
/*____________________________________________________________________*/
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,"$$integral(arccot t,t) = t arccot t +(1/2)ln(1+t^2)$$");
  return 0;
}

/*____________________________________________________________________*/
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 = check1(lessthan(zero,x));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check1(lessthan(zero,lo));
       if(err)
          return 1;
       err = check1(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,"$$integral(arccsc t,t) = t arccsc t + ln(t + sqrt(1+t^2))$$");
  return 0;
}
/*____________________________________________________________________*/
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 = check1(lessthan(x,zero));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check1(lessthan(hi,zero));
       if(err)
          return 1;
       err = check1(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,"$$integral(arccsc t,t) = t arccsc t - ln(t+sqrt(1+t^2))$$");
  return 0;
}

/*____________________________________________________________________*/
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 = check1(lessthan(zero,x));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check1(lessthan(zero,lo));
       if(err)
          return 1;
       err = check1(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,"$$integral(arcssec t,t) = t arcsec t- ln(t + sqrt(1+t^2))$$");
  return 0;
}
/*____________________________________________________________________*/
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 = check1(lessthan(x,zero));
       if(err)
          return 1;
     }
  else if(ARITY(t) == 4)
     { lo = ARG(2,t);
       hi = ARG(3,t);
       err = check1(lessthan(hi,zero));
       if(err)
          return 1;
       err = check1(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,"$$ integral(arcsec t,t) = t arcsec t + ln(t+sqrt(1+t^2))$$");
  return 0;
}


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