sursumCorda

922 Reputation

13 Badges

2 years, 206 days

MaplePrimes Activity


These are replies submitted by sursumCorda

@mmcdara Thanks for your advice. However, I find some strange things.
In the first approach, because

for matrices with non-numerical entries, linalg['definite'] returns a conjunction of Boolean expressions, all of which must be true if the matrix is to have the property specified by the parameter `kind`,

it is enough to search for a real instance satisfying the boolean expression. Strangely, the result is not correct.
As for the second approach, I attempt to resolve the conditions via brute-force methods: RealDomani[solve](And(RealDomain[solve](eig_1 >= 0), RealDomain[solve](eig_2 >= 0), RealDomain[solve](eig_3 >= 0), …)). Strangely, the result is still incorrect. 
 

restart``

mm:=<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,1,0,0,0,0,0,0,0,0,0,0,k__3-1/2,0,k__3-1/2,0,0,0,0,0,0,0,0,-1/2,0,1-2*k__3,0,-1/2,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,1,0,k__3,0,-1/2,0,0,0,0,0,0,0,0,0,k__3,0,-2*k__3,0,0,0,0,0,0,0,0,-1/2,0,0,0,0,0|0,0,0,0,0,0,-2*k__3,0,k__3-1,0,-1/2,0,0,0,0,0,0,0,0,0,k__3,0,1-2*k__3,0,0,0,0,0,0,0,0,k__1,0,0,0,0|0,0,0,0,0,k__3,0,1-4*k__3,0,k__3-1,0,0,0,0,0,0,0,0,0,(1-k__2)/2,0,k__3-1/2,0,0,0,0,0,0,0,0,1-2*k__3,0,0,0,0,0|0,0,0,0,0,0,k__3-1,0,1-4*k__3,0,k__3,0,0,0,0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,0|0,0,0,0,0,-1/2,0,1-2*k__3,0,k__1,0,0,0,0,0,0,0,0,0,k__3-1,0,k__3,0,0,0,0,0,0,0,0,-2*k__3,0,0,0,0,0|0,0,0,0,0,0,k__1,0,1-2*k__3,0,-1/2,0,0,0,0,0,0,0,0,0,k__3,0,k__3-1,0,0,0,0,0,0,0,0,-2*k__3,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0,-1/2,0,-2*k__3,0,-1/2,0,0,0,0,0,0,0,0,k__3,0,k__3,0,0,0,0,0,0,1,0|0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>assuming'real':

(* First Approach *)

linalg:-definite(convert(mm, matrix), 'positive_semidef'): # unsolved constraints
SMTLIB:-Satisfy(`%`); # find an instance
LinearAlgebra:-IsDefinite(eval(mm, %), query = 'positive_semidefinite'); # False

{k__1 = -2, k__2 = 19, k__3 = -2}

 

false

(1)

(* Second Approach *)

RootOf~(factors(MTM:-poly(mm))[-1, .., 1], 'x'): # eigenvalues in implicit form
convert~(RealDomain:-solve~(% >=~ 0), `and`): # resolve: each of them ≥ 0
RealDomain:-solve(%, {k__ || (1 .. 3)}, 'maxsols' = 1);
if andmap(is, subs((temp := {k__1 = 5/3, k__2 = 35, k__3 = -7/3}), %)) then
    LinearAlgebra:-IsDefinite(eval(mm, temp), query = 'positive_semidefinite') # False again
fi;

{k__1 <= -2*(k__2*k__3+k__3^2-11*k__3+4)/(k__2-8*k__3+1), k__2 <= 6*k__3^2-3*k__3+1/2, 3*k__3^2+(9/2)*k__3+(1/2)*((4*k__3^2-4*k__3+9)*(3*k__3-2)^2)^(1/2) <= k__2, 6*k__3^2-k__2-k__3+1 <= k__1, k__3 < 1/2-(1/2)*17^(1/2)}

 

false

(2)

NULL


 

Download PSD_BUG.mw

 Is there something wrong?

 

@Carl Love Thanks for knowledge. The documentation of Alias gives me a feeling of being somewhat dangerous. Besides, some new commands in the ArrayTools package seem to compromise on efficiency (maybe for the sake of simplicity?).

@C_R Maple code is as follows: 

interface(printbytes = false): 
with(SignalProcessing, FFT): 
with(LinearAlgebra, HankelMatrix):
for n from 0 to 15 do
    m:=HankelMatrix(<$1+1..2**n+2**n>,datatype=complex[8],shape=[]);
    gc();print(n,time[real](FFT(m,normalization=none,inplace=true)))
od: # shape=[] is not optional

Now you can run Python directly (cf. Connectivity in Maple 2023); nevertheless, FFT is not built into Python.

from os import environ
environ['JAX_ENABLE_X64']="1"
import timeit,jax.numpy as jnp
for n in range(0x10):
	m=sum(jnp.indices((2**n,2**n),sparse=True,dtype='cdouble')+(1,1))
	print(n,timeit.timeit(lambda:jnp.fft.fft2(m),number=1),sep=",")

Here the better choice is using a standalone release.

@Carl Love "evalf[4](…)" is not enough to obtain the desired result. For example, the entry corresponding to 0.0 and 0.09 should be "0.5359" instead of "0.5358". So one has to use "evalf[4](evalf[4+1](…))" in the anonymous function.

@C_R Strangely, although the help page writes that

the code underlying these commands (in the Intel® IPP 2021.6.0 library) does not support Arrays of dimension greater than 1 directly,

this tutorial (updated on 10/26/2015) says that "there are 1D and 2D versions (to compute for real or complex data) in the library".
I believe that the documentation has some typos.

 

@C_R Thanks for your suggestion. But the Signal Processing package only works (and hence, only optimizes) on coerced Vectors with compatible datatype, because the documentation writes that 

when called with an Array of dimension greater than 1 (at most 5), SignalProcessing[FFT] calls the FourierTransform command in the DiscreteTransforms package instead.

Strangely, although it is said that "the code underlying these commands does not support Arrays of dimension two or higher directly", the Intel® IPP help page says that "there are 1D and 2D versions in the library".

I see the QuantifierElimination package (as well as the built-in routine QuantifierEliminate) (new in Maple 2023) as experimental.

@vv I am in agreement with you.
The QuantifierElimination command (since Maple 2020) in the SemiAlgebraicSetTools subpackage of RegularChains appears to be not experimental now. Unfortunately, it seems that neither QuantifierElimination:-QuantifierEliminate nor RegularChains:-SemiAlgebraicSetTools:-QuantifierElimination can effectively eliminate quantifiers (because of the high complexity?). 

Note. In modern Mathematica, the elimination is often much faster (Why??!): 

Mathematica 13.3.0 Kernel for Microsoft Windows (64-bit)
Copyright 1988-2023 Wolfram Research, Inc.

In[1]:= EchoTiming[Resolve[ForAll[{x,y,z},(x|y|z)\[Element]NonNegativeReals\[And]x+y+z\[GreaterEqual]x*y*z-2,12*K+(x+y+z-(-1))^2\[GreaterEqual]K*(y*z+z*x+x*y)+(6-(-1))^2],WorkingPrecision\[RuleDelayed]21+1],Method\[Rule]RepeatedTiming]
>> 10.458

Out[1]= K == 4

In[2]:= EchoTiming[Resolve[ForAll[{x,y,z},(x|y|z)\[Element]NonNegativeReals\[And]x+y+z\[GreaterEqual]x*y*z-2,12*K+(x+y+z-(+2))^2\[GreaterEqual]K*(y*z+z*x+x*y)+(6-(+2))^2],WorkingPrecision\[RuleDelayed]17+1],Method\[Rule]RepeatedTiming]
>> 5.56633

Out[2]= 2 <= K <= 3

I surmise that this is because certain core components call optimized and compiled 𝙲 code rather than execute shallow native 𝙼𝚖𝚊 code ... I suppose so.

All library commands (integrated into the Maple computation engine) are implemented in the high-level Maple programming language, so …

Alas, every coin has two sides; this may also result in uncommon inefficiency (as one has seen here).

@tomleslie Well, I do not believe that this is just a “feature”, and yet Maple 2023 still cannot solve this more carefully.

@vv It is fortunate to see that solve solved those two systems at last (though one has to await them for enough long (!)). Nevertheless, the output of the first system is too complicated

restart;

kernelopts(version);

         Maple 2023.0, X86 64 WINDOWS, Mar 06 2023, Build ID 1689885

 

eqns__1 := {x >= 0, y >= 0, z >= 0, x*y*z+x^2+y^2+z^2 <= 2*(x*y+x*z+y*z), 2*(x^2+y^2+z^2) < x^2*y+x*z^2+y^2*z-27}

eqns__2 := {x > 0, y > 0, z > 0, x*y*z+x^2+y^2+z^2 <= 2*(x*y+x*z+y*z), 2*(x^2+y^2+z^2) <= x^2*y+x*z^2+y^2*z-27}

tic[1] := time[real](); CodeTools:-Usage(PDEtools:-Solve(eqns__1, [x, y, z], AllSolutions))toc[1] := time[real]()-tic[1]

tic[2] := time[real](); CodeTools:-Usage(PDEtools:-Solve(eqns__2, [x, y, z], AllSolutions))toc[2] := time[real]()-tic[2]

memory used=308.64GiB, alloc change=425.50MiB, cpu time=39.46m, real time=17.92m, gc time=31.00m

 

 

 

1076.155

 

memory used=309.75GiB, alloc change=28.00MiB, cpu time=14.70m, real time=10.57m, gc time=5.89m

 

{[[z = 3, y = 3, x = 3]]}

 

634.407

(1)

convert(add(eval(toc)), 'units', 's', 'min')NULL

28.50936667

(2)

Download half_an_hour.mw

As you have expected, the certified result is simply . I cannot know why Maple did not simplify the returned value in a long time, which only leads to an unreadable (and more or less worthless) solution!

@C_R Sorry for misunderstanding. I don't mean that "a = 2/(sqrt(5) + 1) should be treated as a separate solution"; I just want to stress that the output should be “a >= 2/(sqrt(5)+1)” instead of "a > 2/(sqrt(5)+1)". (Isn't this a bug?) 
Besides, I find that this bug can even be reproduced in an old version! 

# in Maple 1x
> solve({a > 0, ln(a)+ln(1+a) >= 0}, a);
 = 
           /      /  2                    \        \ 
          { RootOf\_Z  - _Z - 1, index = 1/ - 1 < a }
           \                                       / 

It seems that Maple's developers still don't know this ….

@mmcdara Thanks for your trick. However, it appears the output is still not very accurate when using larger Digits. (And in many cases, it is even nearly unexpected.) The documentation writes that this package "takes advantage of built-in library routines provided by NAG", but I don't know why it cannot return a result with high precision.

@Axel Vogt As for the "source", it comes from a difficult algebraic inequality. But this question is another thing (as I do not need an exact supremum here).

@acer Thanks for your kind reply. You mention the Optimization package. In my view, this toolbox is much less smart than solve/float, evalf/Int, dsolve/numeric, and evalf/Sum (for some unaccountable reason). One can often find (too) many warning messages and errors during a computation. Well, there is a reasonable prospect that it is no longer actively developed (though is still being maintained (just like the algsubs command)). What a pity.

@Carl Love Many thanks! 
You said that "Maple uses dynamic scoping", but recently, I noticed the following sentence in What Has Changed in Maple V Release 5

Maple V Release 5 implements lexical scoping.

Does this mean that Maple uses a mixed version instead?

@nm You say: "It goes without saying that listing all the proc names in trace([foo,....],statements = false) is not a real solution.". But the following code does work: 

foo:=proc(n,m,k)   
   local r;  
   #if DO_TRACE then
   #   option trace=0:
   #fi;
   
   boo(1);
   r:=n:
   NULL;
 end proc:

boo:=proc(n)   
   local r;  
   r:=n:
   NULL;
 end proc:

trace~([foo, boo], statements = false):
foo(1, 2, 3);
{--> enter foo, args = 1, 2, 3
{--> enter boo, args = 1
<-- exit boo (now in foo) = }
<-- exit foo (now at top level) = }

Is there any misunderstanding?

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