## 7864 Reputation

14 years, 257 days

## One possibility...

@Christian Wolinski Good question.  I'd probably do something crude like

```for n to 5 do
'n'=n, Statistics:-Fit(y, data, x, 'output=[parametervalues,residualsumofsquares]');
end do;
n = 1, [[m = 1.89016445809072], 0.04365213270]
n = 2, [[m = 2.04708142901557], 0.002540629258]
n = 3, [[m = 2.13911489423050], 0.001559320138]
n = 4, [[m = 2.19055011428686], 0.009593451000]
n = 5, [[m = 2.22152248102920], 0.01934052765]
```

Then pick the one with the smallest residual (n=3). Comparing plots would be useful.

## misnomers...

@Carl Love Yes, SearchArray is a misnomer. Poorly named methods are a nuisance, they hide in the help. I chose to roll my own, with seq.  I wasn't clever enough to use your transposition trick to avoid some code duplication.

## Improvement...

@Carl Love Some good ideas in there.  Profiling the routine reveals that, at least for the random matrix you provided, most of the time is spent in Tally.  I believe that can be reduced significantly by tallying once, for the original matrix, then updating the tally for subsequent calls by just checking omitted row/column.  Here's the basic idea, though I used number of zeros rather than number of non-zeros (haven't paid much attention to whether it is correct, though the result matches yours).

```Determinant2 := module()

export
ModuleApply := proc(A :: Matrix(square))
local ZerosInCols, ZerosInRows, i, j, n;

n := upperbound(A,1);
if n=0 then
return 1;
elif n=1 then
return A[1,1];
end if;

Det(A, n, ZerosInRows, ZerosInCols);

end proc;

export
Det := proc(A :: Matrix
, n :: posint
, ZerosInRows :: list
, ZerosInCols :: list
)
local c, cols, i, j, mx, r, rows, zerosInCols, zerosInRows;

if n=1 then
return A[1,1];
end if;

# find row or column with most zeros
mx := max(ZerosInCols);
if mx = n then return 0; end if;
member(mx, ZerosInCols, 'c');
mx := max(ZerosInRows);
member(mx, ZerosInRows, 'r');
if mx = n then return 0; end if;

if c >= r then
# use the c column
zerosInRows := [seq(ifelse(A[i,c] = 0
, ZerosInRows[i] - 1
, ZerosInRows[i]
), i = 1..n)];
cols := [..c-1,c+1..];
, 0
, (-1)^(c+i)*A[i,c]*thisproc(A[[..i-1,i+1..],cols]
, n-1
, subsop(i=NULL, zerosInRows)
, subsop(c=NULL, [seq(ifelse(A[i,j] = 0
, ZerosInCols[j]-1
, ZerosInCols[j]
), j = 1..n)])
)
)
, i = 1..n);
else
# use the r row
zerosInCols := [seq(ifelse(A[r,j] = 0
, ZerosInCols[j] - 1
, ZerosInCols[j]
), j = 1..n)];
rows := [..r-1,r+1..];
, 0
, (-1)^(r+j)*A[r,j]*thisproc(A[rows, [..j-1,j+1..]]
, n-1
, subsop(r=NULL, [seq(ifelse(A[i,j] = 0
, ZerosInRows[i]-1
, ZerosInRows[i]
), i = 1..n)])
, subsop(j=NULL, zerosInCols)
)
)
, j = 1..n);
end if;

end proc;

end module:
```

## Symbolic power...

@Carl Love While a numeric power is handled

```simplify(polar(r,theta)^3);
polar(r^3, 3*theta)
```

a symbolic power is not

```simplify(polar(r,theta)^n) assuming n :: real;
polar(r,theta)^n
```

## Status...

While the behavior still appears in Maple 2019.2, it has been fixed in the development version of Maple.

## nice...

@acer That's a rather clever technique.

## The missing doc...

Robert's lament is understandable; the problem is worse than he suggests.  It isn't just the naive user that has a problem.  I don't believe that there is any user available documentation on this Maple specific functional form of mathml.  There is some internal documentation but it's been awhile since I've perused it. With a working knowledge of mathml its possible to muddle your way through much of it.

## andseq...

@Carl Love It is for occasions like this that I wish Maple had an andseq builtin.  One could achieve the same end without having to use zip, and so avoid the intermediate list.

## sort with key...

@Kitonum A better way to sort that is to use the key option

```sort(E1, 'key' = (s -> s[1])):
```

## touche...

@Carl Love Rouben's suggestion is practical, understandable, and concise, though the use of the % is a slight cheat. Yours is the opposite, though entertaining and the sort of thing I was trying to come up (for no good reason).  Can't say I've ever used a tilde-operator with expression sequences.

## selectremove...

@Rouben Rostamian  It would be nice if there were a clever way to use selectremove here.  I couldn't come up with anything better than

````&=-` := (a,b) -> a = -b:
`&=-`(selectremove(has, tmp, diff)); # where tmp is the result of your expand call.
```

## Source button...

Click the Source button, upper-left on toolbar, to edit the html directly.

## Identity...

@Carl Love I didn't realize D[] would work here, as the identity.  Cute, though not entirely clear, but I'll use it.  I've suggested that Maplesoft add a builtin identity a few times. Not sure what the resistance is.  Ideally it would be short, say Id, however, that might cause backwards compatibility issues. It's also not entirely clear whether it should be, effectively, x->x or () -> args.

## cat...

@Carl Love Be aware that || is discouraged (says so right in the help page).  Use cat instead. Also note that the ranges work with character symbols:

```cat(x, a..e);
xa, xb, xc, xd, xe
```

## Inert forms...

@torabi As I mentioned in my first response, use the inert integral form (replace int with Int).  There is no way that that integral can be symbolically evaluated, so why make Maple attempt to do so? The summations can be evaluated (expanded) iff you supply the integer limits.

 1 2 3 4 5 6 7 Last Page 3 of 180
﻿