Maple 2023 Questions and Posts

These are Posts and Questions associated with the product, Maple 2023

Why does

restart;
eq:=Z^2=y/x;
solve(eq,Z)

give

I never told maple that y>=0 and x>=0 ?   I was expecting what we will do by hand. which is

Note that sqrt(x*y) is same as sqrt(x)*sqrt(y) only when y and x are not negative. 

Is there an option to make Maple not do this and give same result as above? I tried PDEtools:-Solve and it gives same solution as solve.

Maple 2023.2.1 on windows 10

This worksheet loses contact with the kernel. I asked Tech Support. How do I report a bug?

Hung.mw

The last line was a typo, but, it should not lose contact with the kernel...

After executing the print statement,

> 1

produces the error message.

Tom Dean

For example, here are two equations containing trigonometric functions (Note that they do not form one system!): 

restart; # There are more examples, yet for the sake of briefness, they are omitted here. 
eqn__0 := cos(x)*cos(y)*cos(x + y) = 2*(sin(x)*sin(y) - 1)*2*(sin(x)*sin(x + y) - 1)*2*(sin(y)*sin(x + y) - 1):
eqn__1 := (cos(x + y) - (cos(x) + cos(y)) + 1)**2 + 2*cos(x)*cos(y)*cos(x + y) = 0:

Unfortunately, none of 

(* Tag0 *) RealDomain:-solve(eqn__0, {y, x}):
(* Tag1 *) solve(eqn__0, {y, x}) assuming y + x >= 0, (y, x) <=~ Pi:
(* Tag2 *) RealDomain:-solve(eqn__1, {y, x}):
(* Tag3 *) solve(eqn__1, {y, x}) assuming y + x >= 0, (y, x) <=~ Pi:

outputs concise solutions.
Using `plot3d`, it is easy to check that when "And(y + x >= 0, (y, x) <=~ Pi)", “{y = Pi/2, x = 0}, {y = Pi/3, x = Pi/3}, {y = 0, x = Pi/2}, {y = Pi/2, x = Pi/2}” is both the only solution to "eqn__0" and the only solution to "eqn__1". But how to get Maple to do so without manual intervention?

Edit. The main purpose is to automatically find the generic solutions to each of the two equations (Tag0 and Tag2) (separately). Now that the cosine and sine functions are both periodic with period 2π and both (lhs - rhs)(eqn__0) and (lhs - rhs)(eqn__1) are even symmetric, it is enough to focus only on the region y + x ≥ 0 ∧ (y, x) ≤~ Pi. So, in theory, a second-best workaround should be Tag1 and Tag3. However, why is Maple still unable to find the four exact solutions above?

This could be new bug in 2023.2.1, could someone else confirm if it is in earlier versions 2023.2 ?

restart;
ode:=diff(y(x),x)-y(x)^2-m*y(x)*cot(x)-b^2*sin(x)^(2*m) = 0;
DEtools:-symgen(ode)

Error, (in trig/reduce) too many levels of recursion

After about 30 seconds.

I tried it in Maple 2022.2  I waited for more than 10 minutes and it was still running.  If you think it is new bug, will send email to Maple support.

The big problem with these Maple internal errors, is that it is not possible to trap them with try/catch. So the program simply crashes and there is no workaround.

``

restart;

35880

interface(version)

`Standard Worksheet Interface, Maple 2023.2, Windows 10, November 24 2023 Build ID 1762575`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1615 and is the same as the version installed in this computer, created 2023, November 29, 17:28 hours Pacific Time.`

ode:=diff(y(x),x)-y(x)^2-m*y(x)*cot(x)-b^2*sin(x)^(2*m) = 0;

diff(y(x), x)-y(x)^2-m*y(x)*cot(x)-b^2*sin(x)^(2*m) = 0

DEtools:-symgen(ode);

Error, (in tools/map) too many levels of recursion

 


reported to Maple support

Download trig_reduce_recursion_dec_20_2023.mw

 I have been trying to run a code to plot a region of stability for a numerical method for solving IVPs. Apart from the fact that it is taking time to run, it is giving me errors: 'Error; (inplots/ implicitplot/factor) and  Error; (inplot/ iplot2d:-Levels ) could not evaluate expression' 

 Attached here is the code:

K=4

NULL

with(LinearAlgebra):

NULL

P1 := simplify(A1-ScalarMultiply(A3, z)-ScalarMultiply(A5, z^3)):

Error, (in plots/implicitplot/factor) invalid input: the following extra unknowns were found in the input expression: {P5[4]}

Error, (in plot/iplot2d:-Levels) could not evaluate expression

NULL

Download RAS(TDFFAM).mw

The help page mentions: 

The package supports five q-hypergeometric terms. They are q-Pochhammer symbol, q-binomial coefficient, q-brackets, q-factorial, and q-Gamma, which correspond to the five functions , , , , and . 

But what about the so-called q-hypergeometric function? Though there exist QDifferenceEquations:-IsQHypergeometricTerm and QDifferenceEquations:-QHypergeometricSolution in Maple, they do not seem to represent the function itself
For example, how to type the q-Gauss sum (cf. DLMF's §17.6(i)) or verify the last “simple series expression” given in Basic hypergeometric series - Wikipedia? In Mma, one may achieve these with something like 

while 

convert("QHypergeometricPFQ[{a, b}, {c}, q, c/(a b)]", 'FromMma', 'evaluate');
 = 
                              /                 c \
            QHypergeometricPFQ|[a, b], [c], q, ---|
                              \                a b/

So has the q-hypergeometric function been implemented in Maple?

What is the correct way, in code, to check if Maple result contains any one of its own global build in symbols such as _Z or _C or any such symbol it uses?

I need to bypass this result. Currently I check explicitly, but I am sure there is a better way. Here is an example

r:=discont(1/tan(x),x);

This returns 

Currently I do 

if has(r,_Z1)  or has(r,_Z2) or has(r,_Z3) then
etc...

same for _C1, _C2., etc...

But this method is not robust. The problem is that _Z1 is symbol. So I can't check for symbol type in the  result as result could possibly have one of my own symbols there depending on input.

Is there  better way to do this? I am only asking about output of discont here and not any other Maple function. I assume discont uses _Zn only but I am not sure. It could use different symbol? 

given 

r1:=   -1 <= x and x <= 0;
r2:=   0 <= x and x <= 1;

We see that the above can be simplified to one inequality

-1<= x and x<=1

The closest I found to do this is

r1:=-1 <= x and x <= 0;
r2:=0 <= x and x <= 1;
solve(r1 or r2,x);

which gives RealRange(-1, 1) but I'd like to get the form  -1<= x and x<=1 similar to:

I tried convert to piecewise and simplify and few other things. Is there a trick in Maple to simplify/combine/join inequalites like the above? i.e. convert RealRange(-1, 1) to -1<=x and x<=1 

everything is on the real line.

Maple 2023.2

> kernelopts(version)
   Maple 2023.2, X86 64 LINUX, Nov 24 2023, Build ID 1762575

I got results I did not expect using &^ and mod. So, I created a simple example.

powermod.mw

&^ ... mod does not seem to allow () to set order of execution where ^ ... mod does.

How does &^ ... mod arrive at the values that are different than ^ ... mod?

Tom Dean

how do i change the decimal separator, i cant find the setting anywhere. I already changed all the settings in windows related to this. It displays numbers the way i want it to, by separating decimals using a comma, since that's what I'm used to. My regional settings on windows are also correct, however I can't seem to get maple to use the same separation. It looks like 123.13 when i want it to be 123,13. I couldn't find a solution online so I made an account here in the hope of finding a solution. Thanks

I would like to simulate the evolution of the so-called B, C, K, W system and SKI combinator calculus in Maple.
The rewrite rules of them are simple: 

S(x)(y)(z)=x(z)(y(z))
K(x)(y)=x, and 
I(x)=x. (Note that since  is protected, I shall use  hereafter.)

However, if I try to evaluate the following example given in the  article, 

Maple will only return an unchanged result: 

restart;
applyrule([cS(x::anything)(y::anything)(z::anything) = x(z)(y(z)), 
   cK(x::anything)(y::anything) = x, cI(x::anything) = x], 
  cS(cK(cS(cI)))(cS(cK(cK))(cI))(x)(y)); # Unable to reduce??? 
 = 
              cS(cK(cS(cI)))(cS(cK(cK))(cI))(x)(y)

I believe that this is not an outlier.
Here are two additional instances: 

> rls := [cS(x::anything)(y::anything)(z::anything) = x(z)(y(z)), cK(x::anything)(y::anything) = x]:
> map2(applyrule, rls, [cS(cS(cS)(cS))(cS)(cS(cS))(cK), cS(cS(cS))(cS)(cS)(cS)(cS(cS)(cK(cK)))]);
                       [cS(cS(cS)(cS))(cS)(cS(cS))(cK), cS(cS(cS))(cS)(cS)(cS)(cS(cS)(cK(cK)))]

>

So why can't `applyrule` apply rules as desired? Meanwhile, how to automatically and thoroughly (like :-eval['recurse'] or MmaTranslator:-Mma:-ReplaceRepeated) apply those transformation rules to 

  1. , and

I have read something like How to apply a recursive rule in an expression? - MaplePrimes, but they are not the same issue.

I have this overloaded function foo(). 

restart;

foo:= overload(  
        [
        proc(A::integer,$)option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);             
        end proc,

        proc(A::integer,B::integer,$)option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc
       ]);

Which works OK. so I can now do 

foo(1)
foo(1,2)

But I wanted to indicate that the proc returns say ::integer , and this where I am stuck, I do not know where to add this ::integer

With non-overloaded proc's, this is the syntax

foo:=proc(A::integer,$)::integer;
     ......
end proc;

but I can't do this with the overloaded function. If I type

foo:= overload(  
        [
        proc(A::integer,$)option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);             
        end proc,

        proc(A::integer,B::integer,$)option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc
       ])::integer;

Maple simply does not like it. typing foo(1) now it just echos the definition back.

And these give syntax errors

foo:= overload(  
        [
        proc(A::integer,$)::integer option overload;
            print("first one, _passed = ", _passed," _npassed = ",_npassed);    
        end proc,

        proc(A::integer,B::integer,$)::integer option overload;
            print("second one  _passed = ", _passed," _npassed = ",_npassed);
        end proc
       ]);

Tried many other variations and looked at help but see nothing to far.

Can one add ::type to indicate type proc returns with overloaded proc?

Maple 2023.2.1

I want to execute a function at least one time. So, I use do ... until ...

However, the function sometimes returns FAIL. So, I looked at help FAIL.

FAIL.mw

The while loop works. The until loop returns an error. evalb(testeq(...)=FAIL) seems overly complicated.

Tom Dean

I am starting a course on differential forms. They have introduced the wedge product by comparing it to the curl product. I can do it by hand. But I would like to do it in Maple. I tried to read the help page of with(difforms) but I cannot see how to do it. And to add to the complication, since my keyboard is in French, I don't know how to insert the circumflex accent right after &. Maybe I should just wait that more theory is done, but just for the principle, I would like to be able to do it. For example, the vectors are:

a=(1, 3,-2)

b=(5, 2, 8)

Thank you in advance for your help.

Mario

The attached integral is plotted quite quickly, but the search for the maximum and for the inverses of function values takes time. Can the search be accelerated or is the integrand simply too complicated?

Int(22.89730452*exp(-3.373250126*10^6*x^2)*sqrt(2)*(erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7)-x^2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7)-x^2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc)

Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc)

(1)

plot(Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc), y = 0 .. .25)

 

unapply(int(op(1 .. 2, Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc))), y)

proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc

(2)

CodeTools:-Usage(Optimization:-Maximize(proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*(x^2))*(2^(1/2))*(erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc, 0 .. .15))

[HFloat(0.0356073228322897), Vector[column](%id = 36893490875463313756)]

(3)

CodeTools:-Usage(fsolve((proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*(x^2))*(2^(1/2))*(erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc)-0.5e-2, 0 .. .15, maxsols = 2, method = subdivide))

0.2456248637e-1, 0.9863751363e-1

(4)

Download slow_maximize_and_fsolve.mw

4 5 6 7 8 9 10 Last Page 6 of 26