sursumCorda

1194 Reputation

15 Badges

2 years, 112 days

MaplePrimes Activity


These are questions asked by sursumCorda

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

The output RealDomain:-solve(x**2 + 2*cos(x) = (Pi/3)**2 + 1, [x]) means that there is no real solution, but clearly, both x = -Pi/3 and x = +Pi/3 satisfy the original equation: 

So, why does `solve` lose the real solutions without any warning messages? 
Code: 

restart;
eq := 9*(x^2 + 2*cos(x)) = Pi^2 + 9;
RealDomain:-solve(eq, [x]);
                               []

:-solve({eq, x >= 0}, [x]); # as (lhs - rhs)(eq) is an even function 
                               []


1 2 3 4 5 6 7 Last Page 1 of 23