## 2448 Reputation

13 years, 123 days

## Protective measures...

In my experience, the "new" Standard GUI label is a fragile feature, actually a patch specific to this particular interface. So, my advice is to avoid these labels and use assigned names instead which always work, and for every interface, as they are native to historical Maple.

## Why it does not simplify...

The reason why z1 simplifies while z2, with an extra term, does not can be traced to a quirk/bug in the builtin procedure numer:

```> z1:=n*(Int(cos(x)^(n-2), x))-(Int(cos(x)^(n-2), x)):
> numer(z1);
/
|        (n - 2)
|  cos(x)        dx (n - 1)
|
/
> z2 := cos(x)^(n-1)*sin(x)+n*(Int(cos(x)^(n-2), x))-(Int(cos(x)^(n-2), x)):
> numer(z2);
/                      /
(n - 1)             |        (n - 2)       |        (n - 2)
cos(x)        sin(x) + n  |  cos(x)        dx -  |  cos(x)        dx
|                      |
/                      /
```

In more detail, simplify in your statements calls the procedure `simplify/trig` several times, see the trace by prepending the line `trace(`simplify/trig`)`. The key is the fifth call, going through the line 31:

```> showstat(`simplify/trig`,31);
`simplify/trig` := proc(a0, {evaluaterelatedfunctions::truefalse := true})
local a, c0, c1, f, f1, f2, n, n1, d, d1, s, S, Strig, err, n0, zz;
...
31       n, d := (numer, denom)(a);
...
```

## Brain vs Maple...

Yes, sometimes the brain is more efficent at identifying patterns. Yet, something where Maple may help is by enabling labelling, see its entry in the help page ?interface . Sadly, it works only for the older output format modes. E.g. if you are using the Standard GUI you may have to set the output format like `interface(typesetting=standard):interface(prettyprint=2)` or older.

## differences between subs and eval...

I think that the best source for reading about differences between subs and eval is the subsection "3.15 Using Expressions" > "Substituting Subexpressions" of the Programming Guide, Chapter 3.

## How to convert documents to classical Ma...

I think that the simplest method is to export the document to Maple Input .mpl format, and then read this mpl file back into the Standard GUI, now in Standard worksheet mode (as opposed to Classic worksheet mws format, which is handled by the Classic GUI, and poorly imitated by the Standard GUI). In addition, you can read this mpl file from the CLI. Note, however, that something may be lost or become corrupted along the way because of bugs in the code for transformation from the 2D language into the 1D language and diverse design shortcomings.

## evaluation of int(cos(x)^n,x)...

About why `int(cos(x)^n,x)` does not evaluate, and why Mathematica does, some facts can be observed, while some other information is hidden. First, what Maple does can be observed though tracing and other techniques. For instance, try infolevel:

```> infolevel[int]:=5:
> int( (cos(x))^n,x) ;
int:   Beginning integration with _EnvContinuous=_EnvContinuous, _EnvAllSolutio\
ns=_EnvAllSolutions, and _EnvCauchyPrincipalValue=_EnvCauchyPrincipalValue.
int/indef1:   first-stage indefinite integration
int/indef2:   second-stage indefinite integration
int/trigon:   case of integrand containing trigs
int/prptrig:   case ratpoly*trig(arg)
Norman:   enter Risch-Norman integrator
Norman:   exit Risch-Norman integrator
Risch:   enter Risch integration
...
Risch:   Risch d.e. has no solution
int/indef1:   first-stage indefinite integration
int/indef2:   second-stage indefinite integration
int/indef2:   applying derivative-divides
int/indef1:   first-stage indefinite integration
int/indef1:   first-stage indefinite integration
int/indef2:   second-stage indefinite integration
int/indef2:   trying integration by parts
int/indef2:   try again after applying simplify
int/indef1:   first-stage indefinite integration
int/indef2:   second-stage indefinite integration
int/indef2:   trying integration by parts
Risch:   exit Risch integration
/
|        n
|  cos(x)  dx
|
/
```

What this log says roughly, is that integrand is not found in the quick check table, it cannot be handled by the collection of ad-hoc methods (dispatched by `int/indef1` and `int/indef2`) and the Rich algorithm (and friends) can do nothing either with it. More details can be obtained by debugging, etc.

Now, I think that nothing equivalent in regards to detail can be known by a user of what Mathematica does. So, next, my guess. Probably, the best way of handling this integral is by an "integration table" or a set of integration rules. And may be that this is exactly  what Mathematica is doing.

Then, what about Maple? Well, actually a similar result in terms of hypergeom can be obtained by a port of Rubi to Maple, yielding this expression:

> FR:= sin(x)*hypergeom([1/2, 1/2-1/2*n],[3/2],sin(x)^2)*cos(x)^(1+n)*(cos(x)^2)^(-1/2 -1/2*n):

> plot(eval(FR,n=3),x=-2*Pi..2*Pi);

Compare with Mathematica's result translated into Maple syntax:

```> FM:=-cos(x)^(n+1)/(n+1)*hypergeom([(n+1)/2,1/2],[(n+3)/2],cos(x)^2)*sin(x)/(sin(x)^2)^(1/2):
> plot(eval(FM,n=3),x=-2*Pi..2*Pi,discont=true);
```

These expressions differ by a piecewise constant. While Rubi's primitive function is smooth on the complex plane, Mathematica's primitive function has discontinuities arising in branch cuts crossing the real axis (n=3).

## Integration by parts...

For the integration by parts:

```> J:=n->Int( (cos(x))^n,x):
> IntegrationTools:-Parts(J(n),cos(x)^(n-1));
/         2       (n - 1)
(n - 1)    |    sin(x)  cos(x)        (n - 1)
sin(x) cos(x)        -  |  - ----------------------------- dx
|               cos(x)
/
> J(n)=(IntegrationTools:-Expand@expand@simplify)(%,{sin(x)^2+cos(x)^2=1});
/                 /  /                /       n   \     /
|        n         | |        n       |  cos(x)    |    |        n
|  cos(x)  dx = -n | |  cos(x)  dx -  |  ------- dx| +  |  cos(x)  dx
|                  | |                |        2   |    |
/                   \/                /   cos(x)    /   /
/       n                   n
|  cos(x)       sin(x) cos(x)
-  |  ------- dx + --------------
|        2          cos(x)
/   cos(x)
> eq:=combine(%,power);
/                 /  /                /                 \
|        n         | |        n       |        (n - 2)   |
eq :=  |  cos(x)  dx = -n | |  cos(x)  dx -  |  cos(x)        dx|
|                  | |                |                  |
/                   \/                /                   /
/                /
|        n       |        (n - 2)                   (n - 1)
+  |  cos(x)  dx -  |  cos(x)        dx + sin(x) cos(x)
|                |
/                /
> s:=J(n)=J[n],J(n-2)=J[n-2];
/                      /
|        n             |        (n - 2)
s :=  |  cos(x)  dx = J[n],  |  cos(x)        dx = J[n - 2]
|                      |
/                      /
> subs(s,eq);
(n - 1)
J[n] = -n (J[n] - J[n - 2]) + J[n] - J[n - 2] + sin(x) cos(x)
> op(solve(%,{J[n]}));
(n - 1)
sin(x) cos(x)        + n J[n - 2] - J[n - 2]
J[n] = --------------------------------------------
n
> collect(%,J[n-2]);
(n - 1)
(n - 1) J[n - 2]   sin(x) cos(x)
J[n] = ---------------- + --------------------
n                    n
> subs((rhs=lhs)~([s]),%);
/                      /                                 (n - 1)
|        n      n - 1  |        (n - 2)      sin(x) cos(x)
|  cos(x)  dx = -----  |  cos(x)        dx + --------------------
|                 n    |                              n
/                      /
```

## the nonunit qualifier...

Yes, in the context of the package PatternMatching, the nonunit qualifier serves as an instruction saying that matching for the case of the unit of the operation should be excluded, namely 0 for a summand, 1 for a factor in a product or an exponent.

## conditional in PatternMatching...

In the context of the facilities provided by the package PatternMatching, like define, patmatch and applyrule, the construct conditional is used for writing conditional parametric patterns, meaning patterns that match only when some boolean condition or predicate is satisfied by the values that the pattern parameters bind to. In your example, the condition is whether the expression to which the parameter a binds is independent of the name to which the parameter X binds, as in the case for `INT(2,x)`. This predicate may include calls to procedures like type, is, etc, but these calls need to be made in an "inert" form, which in the context of this package means prepending an underscore ( _ ) to the procedure name. Consequently, they should go as `_type(...)`, `_is(...)`, etc.

A bit of explanation on the conditional construct is available in the help page ?patmatch , but certainly, overall, the documentation of the facilities of this package is below standard, what is a pitty.

## relation to hypergeom...

Something like this one?:

```> FunctionAdvisor(specialize,HeunC(alpha, beta, gamma, delta, eta, z),hypergeom);
[HeunC(alpha, beta, gamma, delta, eta, z) =
/                          2        2             1/2\
|gamma   beta         (beta  + gamma  - 4 eta + 1)   |
|----- + ---- + 1/2 + -------------------------------|
\  2      2                          2               /
/  1   \
|------|                                                       hypergeom([
\-z + 1/
2        2             1/2
gamma   beta         (beta  + gamma  - 4 eta + 1)
- ----- + ---- + 1/2 + -------------------------------,
2      2                          2
2        2             1/2
gamma   beta         (beta  + gamma  - 4 eta + 1)                    z
----- + ---- + 1/2 + -------------------------------], [beta + 1], ------),
2      2                          2                              -1 + z
And(alpha = 0, beta + 1 <> 0, delta = 0, z <> 1)]
```

## LibraryTools Browser...

Yes this browser is very buggy. I have submitted several SCRs against it years ago with no significant improvement yet. Besides, it does not list after type (procedures, modules, tables, sets, etc). So I prefer listing using with my own tools.

Yes, Standard GUI in Maple 16 and later have an undo after execute enabled by default. I am not aware of a setting for this facility, available for Maple 15 and earlier. I agree that it should be active, but how knows? The design of the Standard GUI is so odd...

## Not a small report...

Note that it would not be a small report... The procedures of the form algcurves/xxx amount to 150. Then e.g. AbelMap is actually a module under algcurves with 32 private procedures itself. And there are two more modules there. And there are many more packages, some of them much more larger and complex, e.g. including long tables of procedures, etc. Certainly, listing exported, visible, documented procedures only is another thing, something about 1% of the total. But you would be loosing many interesting  and useful procedures hidden out there.

## Is there a way to automate this?...

What you want to do is, probably, running the Standard GUI in batch mode. Then, most likely, the answer is no. The Standard GUI does not seem to be designed to be run in batch mode. And some of its functionality (like export) seems GUI only (no known programmatic access mode).

## why algsubs would not work well...

The algorithm used by algsubs needs the degree of eta in the patern, as computed by degree, which is undefined. See it just for a piece of the computation behind the scene:

```> degree(1/(eta*M[n]+gamma), eta);
FAIL
```

This is an example of a class of patterns for which applyrule may be better:

```> applyrule(-eta*M[n]/(gamma*(eta*M[n]+gamma))-1/(eta*M[n]+gamma) = factor(-eta*M[n]/(gamma*(eta*M[n]+gamma))-1/(eta*M[n]+gamma)), (-eta*M[n]/(gamma*(eta*M[n]+gamma))-1/(eta*M[n]+gamma))*p[i]+(int(p[i], i = 0 .. M[n]))*eta/(gamma*(eta*M[n]+gamma))+alpha/(eta*M[n]+gamma));
M[n]
/
p[i]              eta             |                     alpha
- ----- + ------------------------  |      p[i] di + ----------------
gamma   gamma (eta M[n] + gamma)  |                eta M[n] + gamma
/
0
```
 2 3 4 5 6 7 8 Last Page 4 of 29
﻿