Sindbad~EG File Manager

Current Path : /usr/home/beeson/Otter-Lambda/yyy/series/
Upload File :
Current File : /usr/home/beeson/Otter-Lambda/yyy/series/ldots.c

/* M. Beeson, for Mathpert.
Operations for infinite series.
Original date 1.6.99
Last modified 1.22.99
*/

#include <string.h>
#include <assert.h>
#include <math.h>
#define SERIES_DLL
#include "globals.h"
#include "trig.h"
#include "series.h"
#include "errbuf.h"
#include "limval.h"
#include "deval.h"
#include "pathtail.h"  /* set_pathtail */
#include "autosimp.h"  /* SetShowStepOperation */
#include "islinear.h"
#include "prover.h"    /* NOTDEFINED   */
#include "calc.h"      /* polyvalop    */
#include "converge.h"
#include "trigpoly.h"  /* algebraic_in2 */
#include "deriv.h"     /* derivative   */
#include "cflags.h"    /* pushpending, poppending */
#include "graphstr.h"  /* document.h needs it */
#include "document.h"  /* controldata  */
#include "operator.h"  /* series4      */
#include "autosimp.h"  /* contains_calc */
#include "pvalaux.h"   /* obviously_nonnegative */
#include "series2.h"
#include "binders.h"
#include "loglead.h"   /* log_leading_term */
#include "polynoms.h"  /* POLYnomial etc.  */


/*____________________________________________________________________________________________*/
MEXPORT_SERIES int ldots0(term t, term arg, term *next, char *reason)
/* express series as $a_0 + a_1 + ... $ */
{ int i;
  if(FUNCTOR(t) != SUM)
     return 1;
  if(ARITY(t) != 4)
     return 1;
  if(!equals(ARG(3,t),infinity))
     return 1;
  *next = make_term(SUM,5);
  for(i=0;i<4;i++)
     ARGREP(*next,i,ARG(i,t));
  ARGREP(*next,4,tnegate(two));
  strcpy(reason, english(2316));  /* express series as $a_0 + a_1 + ... $ */
  return 0;
}
/*____________________________________________________________________________________________*/
MEXPORT_SERIES int ldots1(term t, term arg, term *next, char *reason)
/* express series as $a_0 + a_1 + a_2 ... $ */
{ int i;
  if(FUNCTOR(t) != SUM)
     return 1;
  if(ARITY(t) != 4)
     return 1;
  if(!equals(ARG(3,t),infinity))
     return 1;
  *next = make_term(SUM,5);
  for(i=0;i<4;i++)
     ARGREP(*next,i,ARG(i,t));
  ARGREP(*next,4,tnegate(three));
  strcpy(reason, english(2317));  /* express series as $a_0 + a_1 + a_2 + ... $ */
  return 0;
}
/*____________________________________________________________________________________________*/
MEXPORT_SERIES int ldots2(term t, term arg, term *next, char *reason)
/* express series using ... and general term */
{ int i;
  if(FUNCTOR(t) != SUM)
     return 1;
  if(ARITY(t) != 4)
     return 1;
  if(!equals(ARG(3,t),infinity))
     return 1;
  *next = make_term(SUM,5);
  for(i=0;i<4;i++)
     ARGREP(*next,i,ARG(i,t));
  ARGREP(*next,4,two);
  strcpy(reason, english(2318));   /* express series using ... and general term */
  return 0;
}

/*____________________________________________________________________________________________*/
MEXPORT_SERIES int ldotstosigma(term t, term arg, term *next, char *reason)
/* Express series using sigma notation */
{ int i;
  if(FUNCTOR(t) != SUM)
     return 1;
  if(ARITY(t) != 5)
     return 1;
  if(!equals(ARG(3,t),infinity))
     return 1;
  *next = make_term(SUM,4);
  for(i=0;i<4;i++)
     ARGREP(*next,i,ARG(i,t));
  strcpy(reason, english(2320));   /* Express series using sigma notation */
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showevaluatedterms(term t, term arg, term *next, char *reason)
/* show terms with factorials evaluated */
{ if(FUNCTOR(t) != SUM || !equals(ARG(3,t),infinity) || EVALFACTORIAL(t))
     return 1;
  if(ARITY(t) != 5)
     return 1;
  if(!contains(ARG(0,t),FACTORIAL))
     return 1;
  *next = t;
  SET_EVALFACTORIAL(*next);
  strcpy(reason, english(2349));
  /* show terms with factorials evaluated */
  HIGHLIGHT(*next);
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showfactorialsinterms(term t, term arg, term *next, char *reason)
/* do not evaluate factorials in coefficients */
{ if(FUNCTOR(t) != SUM || !equals(ARG(3,t),infinity) || DEVALCOEF(t) || !EVALFACTORIAL(t))
     return 1;
  if(ARITY(t) != 5)
     return 1;
  if(!contains(ARG(0,t),FACTORIAL))
     return 1;
  *next = t;
  UNSET_EVALFACTORIAL(*next);
  HIGHLIGHT(*next);
  strcpy(reason, english(2352));
  /* do not evaluate factorials */
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showdevaluatedterms(term t, term arg, term *next, char *reason)
/* Show the coefficients in decimal form */
{ if(FUNCTOR(t) != SUM || !equals(ARG(3,t),infinity) || DEVALCOEF(t))
     return 1;
  if(ARITY(t) != 5)
     return 1;
  *next = t;
  SET_DEVALCOEF(*next);
  strcpy(reason, english(2350));
  /* show coefficients in decimal form */
  HIGHLIGHT(*next);
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showundevaluatedterms(term t, term arg, term *next, char *reason)
/* do not use decimal form for coefficients */
{ if(FUNCTOR(t) != SUM || !equals(ARG(3,t),infinity) || !DEVALCOEF(t))
     return 1;
  if(ARITY(t) != 5)
     return 1;
  *next = t;
  UNSET_DEVALCOEF(*next);
  strcpy(reason, english(2351));
  /* do not use decimal form for coefficients */
  HIGHLIGHT(*next);
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showanotherterm(term t, term arg, term *next, char *reason)
/* Show another term of a series written using ... */
{ int err = showmoreterms(t,one,next,reason);
  if(err)
     return 1;
  strcpy(reason, english(2321));  /* show another term before ... */
  return 0;
}
/*_____________________________________________________________________________________________*/
MEXPORT_SERIES int showmoreterms(term t, term arg, term *next, char *reason)
/* Show ? terms of a series written using ... */
{ long nterms,m;
  term aux,u;
  if(FUNCTOR(t) != SUM)
     return 1;
  if(ARITY(t) != 5)
     return 1;
  if(!ISINTEGER(arg))
     return 1;
  nterms = INTDATA(arg);
  aux = ARG(4,t);
  if(NEGATIVE(aux))
     { if(!ISINTEGER(ARG(0,aux)))
          return 1;
       m = INTDATA(ARG(0,aux));
     }
  else
     { if(!ISINTEGER(aux))
          return 1;
       m = INTDATA(aux);
     }
  if(m+nterms > 1000)
     { errbuf(0, english(2322));  /* The maximum number of terms before ... is 1000. */
       return 1;
     }
  copy(t,next);
  u = make_int((unsigned short)(m+nterms));
  if(NEGATIVE(aux))
     ARGREP(*next,4,tnegate(u));
  else
     ARGREP(*next,4,u);
  HIGHLIGHT(*next);
  strcpy(reason,english(2319));  /* show more terms before ... */
  return 0;
}

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