sursumCorda

1239 Reputation

15 Badges

2 years, 234 days

MaplePrimes Activity


These are replies submitted by sursumCorda

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

@vv That's a pity; I don't know why Maple® cannot handle real algebraic functions directly and then give a more readable (but still correct) solution.
Let us see what Symbolic Math Toolbox™ returns: 

MuPAD's_solve

@vv Thanks.

This could be very difficult (or even impossible) to obtain in general.

But how about the poster's question (instead of generalized cases)? 

@vv Thanks. But how do I force Maple to eliminate the dummy variable t3 from the output automatically (instead of by hand later)? Actually, the desired result should resemble piecewise(t1 <= 0, t2 < 0, t1 > 0, t2 <= (1/4)*t1^2).

@vs140580 Sorry, I just want to reply to CL's "fast or slow" statement. I don't answer your question.

@Carl Love Thanks.

Incidentally, it appears that the seq version is somewhat faster: (Another comparison.) 

restart;

Normalizer := rcurry(RealDomain[simplify], assume = positive):
checknn__1 := proc(f::And(symmfunc(x, y, z), freeof({x, y, z}) &under (e -> ifelse(testeq(e), 0, simplify(eval(e, [x, y, z] =~ 'l'*~[x, y, z])/e, symbolic)))), n::coerce(posint, MTM:-uint32) := 2^16, $)::truefalse;
    options encrypted, hfloat;
    description `All rights reserved.`;
    local F := `assuming`(map(combine@simplify, subs(z = 6 - (x + y), f)), (x, y, 6 - (x + y)) >~ 0);
    local ind::posint, data := LinearAlgebra:-RandomMatrix(n, 2, generator = 0 .. 1., datatype = float[4]);
    andseq((() -> args[-1] >= 0)((ind := k), evalhf(subs((w -> {x = 2*w(1), y = 3*w(2) - w(1)})(sort(data[k])), F))), k = 1 .. n);
    `if`(%, eval('% and evalb(ind = n), WARNING("precision may be lost")'), unapply(%)(print([x, y, z] =~ (w -> [2*w(1), 3*w(2) - w(1), 3*(2 - w(2)) - w(1)]/6)(sort(data[ind])))))
end:

CodeTools[Usage](`#msub(mi("checknn"),mi("1"))`(x^3+y^3+z^3-(3+1/10000)*x*y*z, 0.1e6))

[x = HFloat(0.3328814307848612), y = HFloat(0.3331732551256816), z = HFloat(0.3339453140894572)]

 

memory used=102.60MiB, alloc change=46.00MiB, cpu time=1.83s, real time=1.67s, gc time=562.50ms

 

false

(1)

NULL

 

Download iRandomPointVector1.mw
 

restart;

Normalizer := rcurry(RealDomain[simplify], assume = positive):
checknn__2 := proc(f::And(symmfunc(x, y, z), freeof({x, y, z}) &under (e -> ifelse(testeq(e), 0, simplify(eval(e, [x, y, z] =~ 'l'*~[x, y, z])/e, symbolic)))), n::coerce(posint, MTM:-uint32) := 2^16, $)::truefalse;
    options encrypted, hfloat;
    description `All rights reserved.`;
    local data, F := (map(combine@simplify, subs(z = 6 - (x + y), f)) assuming (x, y, 6 - (x + y)) >~ 0);
    to n do
        data := sort(Statistics:-Sample(Uniform(0, 1), 2)) . <2, -1; 0, 3>;
        if not evalhf(subs({x = data[1], y = data[2]}, F)) >= 0 then
            print([x, y, z] =~ [data[1], data[2], 6 - (data[1] + data[2])]/~6);
            return false
        fi
    od;
    WARNING("precision may be lost");
    true
end:

CodeTools[Usage](checknn__2(x^3+y^3+z^3-(3+1/10000)*x*y*z, 0.1e6))

[x = HFloat(0.3329693776781595), y = HFloat(0.3333573368712247), z = HFloat(0.3336732854506157)]

memory used=1.35GiB, alloc change=158.00MiB, cpu time=2.37m, real time=2.34m, gc time=3.81s

false

NULL

 

Download iRandomPointVector2.mw

@vs140580 How large is your n? However, I think that the most convenient way is using seq(seq(seq(…, k in list), j in list), i in list); (or seq(…, l in combinat:-choose(list, 3));).
(By the way, it seems to me that using for loops in Maple is generally not the most efficient way to iterate over some index variable(s).)

First 15 16 17 18 19 20 21 Page 17 of 23