sursumCorda

922 Reputation

13 Badges

2 years, 207 days

MaplePrimes Activity


These are replies submitted by sursumCorda

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

@acer Thanks for your observation.
Can anyone reproduce that bug in Maple 2018?

@mmcdara Thanks. If I understand right, for this purpose, I have to replace the problem variables manually first. So, is it impossible to find the exact supermun directly?
Actually, I have some more complex expressions, but Maple's maximize (or minimize) often gives incorrect results without any exception messages (although the Student[MultivariateCalculus][LagrangeMultipliers] function sometimes works). 

@Carl Love Well, you may consider 

k*x*y - (x - y)^2/2; # which is equal to (1 + k)*x*y - (x^2 + y^2)/2

 for some real parameter k. When k = 0, its supremum is just 0, while when k > 0, its supremum is no longer 0 (but it appears that Maple don't know this fact). (As the arithmetic mean-geometric mean inequality says, we have x2y2≥2xy, where the coefficient "2" cannot be replaced with a larger number in general.)

@QM I agree you. This example is simple enough, so it's not hard to find (and then fix) such a bug; nonetheless, ensuring the correctness would never be users' responsibility!

@C_R Thanks. That's really strange. I don't know what happened in Maple 2023: sqrt(A^2) doesn't work, but sqrt(A)^2, sqrt(A*A), and sqrt(A)*sqrt(A) all works.

@C_R Thanks for your try. Since the error occurs in `simplify/sqrt/fraction`, can you reproduce this in Maple 2022.2? 
 

interface(version) = `Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`NULL

restart;

showstat(`simplify/sqrt/fraction`, 1 .. 2)


`simplify/sqrt/fraction` := proc(f)
local i, nu, de, n, d, nr, dr, g, j, ex, a, gtmp, rmvd, N;
   1   n := traperror(numer(f));
   2   if n = lasterror then
           ...
       end if;
       ...
end proc
 

 

FUNC := proc (x::{list, set, algebraic}) options operator, arrow; end proc

x := -1

proc (x::{list, set, algebraic}) options operator, arrow; end proc

(1)

Typesetting:-mrow(Typesetting:-mi("f0", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo("proc", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("f", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "firstprocnewline"), Typesetting:-mo("local", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("n", italic = "true", mathvariant = "italic"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("traperror", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("FUNC", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("f", italic = "true", mathvariant = "italic")), mathvariant = "normal")), mathvariant = "normal"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "firstprocnewline"), Typesetting:-mi("evalb", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("n", italic = "true", mathvariant = "italic"), Typesetting:-mo("=", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("lasterror", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "decreaseindentnewline"), Typesetting:-mo("end", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"))

Typesetting:-mrow(Typesetting:-mi("f1", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mo("proc", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("f", italic = "true", mathvariant = "italic")), mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "firstprocnewline"), Typesetting:-mo("local", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("n", italic = "true", mathvariant = "italic"), Typesetting:-mo("&coloneq;", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("traperror", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("numer", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("f", italic = "true", mathvariant = "italic")), mathvariant = "normal")), mathvariant = "normal"), Typesetting:-mo(";", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.2777778em"), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "firstprocnewline"), Typesetting:-mi("evalb", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(""), Typesetting:-mrow(Typesetting:-mi("n", italic = "true", mathvariant = "italic"), Typesetting:-mo("=", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-mi("lasterror", italic = "true", mathvariant = "italic")), Typesetting:-mi("")), mathvariant = "normal"), Typesetting:-mi(""), Typesetting:-mspace(height = "0.0ex", width = "0.5em", depth = "0.0ex", linebreak = "decreaseindentnewline"), Typesetting:-mo("end", bold = "true", mathvariant = "bold", fontweight = "bold", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mo(":", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"))

f0("")

true

(2)

f1("")

false

(3)

NULL


 

Download lasterror.mw

@Preben Alsholm Many thanks. Could you test f~(x,y) and f~(x,` $`,y) additionally? (I think that the latter would run a bit faster, but I cannot confirm this.)

@Scot Gould This works: 

restart;
with(Units):
Automatically loading the Units[Simple] subpackage


A := 1, 2, 3:
B := 4, 5, 6:
AB := :-eval('B' - 'A');
                         AB := 3, 3, 3

Note that the original B - A is equivalent to 

Units:-Simple:-`+`(B, Units:-Simple:-`-`(A));
                               11

B - A;
                               11

:-eval('B' - 'A'); # fix it
                            3, 3, 3

 

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