Carl Love

Carl Love

25831 Reputation

25 Badges

10 years, 359 days
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity

These are answers submitted by Carl Love

It's an interesting Question; I vote up.

To do what you want, you need to declare notsave::uneval. For example:

Excl:= {'x', 'y'}:
(x,y,z,w):= (3,5,7,9):
SaveNames:= (excl::uneval, fname::{symbol, string})->
        _V= remove(
            type, {anames}(user), 
            {procedure, identical(eval(excl, 2)[], eval(excl, 1))}
        proc() save _V, fname; return end proc
SaveNames(Excl, "V.txt");

read "V.txt";
                             w := 9
                             z := 7

x,y,z,w, Excl, eval(SaveNames);
                  x, y, 7, 9, Excl, SaveNames

In the line Excl:= {'x', 'y'}, the quotes would only be necessary if those variables had been already assigned values.

In the remove command, the eval(excl, 2)[] specifies the elements of the exclusion set (as names), and the eval(excl, 1) specifies the set's own name. The 2 and 1 are the number of levels of evaluation used.

If you consider the projection computed in part a to be a point p rather than a vector (this different point of view, i.e. the point\vector distinction, doesn't require any change in the Maple syntax), then the distance for part b is the distance between a and p. This works because the line goes through the origin (at lambda = 0).

Consider this counterexample (which I'm composing in my head while typing on my phone; no paper or Maple, so maybe I'm mistaken): The edges are {{1, 2}, {1, 3}, {2, 4}, {3, 4}, {4, 5}, {4, 6}, {5, 7}, {6, 7}}. I think that the max flow from 1 to 7 is 2, but there are not 2 vertex-disjoint paths from 1 to 7.

However, it does seem plausible to me that the max flow always equals the maximum number of pairwise-edge-disjoint paths.

Does the command PolynomialIdeals:-Quotient do what you want?

Maple's Iterator package is precisely made for this purpose: to generate combinatorial objects one-by-one so that they can be used in a loop without needing the entire list of them stored in memory. For example:

n:= 5: k:= 3:
for C in Iterator:-Combination(n,k) do
                           {1, 2, 3}
                           {1, 2, 4}
                           {1, 3, 4}
                           {2, 3, 4}
                           {1, 2, 5}
                           {1, 3, 5}
                           {2, 3, 5}
                           {1, 4, 5}
                           {2, 4, 5}
                           {3, 4, 5}

The in clause in the for-do loop header hides the fact that the objects are being generated one-by-one (per loop iteration) rather than as a container (list, sequence, etc.). 

Over the years, I have extensively tested the efficiency of various iteration commands in Maple: for-doseqmap, etc. There is no significant difference between for and the others. It has a totally undeserved bad reputation for inefficiency. That reputation may be due the fact that there is a very inefficient operation which is unfortunately very common among newbies, and is done with do loops: building a sequence, list, or set one element per loop iteration. The inefficiency is specific to those three container types; building tables or arrays per loop iteration works fine.

The try ... catch statement is the way. In the following example, we predict that we'll face division-by-zero errors, but there's no need to tell Maple that. In other words, there's no need to put any string after the catch. The next statement means to continue with the next iteration of the loop.

R:= rand(-9..9):
[to 9 do 1/R() od];
Error, numeric exception: division by zero
randomize(1): #to generate the same random numbers
[to 9 do try 1/R() catch: next end try od];
                  [-1  1  1      1  -1  1  -1]
                  [--, -, -, -1, -, --, -, --]
                  [4   2  3      2  4   6  9 ]

Note that the output list has 8 entries, not 9, indicating that one zero was skipped.

The above example is intended for 1D input (aka Maple Input) only.

sin(x)/cos(y) is not equal to any simple expression of tangent.

This (MaplePrimes) is a public forum, not an official place for customer support. (Although one can usually obtain excellent unofficial support here.) No forum---whether it be a paper periodical, a book, a conference, or online---can survive without editors (aka moderators); they would quickly devolve into unintelligible messes, and all the good writers would leave.

The vast majority of contributors here, including Moderators, are unpaid, unsupervised, and acting independently. Sometimes an editor will make the wrong decision; that is not abuse. However, for you to call it abuse is abusive, and the only reason that I'm not even more annoyed by your Question is that perhaps you thought that this was an official customer-support channel rather than a public forum. If you show disrespect to acer again, I'll delete it.

Apply command CycleBasis to G. Select the members of the output containing v. From these, select the one with the fewest elements. That number of elements is your answer.

Assumptions made with an assuming clause are only active for the command to which the clause is attached. Thus, there is no assumption applying to eta for the is command in question.

Your use of interface(showassumed= 0) obscured this information, which likely would've otherwise been apparent to you. Sure, those tildes on the variables are ugly. BUTyou should first get your code to work, then remove ugliness. Obscuring information also makes it more difficult for other people, such as me, to debug your code.

In your Maple initialization file, include the line


Then the number will be at the top of every worksheet.

Note that g1 is itself an equation: Q = RootOf(...). So, if you say eval(..., [Q= g1, ...]), the substitution becomes Q= (Q= ...). In other words, you're substituting an entire equation for Q when you meant to substitute only the right side of that equation. The same problem happens with g2 and T. To correct it:

eval(..., [g1, g2, ...other equations...])

Here's a one-line Answer, although perhaps less understandable than the one from @mmcdara :

(mul@op~@applyop~)((3-nops)*(`+`@op), 1, ListTools:-Collect((`{}`@op)~(L)));

Some explanations:  (`{}`@op)~ converts the list pairs to sets to make the order irrelevant. This also changes [2,2] to {2}, which affects the sums done by (`+`@op). The (3-nops)* contributes a coefficient to compensate for that: (3-nops)({1,4}) = 1(3-nops)({2}) = 2. Then all numbers are multiplied by mul@op~; there's no need to first multiply them pairwise. The applyop~ is used so that the (3-nops)*(`+`@op) is only applied to the 1st operand of each pair returned by Collect.

Ordinarily, (`+`@op) could be replaced by add, but the internal extra-optional-arguments syntax used by applyop makes that not work.

A surprisingly quick and easy analysis of the code behind eval[recurse] and reading of the help page ?has shows that eval[recurse] cannot possibly work correctly when there are lists or sets on the left sides of the substitution equations, and that this bug would be easy to fix. That the list is empty and substitutent is NULL are irrelevant. The code can be read by

showstat(`simpl/eval`::ModuleApply);  #Note: :: not :-

Note the use of has in lines 7 and 15 and this paragraph from ?has (3rd paragraph of Description):

  • If the item that you want has to search for is itself a list or set, you must enclose it in a list or set. Otherwise, has will search for items in the list or set as described above.

The bug can be fixed by these steps:

kernelopts(opaquemodules= false):
interface(verboseproc= 2):

In a fresh execution block, type (but don't press Enter)



Copy and paste the output of the lprint into the blank line in the execution block.

In lines 7 and 15, change the second argument of has to

`if`(y::{'list','set'}, [y], y)

In line 10 put the `simpl/eval`:- module prefix on Terminates1 and Terminates2.

In line 14 wrap the right side of := with an extra eval (with no second argument).

Add this line immediately after line 14:

if expr=() then return fi;

Press Enter, because we're ready to test the procedure.

lprint(eval[recurse]([[[[[]]]]], [[]= 'NULL']));

Like this:

Split:= (L::list(string), d::string)->
local p:= StringTools:-Search(d,L);
    (index~(L, `..`~(1, p-~1)), (parse@index)~(L, `..`~(p+~length(d), -1)))
Split(["k$1","y$23","f$2.5"], "$");
                 ["k", "y", "f"], [1, 23, 2.5]


First 8 9 10 11 12 13 14 Last Page 10 of 375