sursumCorda

1244 Reputation

15 Badges

2 years, 242 days

MaplePrimes Activity


These are questions asked by sursumCorda

As the following worksheet shows, Student:-NumericalAnalysis:-MatrixDecomposition cannot factorize the input matrix  and throws an error, but if we simply reorder or exchange the elements of , no error will be raised. (The reason for setting  is that LinearAlgebra:-LUDecomposition can be used for other methods.) 
 

restart

with(Student:-NumericalAnalysis, MatrixDecomposition)

m := Matrix([[3*(sqrt(3)+1)/8,-1/2,1/2,-(sqrt(3)+1)/8,-1/2,1/2,-(sqrt(3)+1)/8,-1/2,1/2,-(sqrt(3)+1)/8],

             [-1/2,sqrt(3)-1,-(sqrt(3)-1),-1/2,0,0,1/2,0,0,1/2],

             [1/2,-(sqrt(3)-1),sqrt(3)-1,1/2,0,0,-1/2,0,0,-1/2],

             [-(sqrt(3)+1)/8,-1/2,1/2,3*(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8],

             [-1/2,0,0,1/2,sqrt(3)-1,-(sqrt(3)-1),-1/2,0,0,1/2],

             [1/2,0,0,-1/2,-(sqrt(3)-1),sqrt(3)-1,1/2,0,0,-1/2],

             [-(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8,-1/2,1/2,3*(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8],

             [-1/2,0,0,1/2,0,0,1/2,sqrt(3)-1,-(sqrt(3)-1),-1/2],

             [1/2,0,0,-1/2,0,0,-1/2,-(sqrt(3)-1),sqrt(3)-1,1/2],

             [-(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8,1/2,-1/2,-(sqrt(3)+1)/8,-1/2,1/2,3*(sqrt(3)+1)/8]],

            'shape'='symmetric'):

MatrixDecomposition(m, 'method' = 'LDLt'): # this does not work 

Error, (in Student:-NumericalAnalysis:-MatrixDecomposition) a pivot element 0 is encountered, and the entries below it are not all 0; the factorization cannot continue

 

MatrixDecomposition(m([1, 4, 7, 10, 2, 5, 8, 3, 6, 9] $ 2), 'method' = 'LDLt'): # yet this works 

MatrixDecomposition(m([2, 3, 5, 6, 8, 9, 1, 4, 7, 10] $ 2), 'method' = 'LDLt'): # this also works 

randomize(5):

k := 0:
to 1e3 do
        try
                MatrixDecomposition(m(combinat:-randperm(10) $ 2), 'method' = 'LDLt')
        catch :
                k++
        end
od:
k/1e3;

.469

(1)


 

Download LDL_factorization_robustness.mw

The last instance above suggests that it only works on about half of the inputs (that are equivalent to each other). Although I tried changing the value of Digits, the failure rate remained high. Is Student:-NumericalAnalysis:-MatrixDecomposition not robust enough? 

I would like to generate a brief description of the object Iterator:-Product but I get the following error:  

Describe(Iterator:-Product);

object Product :: Class<<36893490916968945900>>:

    ModuleApply( )

    ModuleCopy( self::_Product, proto::_Product, 
Error, (in Describe) `proto` does not evaluate to a module

How do I get rid of this message? 

If I understand right, in the following calling an exception should be raised since the return value of the matching coercion procedure is of course not of type “set”: 

restart;
foo := (x::coerce(set, (y::rtable) -> convert(y, list))) -> x:
foo(<0>);
 = 
                              [0]

Did I miss something?

The goal is to eliminate x, y and z from [a^2=(4*y*z)/((x+y)*(x+z)),b^2=(4*z*x)/((y+z)*(y+x)),c^2=(4*x*y)/((z+x)*(z+y))]. However, eliminate only outputs a null expression (I added a  to emphasize it): 

restart;
expr := 4*[y*z/((x + y)*(x + z)), z*x/((y + z)*(y + x)), x*y/((z + x)*(z + y))]:
{eliminate}([a, b, c]**~2 =~ expr, [x, y, z]);
 = 
                               {}

Why is the result empty? 
In my view, the result should be (a*b*c)**2 = ((a**2 + b**2 + c**2) - 2**2)**2 (or its equivalent). One may verify this by: 

seq(seq(seq(
    is(eval((a^2 + b^2 + c^2 - 4)^2 = (a*b*c)^2, 
      elementwise([a, b, c] = [k1, k2, k3]*sqrt(expr)))), 
    `in`(k3, [-1, +1])), `in`(k2, [-1, +1])), `in`(k1, [-1, +1]));
 = 
         true, true, true, true, true, true, true, true

Recently, I read an old article about how to call external subroutines to speed up the evaluation tremendously. The core of that article is: 

Evidently, the Typesetting:-mrow(Typesetting:-mi( is equivalent to  when b>0, and the `∸`(a, b) is equivalent to . 
The 𝙲 code in that article was composed separately. However, now that it is possible to generate external functions, compile and access them using a single Compiler:-Compile command, it is better to complete the entire process on the fly (in order to reduce oversights and typographical errors while coding). (Besides, the original π™ΌπšŠπš™πš•πšŽ implementation appears verbose and less elegant.) So I write: 

JonesM1 := Compiler:-Compile((n::posint) -> add(max(1 - max(add(ifelse(j = 0, max(j - 1, 0)!**2, irem(max(j - 1, 0)!**2, j)), j = 0 .. i) - n, 0), 0), i = 0 .. n**2), 'O' = 2): # literal translation of the above formula 

But unfortunately, I then get: 

JonesM1(1);
                               2

JonesM1(2);
                               3

JonesM1(3);
                               5

JonesM1(4);
Error, (in JonesM1) integer overflow detected in compiled code

How do I get rid of this error message? 

Note. Of course there exist a ready-to-use built-in function , but the chief aim is not to find the n-th prime number as quickly as possible; I want to see if π™ΌπšŠπš™πš•πšŽ can directly create a compiled version of the one-liner that implements the so-called Jones' algorithm instead of writing separate 𝙲 code like that article. (Don't confound the means with the ends.) 

1 2 3 4 5 6 7 Last Page 1 of 23
ο»Ώ