sursumCorda

1174 Reputation

13 Badges

2 years, 45 days

MaplePrimes Activity


These are questions asked by sursumCorda

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 
                               []


Here are two systems over the reals:

sys__1:=And(r*(387*r+52)+2<r*(226*q+121*s)+9*q*(q*(2*q-5)-3*s+2)+6*s,4*q^3+r*(27*r+4)+s^2=q*(q+18*r),q>=0,r>=0):
sys__2:=And((392-1739*q)*r+4*(2-9*q)**2+2151*r**2<75*r*s,4*q**3+r*(27*r+4)+s**2=q*(q+18*r),q>=0,r>=0):

The following results indicate that both and are satisfiable 

QuantifierElimination:-QuantifierEliminate(exists([s,q,r],sys__1));
                              true
QuantifierElimination:-QuantifierEliminate(exists([s,q,r],sys__1));
                              true

but RealDomain:-solve simply returns an empty list (that is, no solution exists) in both cases

RealDomain:-solve(sys__1,[q,s,r]); # ⟹ sys1 cannot be satisfied
                               []
RealDomain:-solve(sys__2,[q,s,r]); # ⟹ sys2 cannot be satisfied
                               []

As discussed in the previous problem, in contrast to using QuantifierElimination:-QuantifierEliminate, the use of RealDomain:-solve is unsafe. Nevertheless, the above output suggests that even the much-more-sophisticated QuantifierElimination:-QuantifierEliminate is still not always reliable (since the correct returnedvalue appears to be in lieu of ). So, what is the right command to handle polynomial systems over real domains in Maple? 

The first time they are evaluated, some aborts can occur; the second time they are evaluated, no exception is thrown: 
 

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1806 and is the same as the version installed in this computer, created 2024, September 11, 11:27 hours Pacific Time.`

(1)

restart;

RootOf(
        9*x1-5+RootOf(8*_Z**2+_Z-43, 41629632769253767815/18446744073709551616 .. 20814816384626883921/9223372036854775808), x1, 171590466306199/562949953421312 .. 343180932612401/1125899906842624
);

Error, (in property/ProbablyNonZero) cannot determine if this expression is true or false: ln(.1e11*abs(-.304805898398896+1.*RealRange(.304805898398895,.304805898398897)))/ln(10) < -6

 

RootOf(
        9*x1-5+RootOf(8*_Z**2+_Z-43, 41629632769253767815/18446744073709551616 .. 20814816384626883921/9223372036854775808), x1, 171590466306199/562949953421312 .. 343180932612401/1125899906842624
);

5/9-(1/9)*RootOf(8*_Z^2+_Z-43, 41629632769253767815/18446744073709551616 .. 20814816384626883921/9223372036854775808)

(2)

RootOf(
        2*x1-3+RootOf(_Z**2+2*_Z-11, 181818607464242035159/73786976294838206464 .. 363637214928484070345/147573952589676412928), x1, 301683970796757/1125899906842624 .. 150841985398379/562949953421312
);

Error, (in property/ProbablyNonZero) cannot determine if this expression is true or false: ln(2500000000.*abs(-.267949192431123+1.*RealRange(.267949192431122,.267949192431123)))/ln(10) < -6

 

RootOf(
        2*x1-3+RootOf(_Z**2+2*_Z-11, 181818607464242035159/73786976294838206464 .. 363637214928484070345/147573952589676412928), x1, 301683970796757/1125899906842624 .. 150841985398379/562949953421312
);

3/2-(1/2)*RootOf(_Z^2+2*_Z-11, 181818607464242035159/73786976294838206464 .. 363637214928484070345/147573952589676412928)

(3)


 

Download run__twice.mw

Why does (the outer) RootOf have to be evaluated twice? 
Note. There are other similar examples, but they are less concise (so they are omitted here).

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