sursumCorda

922 Reputation

13 Badges

2 years, 206 days

MaplePrimes Activity


These are replies submitted by sursumCorda

@vs140580 If you don't want to write loops, You can use: 

Statistics:-Scale(datainMatrix, center = convert(Statistics:-DataSummary(datainMatrix, output = minimum), list), scale = convert(Statistics:-Range(datainMatrix, list))

I think that what you need is just the Statistics:-Scale command: 

An application for the Scale command is to compute standard scores (z-scores) for a list of values. 
If V is a matrix, the Scale command will scale each column of the matrix.

@nm Thanks. But I think that for comparison, using rtable is more suitable. (In other word, table versus rtable, or array versus Array.)

@acer Thanks for your detailed reply.

Sometimes it's convenient to perform a given operation in a loop (say, because the operation is in stages and a handy procedure isn't yet written to do each one individually).

I'm not sure if understand this point. Of course, one may pre-allocate storage for the output and write one or more for loops, but people can, in effect, write more compact (and clearer?) codes (with neither pre-allocation nor loops) like: 

(() -> args[-1])(( … ), ( … ), ( … ), ..., ( … )); # do several operations (but put several steps on the same line), and give the result of the last one
MakeFunction(%)( … ... … ); # another way to implement sequences of commands (i.e., a compound expression) rather then fit each step on a separate line

And then simply put the inline object into (nested) seq in a user-friendly way (with less error prone?). It seems that they enable the user to focus (entirely?) on the algorithm instead of the mechanics of either creating a new structure or iterating through loops. (I don't mean that the programming infrastructure is not important. But it appears that if somebody only want to do a small task, writing large amount of code will more or less stifle the initiative and dampen the enthusiasm.)

@Carl Love Thanks.
I find that the documentation of Maple's GraphTheory[TransitiveReduction] says that

the transitive reduction of an graph G is a undirected graph …,

while the documentation of MatLab's digraph.transreduction implies that

H = transreduction(G) returns … a digraph object (i.e., a directed graph object). 

Besides, the documentation of Mma's System`TransitiveReductionGraph claims that

TransitiveReduction is also known as minimum equivalent graph,

but it can be inferred (from the Wikipedia article) that 

the transitive reduction doesn't coincide with the minimum equivalent graph in general.

These statements contradict each other indeed!

@lcz Actually, this graph has been reduced in advance, but Maple still cannot give correct results.
The original unweighted graph is: 

GraphTheory[Digraph]({[2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1], [21, 1], [22, 1], [23, 1], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3], [16, 3], [17, 3], [18, 3], [19, 3], [20, 3], [21, 3], [22, 3], [23, 3], [2, 4], [5, 4], [6, 4], [7, 4], [8, 4], [10, 4], [11, 4], [12, 4], [13, 4], [15, 4], [16, 4], [17, 4], [19, 4], [20, 4], [22, 4], [23, 4], [2, 5], [6, 5], [7, 5], [8, 5], [11, 5], [12, 5], [13, 5], [16, 5], [17, 5], [19, 5], [20, 5], [22, 5], [23, 5], [2, 6], [7, 6], [8, 6], [12, 6], [13, 6], [17, 6], [2, 7], [8, 7], [13, 7], [2, 8], [2, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9], [10, 9], [11, 9], [12, 9], [13, 9], [14, 9], [15, 9], [16, 9], [17, 9], [18, 9], [19, 9], [20, 9], [21, 9], [22, 9], [23, 9], [2, 10], [5, 10], [6, 10], [7, 10], [8, 10], [11, 10], [12, 10], [13, 10], [15, 10], [16, 10], [17, 10], [19, 10], [20, 10], [22, 10], [23, 10], [2, 11], [6, 11], [7, 11], [8, 11], [12, 11], [13, 11], [16, 11], [17, 11], [19, 11], [20, 11], [22, 11], [23, 11], [2, 12], [7, 12], [8, 12], [13, 12], [17, 12], [2, 13], [8, 13], [2, 14], [5, 14], [6, 14], [7, 14], [8, 14], [10, 14], [11, 14], [12, 14], [13, 14], [15, 14], [16, 14], [17, 14], [18, 14], [19, 14], [20, 14], [21, 14], [22, 14], [23, 14], [2, 15], [6, 15], [7, 15], [8, 15], [11, 15], [12, 15], [13, 15], [16, 15], [17, 15], [19, 15], [20, 15], [22, 15], [23, 15], [2, 16], [7, 16], [8, 16], [12, 16], [13, 16], [17, 16], [20, 16], [22, 16], [2, 17], [8, 17], [13, 17], [2, 18], [6, 18], [7, 18], [8, 18], [11, 18], [12, 18], [13, 18], [15, 18], [16, 18], [17, 18], [19, 18], [20, 18], [21, 18], [22, 18], [23, 18], [2, 19], [6, 19], [7, 19], [8, 19], [12, 19], [13, 19], [16, 19], [17, 19], [20, 19], [22, 19], [23, 19], [2, 20], [8, 20], [13, 20], [17, 20], [2, 21], [6, 21], [7, 21], [8, 21], [12, 21], [13, 21], [16, 21], [17, 21], [19, 21], [20, 21], [22, 21], [23, 21], [2, 22], [8, 22], [13, 22], [17, 22], [20, 22], [2, 23], [8, 23], [13, 23], [17, 23], [20, 23], [22, 23]}):

Bug???

@mmcdara Thanks. But in newer Maple's version, it doesn't look very aesthetic:  .

@tomleslie I don't know why the first one just returns an error: 

Optimization:-Minimize(((y + z - 2*x)^2 + (z + x - 2*y)^2 + (x + y - 2*z)^2)/((x - y)*(x - z) + (y - z)*(y - x) + (z - x)*(z - y)), variables = {x, y, z}, initialpoint = {(x, y, z) =~ seq(rand(), 3)});
Error, (in Optimization:-NLPSolve) the objective gradients at the initial point are too small
Optimization:-Minimize(((y + z - 2*x)^2 + (z + x - 2*y)^2 + (x + y - 2*z)^2)/((x - y)*(x - z) + (y - z)*(y - x) + (z - x)*(z - y)), (x, y, z) =~ -infinity .. infinity, initialpoint = {(x, y, z) =~ seq(rand(), 3)});
 = 
Warning, no iterations performed as initial point satisfies first-order conditions
     [    [                    11                      11  
     [6., [x = 9.86211147565 10  , y = 1.95011776142 10  , 

                          10]]
       z = 8.6099052027 10  ]]


The objective function is certainly "flat", but only the second one can find the infimum.

@mmcdara Thanks. But unfortunately, these examples don't work in Maple 2015.2.

@toran I'm not sure if I understand right, but I think that you may check the RootFinding Package (particularly the RootFinding[Isolate] command).

@mmcdara Thanks. May you post its URL? I try to search for this, but I get nothing ….

@mmcdara Thanks. However, I think that these don't explain why Maple's internal verifier fails to check the results returned by the solve command.

Why do you use a deprecated function?
Note that using solve instead doesn't change things, but at least you avoid unnecessary problems. 
# showstat~(solvefor, [24, 83]):

solvefor := proc()
local f, i, j, n, basis, vars, V, Vset, sol, t, result, ResultStack, NewResultStack;
       ...
  24           result := traperror(solve(f,{V}));
       ...
  83       return result
       ...
end proc

As you can see, at least on line 24, solvefor can get the same solutions, so one may hope that this function can immediately process them on the next lines. But unfortunately, its output remains incorrect … What a pity!

@acer Thanks. I find the identical error when Maple calls certain external routines: 

(* omitted *)
trace(SMTLIB:-Satisfiable, statements = false):
coulditbe(m, 0);
{--> enter SMTLIB:-Satisfiable, args = {Or(1 <= n_2, n_2 < 0), m_1 = 0, 0 < m_1-(1/2)*n_2^2+(1/2)*n_2}, timelimit = .25
<-- ERROR in SMTLIB:-Satisfiable (now in \`is/internal/SMTLIB\`) = external linking: error loading external library %1: %2, mplsmtlib.dll, �Ҳ���ָ����ģ�顣\r\n}
{--> enter SMTLIB:-Satisfiable, args = {Or(1 <= n_2, n_2 < 0), m_1 = 0, 0 < m_1-(1/2)*n_2^2+(1/2)*n_2}, timelimit = .25
<-- ERROR in SMTLIB:-Satisfiable (now in \`is/internal/SMTLIB\`) = external linking: error loading external library %1: %2, mplsmtlib.dll, �Ҳ���ָ����ģ�顣\r\n}
                              FAIL

I also believe that the problem lies in the compatibility between SMTLIB:-smtlib_execute and vcredist_x64.exe.

@Thomas Richard Thanks. That is strange indeed. https://www.maplesoft.com/support/help/Maple/view.aspx?path=updates/Maple2020/AdvancedMath#section155 says: 

The is command (as well as coulditbe) now makes use of SMTLIB:-Satisfy to help compute some answers involving real variables.

So I guess that the problem is due to some compatibility issue of the SMTLIB package. 
Besides, I find a related compatibility issue of SMTLIB:-Satisfy before. Can you reproduce the same bug in that example? Actually, if I install the Microsoft Visual C++ 2013 x64 Additional Runtime (not "2015-2022"), those errors will disappear immediately, while if I uninstall the Microsoft Visual C++ 2013 Redistributable (x64) (not "2015-2022"), I'll get those errors again.

@Thomas Richard Thanks for your reply. The documentation of coulditbe says that:

The environment variable _EnvTry can be used to specify the intensity of the testing by the is and coulditbe routines. Currently _EnvTry can be set to normal (the default) or hard. If _EnvTry is set to hardis and coulditbe calls can take exponential time.


Besides, have you installed the Microsoft Visual C++ 2013 x64 Additional Runtime? I find that if I install or reinstall it, such computations will no longer fail immediately, while if I uninstall it, I'll get FAIL again. The problem is: Maple 2023.0, by default, don't install Microsoft Visual C++ 2013 Redistributable (x64), as the directory "<Maple>\redist\" (where <Maple> is the Maple installation directory, i.e., kernelopts(mapledir);) only contains two (rather than six) redistributable files.
But why is there a (hidden) compatibility issue? I cannot find it here.

First 11 12 13 14 15 16 17 Page 13 of 19