• No results found

For efficiency reasons, it is unreasonable to expect a CAS to apply all its simplification rules during the course of a computation. The designer of a CAS must choose which simplification rules are appropriate for a par-ticular operator. We use the term simplification context to refer to those simplification rules that are applied during the evaluation of a mathemat-ical operator. The simplification context often determines the form of the output of an operator and in some cases determines whether or not a CAS can even correctly perform an operation.

For example, consider the Maple interactive dialogue in Figure4.4. At the first prompt, u is assigned a polynomial in x in factored form, and at the second prompt, we ask Maple to obtain the degree of u in x. I n this case algebraic expansion (with respect to the symbol x) is part of the

1Observe that the symbol s in the output of the normal command is followed by a tilde (˜). The Maple system includes this symbol to indicate that s has been given a property.

> u := (x+1)*(x+2);

u := (x + 1)(x + 2)

> degree(u,x);

2

> v := (y^2-1-(y+1)*(y-1))*x^2+x+1;

v := (y2− 1 − (y + 1)(y − 1)) x2+ x + 1

> degree(v,x);

2

Figure 4.4. A Maple interactive dialogue that demonstrates a simplification context. (Implementation: Maple(mws),Mathematica(nb)MuPAD(mnb).)

simplification context of the degree operator which returns the value 2.

At the third prompt, v is assigned a polynomial in x with one coefficient that is a polynomial in y (in unexpanded form), and at the next prompt, we ask Maple to obtain the degree of v in x. Notice that the value 2 is returned even though the coefficient of x2simplifies to 0. For this system, expansion with respect to the auxiliary symbol y is apparently not part of the simplification context of the degree operator. On the other hand, both Mathematica’s Exponent operator and MuPAD’s degree operator evaluate the degree of v to 1.

Figure4.5shows how the simplification context of the numerator oper-ator can vary from system to system. First, for the expression (a x + b x)/c, Maple returns the numerator in a factored form, while Mathematica returns an expanded form. Next, consider the expression 1/a + 1/b. I n Maple the terms in the sum are combined over a common denominator, and a + b is returned as the numerator. On the other hand, in Mathematica the terms in the sum are not combined, and the entire expression is returned as the numerator.

Simplification context is a rather loosely defined concept. For exam-ple, does it refer to the simplification rules that are applied before, during, or after an operation? In addition for some operators a simplification rule

> u := (a*x+b*x)/c;

u := a x + b x c

> numer(u);

(a + b) x

> u := 1/a+1/b;

u := 1

a +1 b

> numer(u);

a + b (a) Maple.

In[1 ] := u = (a∗ x + b ∗ x)/c Out [1 ] = a x + b x

c In[2 ] := Numerator[u]

Out [2 ] = a x + b x In[3 ] := u = 1/a + 1/b Out [3 ] = 1

a+1 b In[4 ] := Numerator[u]

Out [4 ] = 1 a+1

b

(b) Mathematica.

Figure 4.5. Interactive dialogues in Maple and Mathematica that show different simplification contexts of the numerator operation. (Implementation: Maple (mws),Mathematica(nb),MuPAD(mnb).)

may be applied in some situations while not in others or may even depend on other options or settings used in a session. Nevertheless, the concept is an important aspect of operator capacity and serves as a warning that unwarranted assumptions about the actions of an operator may cause a program to fail.

Exercises.

1. Explain why the following operations are not properly posed without addi-tional information about the arbitrary symbols that appear in the expres-sions. Implement each operation in a CAS. Is the solution obtained correct for all values of the arbitrary symbols?

(a) dx

x2+ 2 a x + 1. (b) sin(n x) sin(m x) dx.

(c) Solve the differential equation dy2

dx2 − y = exp(a x).

(d)

1 0

1 xn dx.

Use int and dsolve in Maple, Integrate and DSolve in Mathematica, and int and ode (with solve) in Mu PAD.

2. Experiment with a CAS to determine the simplification context of the following operators.

(a) The Coefficientoperator. For example, can the operator obtain co-efficients if the input polynomial is not in expanded form? Is the result returned in expanded form? Is rational simplification part of the simplification context? (Use coeff in Maple and MuPAD and Coefficient in Mathematica.)

(b) TheSolveoperator. For example, can this operator determine that the quadratic equation (a2− 1− (a + 1)(a − 1)) x2+ x− 1 = 0 is really a linear equation and return the solution x = 1? How about the equation (sin2(a)+cos2(a)−1) x2+x−1 = 0? Is rational simplification applied before and/or after a solution to the equation is found? (Use solve in Maple and MuPAD and Solve in Mathematica.)

3. Is rational simplification part of the simplification context of the differ-entiation operator in a CAS? (Use diff in Maple and MuPAD and D in Mathematica.)

4. Describe the semantic capacity of the factor operation in a CAS. The ex-amples in Exercise1, page22are useful for this exercise. (Use factor in Maple and MuPAD and Factor in Mathematica.)

5. Some CAS software has the capability to differentiate and integrate expres-sions with undefined functions. In this exercise we ask you to explore the capacity of differentiation and integration operators in a CAS to handle undefined functions.

(a) Apply the differentiation operator to the following expressions:

u(x), du(x)

dx u(x)v(x), u(x)/v(x), (4.9)

sin(u(x)), u(v(x)), x3du(x)

dx − 3x2u(x) + x2/2.

Does the CAS obtain the results you expect? (Use diff in Maple and MuPAD and D Mathematica.)

(b) Suppose that you are given the derivatives of the expressions in (4.9). Can a CAS integrate these derivatives to obtain the expres-sions in (4.9) (up to a constant)? (Use int in Maple and MuPAD and Integrate in Mathematica.)

6. An important aspect of semantic capacity is what an operator does when it is unable to perform the operation. Experiment with a CAS to determine what each of the of the following operators does in this situation.

(a) Degree.

(b) Solve.

(c) Integral.

(d) Solve ode.

For example, what doesDegree(u, x) operator return when the input ex-pression u is not a polynomial in x? (In Maple u se degree, solve, int, and dsolve; in Mathematica use Exponent, Solve, Integrate, and DSolve; and in Mu PAD u se degree, solve, int, and ode (with solve).)

4.2 MPL’s Algorithmic Language

In this section we describe the basic language structures that are used in MPL to control the flow in an algorithm.