Sindbad~EG File Manager

Current Path : /usr/home/beeson/MathXpert/trigcalc/
Upload File :
Current File : /usr/home/beeson/MathXpert/trigcalc/inttrig.c

/* MathXpert 'table lookup' operators that integrate ln, exp, trig and
inverse trig functions, and operators that result in inverse trig answers */
/*
M. Beeson
11.5.91 Original date
10.23.99 modified
3.22.01  corrected an error in extender().
10.29.23 eliminated OEM symbols
*/

#include <string.h>
#include <assert.h>

#include "globals.h"
#include "ops.h"
#include "trig.h"
#include "calc.h"
#include "factor.h"
#include "prover.h"
#include "algaux.h"
#include "symbols.h"
#include "errbuf.h"
#include "autosimp.h"
#include "pvalaux.h"  /* twoparts */

static int intexp(term t, term *next);
/*_______________________________________________________________________*/
int intcos(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) != COS)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sin1(x);
  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,"$\\int cos t dt = sin t$");
  return 0;
}
/*_______________________________________________________________________*/
int intsin(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) != SIN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = tnegate(cos1(x));
  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,"$\\int sin t dt = -cos t$");
  return 0;
}

/*_______________________________________________________________________*/
int intexponential(term t, term arg, term *next, char *reason)
{ term u,v,x,temp;
  int err;
  unsigned short path[5];
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  x = ARG(1,t);
  if(FUNCTOR(ARG(0,t)) != '^')
     return 1;
  u = ARG(0,ARG(0,t));
  if(equals(u,eulere))
     return 1;
  v = ARG(1,ARG(0,t));   /* u^v */
  err = check1(positive(u));
  if(err)
     { err = infer(negative(u));
       errbuf(0, err? english(688) : english(699));
         /* Can't take ln of non-positive [negative] number */
       return 1;
     }
  temp = make_power(eulere,product(ln1(u),v));  /* new integrand */
  if(ARITY(t) == 2)  /* an indefinite integral */
     *next = integral(temp,x);
  else if (ARITY(t)==4)  /* a definite integral */
     *next = definite_integral(temp,x,ARG(2,t),ARG(3,t));
  SETCOLOR(*next,YELLOW);
  strcpy(reason,"a^b = e^(b ln a)");
  path[0] = INTEGRAL;
  path[1] = 1;
  path[2] = 0;
  set_pathtail(path);
  SetShowStepOperation(introducelninexponent);
  return 0;
}

/*_______________________________________________________________________*/
int inttoatan(term t, term arg, term *next, char *reason)
{ term u,x,v,a,b,temp,p,q;
  int err;
  int flag;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  if(FUNCTOR(u) != '/')
     return 1;
  if(!ONE(ARG(0,u)))
     return 1;
  v = ARG(1,u);
  if(FUNCTOR(v) != '+')
     return 1;
  if(ARITY(v) != 2)
     return 1;
  p = ARG(0,v);
  q = ARG(1,v);
  if(FUNCTOR(p)=='^' && equals(ARG(1,p),two) && equals(ARG(0,p),x))
     { b = q;
       flag = 2;
     }
  else if (FUNCTOR(q)=='^' && equals(ARG(1,q),two) && equals(ARG(0,q),x))
     { b = p;
       flag = 1;
     }
  else
     return 1;
  /* so now u = 1/(b + x^2)  */
  if(depends(b,x))
     return 1;  /* b must be constant */
  err = sqrt_aux(b,&a);  /* see factor.c */
  if(err)
     { err = check1(le(zero,b));
       if(err)
          return 1;  /* the square root can't be taken */
       a = make_sqrt(b);
     }
  if(ONE(a))
     { temp = atan1(x);
       if(ONE(p))
          strcpy(reason,"$\\int 1/(1+t^2)dt= arctan t$");
       else
          strcpy(reason,"$\\int 1/(t^2+1)dt= arctan t$");
     }
  else
     { temp = product(make_fraction(one,a),atan1(make_fraction(x,a)));
       if(flag==2)
          strcpy(reason,"$\\int 1/(t^2+a^2) dt$ =          $(1/a)arctan(t/a)$");
       else
          strcpy(reason,"$\\int 1/(a^2+t^2) dt$ =          $(1/a)arctan(t/a)$");
     }

  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);
  return 0;
}

/*______________________________________________________________________*/
int intln(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  int err;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  x = ARG(1,t);
  u = ARG(0,t);
  if(FUNCTOR(u) != LN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(ARITY(t) == 4)
     { if(ZERO(ARG(2,t)) || ZERO(ARG(3,t)))
          { errbuf(0,english(2364));
            /* It is not correct to apply this operation to an improper integral */
            return 1;
          }
       err = check1(lessthan(zero,ARG(2,t)));
       if(err)
          { errbuf(0, english(2364));
            return 1;
          }
       err = check1(lessthan(zero,ARG(3,t)));
       if(err)
          { errbuf(0, english(2364));
            return 1;
          }
     }
  temp = sum(product(x,ln1(x)),tnegate(x));
  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,"$\\int ln t dt = t ln t - t$");
  return 0;
}
/*_______________________________________________________________________*/
int intexp1(term t, term arg, term *next, char *reason)
/* \\int e^t dt = e^t           */
{ int err;
  term x;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  x = ARG(1,t);
  if(!equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  if(!equals(ARG(1,ARG(0,t)),x))
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason,"$\\int e^t dt = e^t$");
  return 0;
}
/*_______________________________________________________________________*/
int intexp2(term t, term arg, term *next, char *reason)
  /* \\int e^at dt =(1/a) e^(at)  */
{ int err;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  if(FUNCTOR(ARG(1,ARG(0,t))) != '*')
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason,"$\\int e^(ct) dt=(1/c) e^t$");
  return 0;
}

/*_______________________________________________________________________*/
int intexp3(term t, term arg, term *next, char *reason)
/* \\int e^(-t)dt = -e^(-t)     */
{ int err;
  term x;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  x = ARG(1,t);
  if(!equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  if(!NEGATIVE(ARG(1,ARG(0,t))))
     return 1;
  if(!equals(ARG(0,ARG(1,ARG(0,t))),x))
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason, "$\\int e^(-t)dt = -e^(-t)$");
  return 0;
}

/*_______________________________________________________________________*/
int intexp4(term t, term arg, term *next, char *reason)
/* \\int e^(-at)dt = -(1/a) e^(-at) */
{ int err;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  if(!NEGATIVE(ARG(1,ARG(0,t))))
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason,"$\\int e^(-ct)dt=-(1/a)e^(-ct)$");
  return 0;
}

/*_______________________________________________________________________*/
int intexp5(term t, term arg, term *next, char *reason)
/* \\int e^(t/a)dt = a e^(t/a)   */
{ int err;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason,"$\\int e^(t/a)dt = a e^(t/a)$");
  return 0;
}

/*_______________________________________________________________________*/
int intexp6(term t, term arg, term *next, char *reason)
/* integral c^t dt = (1/ln c) c^t  */
{ int err;
  term x;
  if(FUNCTOR(t) != INTEGRAL || FUNCTOR(ARG(0,t)) != '^')
     return 1;
  x = ARG(1,t);
  if(depends(ARG(0,ARG(0,t)),x))
     return 1;
  if(equals(ARG(0,ARG(0,t)),eulere))
     return 1;
  err = intexp(t,next);
  if(err)
     return 1;
  strcpy(reason,"$\\int c^t dt = (1/ln c) c^t$");
  return 0;
}
/*_______________________________________________________________________*/
static int intexp(term t, term *next)
/* Do the work of the above six operations */
{ term x,integrand,temp,c,v,power,base;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  x = ARG(1,t);
  base = eulere;
  integrand = ARG(0,t);
  if(FUNCTOR(integrand) == '^' &&  equals(ARG(0,integrand),eulere))
     power = ARG(1,integrand);
  else if(!depends(ARG(0,integrand),x))
     { base = ARG(0,integrand);
       power = ARG(1,integrand);
     }
  else
     return 1;
  twoparts(power,x,&c,&v);
  if(!equals(v,x))
     return 1;
  if(FUNCTOR(c) != '/')
     temp = signedfraction(ARG(0,t),c);
  else
     { if(INTEGERP(ARG(0,c)) && INTEGERP(ARG(1,c)) && (get_ringflag() & RATRING))
          temp = product(make_fraction(ARG(1,c),ARG(0,c)),ARG(0,t));
       else
          temp = make_fraction(product(ARG(1,c),ARG(0,t)),ARG(0,c));
     }
  if(!equals(base,eulere))
     polyval(product(reciprocal(ln1(base)),temp),&temp);
  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));
  HIGHLIGHT(*next);
  return 0;
}
/*_______________________________________________________________________*/
int inttan(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  u = ARG(0,t);
  if(FUNCTOR(u) != TAN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = tnegate(ln1(abs1(cos1(x))));
  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,"$\\int tan t dt= -ln|cos t|$");
  return 0;
}

/*_______________________________________________________________________*/
int intcot(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  u = ARG(0,t);
  if(FUNCTOR(u) != COT)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = ln1(abs1(sin1(x)));
  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,"$\\int cot t dt = ln|sin t|$");
  return 0;
}

/*_______________________________________________________________________*/
int intsec(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  u = ARG(0,t);
  if(FUNCTOR(u) != SEC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = ln1(abs1(sum(sec1(x),tan1(x))));
  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,"$\\int sec t dt$ =           $ln |sec t + tan t|$");
  return 0;
}
/*_______________________________________________________________________*/
int intcsc(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  u = ARG(0,t);
  if(FUNCTOR(u) != CSC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = ln1(abs1(sum(csc1(x),tnegate(cot1(x)))));
  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,"$\\int csc t dt$ =           $ln |csc t - cot t|$");
  return 0;
}

/*_______________________________________________________________________*/
int intcscsq(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  if(FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(1,ARG(0,t)),two))
     return 1;
  u = ARG(0,ARG(0,t));
  if(FUNCTOR(u) != CSC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = tnegate(cot1(x));
  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,"$\\int csc t dt = -cot t$");
  return 0;
}

/*_______________________________________________________________________*/
int intcotsq(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  if(FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(1,ARG(0,t)),two))
     return 1;
  u = ARG(0,ARG(0,t));
  if(FUNCTOR(u) != COT)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(tnegate(cot1(x)),tnegate(x));
  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,"$\\int cot^2 t dt=-cot t - t$");
  return 0;
}

/*_______________________________________________________________________*/
int intsecsq(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  if(FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(1,ARG(0,t)),two))
     return 1;
  u = ARG(0,ARG(0,t));
  if(FUNCTOR(u) != SEC)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = tan1(x);
  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,"$\\int sec^2 t dt = tan t$");
  return 0;
}

/*_______________________________________________________________________*/
int inttansq(term t, term arg, term *next, char *reason)
{ term u,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  if(FUNCTOR(ARG(0,t)) != '^')
     return 1;
  if(!equals(ARG(1,ARG(0,t)),two))
     return 1;
  u = ARG(0,ARG(0,t));
  if(FUNCTOR(u) != TAN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  temp = sum(tan1(x),tnegate(x));
  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,"$\\int tan^2 t dt=tan t - t$");
  return 0;
}
/*_______________________________________________________________________*/
int inttosec(term t, term arg, term *next, char *reason)
/* \\int sec t tan t dt = sec t  */
{ term u,v,w,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  w = ARG(0,t);
  if(FUNCTOR(w) != '*' || ARITY(w) != 2)
     return 1;
  u = ARG(0,w);
  v = ARG(1,w);
  if(FUNCTOR(u) != SEC && FUNCTOR(u) != TAN)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(FUNCTOR(v) != SEC && FUNCTOR(v) != TAN)
     return 1;
  if(!equals(ARG(0,v),x))
     return 1;
  if(FUNCTOR(u) == FUNCTOR(v))
     return 1;
  temp = sec1(x);
  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,"$\\int sec t tan t dt$ =     sec t");
  return 0;
}
/*_______________________________________________________________________*/
int inttocsc(term t, term arg, term *next, char *reason)
/* \\int csc t cot t dt = -csc t  */
{ term u,v,w,x,temp;
  if(FUNCTOR(t) != INTEGRAL)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  x = ARG(1,t);
  w = ARG(0,t);
  if(FUNCTOR(w) != '*' || ARITY(w) != 2)
     return 1;
  u = ARG(0,w);
  v = ARG(1,w);
  if(FUNCTOR(u) != CSC && FUNCTOR(u) != COT)
     return 1;
  if(!equals(ARG(0,u),x))
     return 1;
  if(FUNCTOR(v) != CSC && FUNCTOR(v) != COT)
     return 1;
  if(!equals(ARG(0,v),x))
     return 1;
  if(FUNCTOR(u) == FUNCTOR(v))
     return 1;
  temp = tnegate(csc1(x));
  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,"$\\int csc t cot t dt$ =     -csc t");
  return 0;
}
/*_______________________________________________________________________*/
static int extender(actualop o, term t, term arg, term *next, char *reason)
/* if o is an integration operator integral(f(x),x) == g(x) , extend it to
integral(f(ax),x) = (1/a) g(ax).  If the formula g(x) is a sum containing
a term 'x', don't produce  ax /a  but just x.
   It expects to find ax as either the 0-th arg of the integrand, or
in case the integrand is a power or product, as the 0-th arg of the
0-th arg.  The operator 'o' must not do anything so fancy that it will
choke on using the variable var0 which is not in the varlist--no
polyvals, infers, psubsts, for example.  The reason produced is
that produced by 'o'; in practice this will be overwritten by the
operator calling extender.
*/

{ term u,x,lo,hi,v,ax,a,s,p,q,temp;
  unsigned f,n;
  int err,i;
  if(FUNCTOR(t)!=INTEGRAL)
     return 1;
  u = ARG(0,t);
  x = ARG(1,t);
  f = FUNCTOR(u);
  n = ARITY(t);
  if(f == '^' || f == '*')
     { if(ATOMIC(ARG(0,u)))
          return 1;
       ax = ARG(0,ARG(0,u));
     }
  else
     ax = ARG(0,u);
  if(NEGATIVE(ax))
     ax = ARG(0,ax);
  if(FUNCTOR(ax) != '/' && FUNCTOR(ax) != '*')
     return 1;
  twoparts(ax,x,&a,&s);
  if(!equals(s,x))
     return 1;
  subst(var0,ax,u,&v);
  if(contains(v,FUNCTOR(x)))
     return 1;
  err = (*o)(integral(v,var0),arg,&p,reason);
  if(err)
     return 1;
  subst(ax,var0,p,&q);
  if(FUNCTOR(q) != '+')
     temp = product(reciprocal(a),q);
  else
     { temp = make_term('+',ARITY(q));
       for(i=0;i<ARITY(q);i++)
          { if(equals(ARG(i,p),var0))
               ARGREP(temp,i,x);
            else
               ARGREP(temp,i, product(reciprocal(a),ARG(i,q)));
          }
     }
  if(n == 2)
     { *next = temp;
     }
  else
     { lo = ARG(2,t);
       hi = ARG(3,t);
       *next = evalat(temp,x,lo,hi);   
     }
  return 0;
}
/*_______________________________________________________________________*/
int intsin2(term t, term arg, term *next, char *reason)
{ int err = extender(intsin,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason,"$\\int sin ct dt$ =         -(1/c) cos ct");
  return 0;
}
/*_______________________________________________________________________*/
int intcos2(term t, term arg, term *next, char *reason)
{ int err = extender(intcos,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason,"$\\int cos ct dt$ =         (1/c) sin ct");
  return 0;
}
/*_______________________________________________________________________*/
int inttan2(term t, term arg, term *next, char *reason)
{ int err = extender(inttan,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason, "$\\int tan ct dt$ =         $-(1/c) ln |cos ct|$");
  return 0;
}
/*_______________________________________________________________________*/
int intcot2(term t, term arg, term *next, char *reason)
{ int err = extender(intcot,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason,"$\\int cot ct dt$ =         $(1/c) ln |sin ct|$");
  return 0;
}
/*_______________________________________________________________________*/
int intsec2(term t, term arg, term *next, char *reason)
{ int err = extender(intsec,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason,"$\\int sec ct dt = (1/c)  ln |sec ct + tan ct|$");
  return 0;
}
/*_______________________________________________________________________*/
int intcsc2(term t, term arg, term *next, char *reason)
{ int err = extender(intcsc,t,arg,next,reason);
  if(err)
     return 1;
  strcpy(reason,"$\\int csc ct dt$ = (1/c)   $ln |csc ct - cot ct|$");
  return 0;
}
/*_______________________________________________________________________*/
int intsecsq2(term t, term arg, term *next, char *reason)
{ int err = extender(intsecsq,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason,"$\\int sec^2 ct dt$ =        (1/c) tan ct");
  return 0;
}
/*_______________________________________________________________________*/
int intcscsq2(term t, term arg, term *next, char *reason)
{ int err = extender(intcscsq,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason,"$\\int csc^2 ct dt$ =        -(1/c) cot ct");
  return 0;
}
/*_______________________________________________________________________*/
int inttansq2(term t, term arg, term *next, char *reason)
{ int err = extender(inttansq,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason,"$\\int tan^2 ct dt$ =        (1/c) tan ct - t");
  return 0;
}
/*_______________________________________________________________________*/
int intcotsq2(term t, term arg, term *next, char *reason)
{ int err = extender(intcotsq,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason,"$\\int cot^2 ct dt$ =        -(1/c) cot ct - t");
  return 0;
}
/*_______________________________________________________________________*/
int inttosec2(term t, term arg, term *next, char *reason)
{ int err = extender(inttosec,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason, "$\\int sec ct tan ct dt$ =  (1/c) sec ct");
  return 0;
}
/*_______________________________________________________________________*/
int inttocsc2(term t, term arg, term *next, char *reason)
{ int err = extender(inttocsc,t,arg,next,reason);
  if(err)
     return 1;
  if(IMPROPER(t))
     { errbuf(0, english(2364));
       /* It is incorrect to apply this operation to an improper integral. */
       return 1;
     }
  strcpy(reason, "$\\int csc ct cot ct dt$ =  -(1/c) csc ct");
  return 0;
}

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