The file MiscellaneousFunctions.mth contains functions for miscellaneous tasks that do not fit the categories of the other utility files.  The function definitions in the file are automatically loaded when any of its functions are first used.


SQUARE_WAVE(n) simplifies to 1 if n mod 2 is less than 1, otherwise it simplifies to -1.


Consider the sum of t from n=a to infinity where t is an expression dependent on index variable n.  To determine if the series converges or diverges for a given t, first enter the above sum and see if it simplifies to a closed form of finite or infinite magnitude.  Success in finding a closed form sum may require restricting the domains of variables in t (other than the index variable n) to appropriate intervals (see the Author > Variable Domain command8MNT4Y).


If Derive does not return a closed form sum, there are many tests you can use to determine if a series converges or diverges.  For example, Leibniz's alternating series test states that a series converges if


       t alternates in sign beyond a certain n,

       the limit of t as n approaches infinity is 0, and

       |t| is nonincreasing beyond a certain n.


Convergence tests for non-alternating series are given in Calculus textbooks.  Most of these tests are easy to apply directly using Derive's Calculus LimitPGUOQ0 or  Calculus IntegrateARB2JQ commands.  However, the particularly useful ratio test requires a substitution followed by a limit, so the following function is defined in MiscellaneousFunctions.mth to facilitate performing this test:


RATIO_TEST(t, n) simplifies to the limit of the absolute value of the ratio of the n+1th term of the series to the nth term, as n approaches infinity.  If the result is greater than 1, the series diverges.  If the result is less than 1, the series converges.  If the result equals 1, the test is inconclusive.


If u(x,y) is an expression dependent on the variables x and y, Derive simplifies LIM(u, [x, y], [x0, y0]) by first computing the limit with respect to x, then with respect to y.  This result may be different than LIM(u, [y, x], [y0, x0]).  In contrast, the following function returns the multivariate limit:


LIM2(u, x, y, x0, y0) simplifies to the limit of u as [x, y] approaches [x0, y0] along a straight line of slope @1.  For example,

LIM2((x^2-y^2)/(x^2+y^2),x,y,0,0)

simplifies to (1-@1^2)/(@1^2+1).  If the result is independent of @1, the limit is independent of the direction of approach.  For example,

LIM2((SIN(x^2)-SIN(y^2))/(x-y),x,y,0,0)

simplifies to 0, and so the limit is independent of the direction of approach.


The adaptive Simpson's Rule method Derive uses to numerically approximate definite integrals is fast, robust, and accurate (see the Calculus Integrate commandARB2JQ).  However, simpler numerical integration methods are useful for educational purposes; for obtaining rigorous bounds on the integrals of monotonic, concave, or convex integrands; and for approximating definite integrals when the integrands depend on parameters other than the integration variable.


LEFT_RIEMANN(u, x, a, b, n) approximates to the left Riemann sum for the integral of expression u from x=a through b, using n equal-width rectangular strips.  If Derive can determine a closed form for the sum for symbolic n, then you may prefer to use the  Simplify Basic CommandBQ.NIL rather than the Simplify Approximate Command1LCSBCN so that you can simplify the limit of that closed-form sum as n approaches infinity.  Otherwise you should use numeric n and the Simplify Approximate command.


There may be expressions for which Derive is unable to find a closed form antiderivative, even though one exists.  You may be able to help Derive integrate such expressions by using one of the following functions to explicitly integrate by parts or to make a change of variable.  


INT_PARTS(u, v, x) uses integration by parts to find the antiderivative of the expression u·v with respect to x.


INT_SUBST(y, x, u) finds the antiderivative of the expression y(x) with respect to x by substituting the inverse of u(x) for x in y, integrating, and then substituting u(x) for x in the result.  This technique is called integration by substitution.  For example,

INT_SUBST(t·SIN(t^2), t, t^2)

simplifies to

        2  
   COS(t ) 
- —————————
      2    


DEF_INT_SUBST(y, x, u, a, b) finds the definite integral of the expression y(x) from x=a to x=b by substituting the inverse of u(x) for x in y and integrating the result from u(a) to u(b).


INVERSE(u, x) simplifies to the inverse of expression u(x) with respect to x.  For example,

INVERSE(SIN(x/b), x)

simplifies to b·asin(x).  Note that making appropriate domain declarations (see the Author > Variable Domain command8MNT4Y) of variables that occur in u will help INVERSE produce the desired result.



Derive can assist with many proofs, including inductive ones.  The classic example of an inductive proof is showing that the sum of t(k) from k=a to n equals s(n).  This can be done by proving that t(a) - s(a) = 0 and proving that

s(n) + t(n+1) - s(n+1) = 0


This is just substitution followed by algebraic simplification, seeking two expressions equivalent to zero.  Consequently, it is easily automated using the LIM function to do the substitutions:


PROVE_SUM(t, k, a, n, s) simplifies to a vector of two expressions.  If both expressions are equivalent to 0, the sum formula above is proved.  If either expression is not equivalent to 0, the sum formula is disproved.  The technique used in PROVE_SUM can be adapted to many other broad categories of inductive proofs.


The following two functions are for extracting components of polynomials:


POLY_COEFF(u, x, n) simplifies to the coefficient of the x^n term(s) of the polynomial u(x).


POLY_DEGREE(u, x) simplifies to the degree of x in the polynomial u(x).  Note that it returns -1 as the degree of 0, the zero polynomial.  If desired, the definition of POLY_DEGREE can be modified using an IF expressionIF_Expressions to return 0 if u=0.  Others may prefer that it be modified to return minus infinity if u=0.


The following functions and variable show how the pseudo-random number generator function (see the Probability FunctionsProbability_Functions) can be used:


random_sign simplifies to either 1 or -1 randomly with equal probability.


RANDOM_POLY(x, d, s) simplifies to a polynomial of degree d in the variable x with random number coefficients between -s and s exclusive.


RANDOM_VECTOR(n, s) simplifies to an n element vector with random number elements between -s and s exclusive.


RANDOM_MATRIX(m, n, s) simplifies to an m by n element matrix with random number elements between -s and s exclusive.


RANDOM_NORMAL(s,m) simplifies to a random value with a normal distribution having a standard deviation of s and a mean value of m.


The following function indicates how well an expression approximates a set of data points:


GOODNESS_OF_FIT(u, x, A) returns the standard deviation of expression u(x) from the values given in data matrix A.  u(x) can be the expression returned by the built-in function FIT, provided u(x) is dependent on only one data variable (see the Statistical FunctionsStatistical_Functions).  For numerical data, GOODNESS_OF_FIT should be approximated rather than simplified.


POLY_INTERPOLATE(A, x)  simplifies to the polynomial in variable x that interpolates the  [x, y]  coordinate pairs given by the rows of the two-column matrix A.  When applicable, POLY_INTERPOLATE is generally preferable to the built-in FIT function (see the Statistical FunctionsStatistical_Functions).  For example,

POLY_INTERPOLATE([[0,0], [1,1], [2,2], [3,0]], x)

simplifies to

  2         
 x ·(3 - x) 
————————————
      2     


POLY_INTERPOLATE_EXPRESSION(u, x, a)  simplifies to the polynomial in variable x that interpolates the expression u given the one dimensional vector of supporting points a.


Other Utility File LibraryG5BS2R 

Created with the Personal Edition of HelpNDoc: Easily create Help documents