Joe Riel

7697 Reputation

22 Badges

13 years, 359 days

MaplePrimes Activity


These are replies submitted by Joe Riel

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

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

@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.

@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.

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

@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.

@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

@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.

@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.

@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.

@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'):

@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

@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.

@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.

@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.

Just noticed that the given solution contains no 1 or 2 and 2 81's  Must have missed a necessary condition.  Will investigate tomorrow.

Follow up The fix was to add a rule requiring that the number 1 appears on some cell.

   one := &or(seq(seq(x[i,j,1], i=1..n), j=1..n)):

The adjacency rule than ensures that all other numbers appear.  I uploaded the corrected worksheet but left the post alone.

Later Realized that the actual error was in the formulation of allvals. The simple fix was to remove it completely, with the one rule it (or the corrected version) is not needed.  Uploaded a new mw file.

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