22 Badges

14 years, 23 days

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.

rank...

@Carl Love I think the original version of Iterator is still in the Maple Applications Center, however, I don't believe it has the Rank/Unrank functionality, that was added later. If it did it would work slightly differently as originally I had the rank starting at 0 (it was changed for compatibilty with equivalent functions in the combinat package).  If the OP wants to roll his own, the algorithms came from Knuth's Art of Computer Programming, volume 3, section 5.1.1; also see exercise 7 in that section.

There is an unrankperm procedure in combinat that can probably be used here.

type/linear...

@MDD The type/linear can be used, however, there are some corner cases you may have to handle separately.  Consider

type(a*x + b, linear([x]));  # --> true
type(0*x + b, linear([x]));  # --> false


If missing variables isn't an issue, then you could do something like

L := [a*x + b*y + c, 3*x + y]:
andmap(type, L, linear([x,y])); # --> true


If you want to consider, say, 3 to be linear in x, then you could do something like

vars := [x,y]:
andmap(type, L, Or(freeof(vars),linear(vars)));


That returns true if all expressions in L are either linear in the given variables, or has none of the variables.

Uniform...

@vv To get a uniform distribution of unitary matrices, I think you need to use a normal distribution for the generator.  Say

with(Statistics): With(LinearAlgebra):
n := 2:
Dist := Normal(0,1):
S := Sample(Dist,[n,n]) + I*Sample(Dist,[n,n]):
U := Matrix(GramSchmidt([seq(S[..,k],k=1..n)],'normalized','conjugate'):


Workaround...

@Carl Love Here's a hackish way to remove the first statement from latex/int:

latex/int := FromInert(subsindets(ToInert(eval(latex/int)), 'specfunc(_Inert_STATSEQ)', f -> op(0,f)(op(2..,f)))):
latex(Int(x,y,z,a,b,c));
\int x\,{\rm d}y


SMT...

@Rouben Rostamian  There are SMT-solvers (satisfiability modulo theories) that should be able to handle that, however, Satisfy is a pure SAT-solver, so unless there is a clever way to easily express the inequalities in terms of logic, it won't be useful here.

Help...

@rquirt The help for the ports (click the help icon on the Configuration header, and then the Ports header) just mentions that the name of a custom port has to be entered.  It really should also mention that the fully qualified name can be used for any port defined in an accessible Modelica library.  I'll add that to the description.

MapleSAT...

@tomleslie In 2018 Satisfy was upgraded to use MapleSAT (naturally), an external SAT-solver based, at least originally, on miniSAT. This has made it significantly more effective.  I agree, the examples on the Satisfy help page don't give one the impression that it can do much.

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