Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I am getting this error. Is this expected or known issue?  

restart;
sol:=-csgn(1, 1/(_C1*a - _C1*x - 1))*_C1*a^4/((k + 1)*(_C1*a - _C1*x - 1)^2) + 4*csgn(1, 1/(_C1*a - _C1*x - 1))*_C1*a^3*x/((k + 1)*(_C1*a - _C1*x - 1)^2) - 6*csgn(1, 1/(_C1*a - _C1*x - 1))*_C1*a^2*x^2/((k + 1)*(_C1*a - _C1*x - 1)^2) + 4*csgn(1, 1/(_C1*a - _C1*x - 1))*_C1*a*x^3/((k + 1)*(_C1*a - _C1*x - 1)^2) - csgn(1, 1/(_C1*a - _C1*x - 1))*_C1*x^4/((k + 1)*(_C1*a - _C1*x - 1)^2) + a^2/((k + 1)*(_C1*a - _C1*x - 1)^2) - 2*a*x/((k + 1)*(_C1*a - _C1*x - 1)^2) + x^2/((k + 1)*(_C1*a - _C1*x - 1)^2) + csgn(1, 1/(_C1*a - _C1*x - 1))*a^3/((k + 1)*(_C1*a - _C1*x - 1)^2) - 3*csgn(1, 1/(_C1*a - _C1*x - 1))*a^2*x/((k + 1)*(_C1*a - _C1*x - 1)^2) + 3*csgn(1, 1/(_C1*a - _C1*x - 1))*a*x^2/((k + 1)*(_C1*a - _C1*x - 1)^2) - csgn(1, 1/(_C1*a - _C1*x - 1))*x^3/((k + 1)*(_C1*a - _C1*x - 1)^2) - csgn(1/(_C1*a - _C1*x - 1))*a^2/((k + 1)*(_C1*a - _C1*x - 1)^2) + 2*csgn(1/(_C1*a - _C1*x - 1))*a*x/((k + 1)*(_C1*a - _C1*x - 1)^2) - csgn(1/(_C1*a - _C1*x - 1))*x^2/((k + 1)*(_C1*a - _C1*x - 1)^2);

solve( simplify(sol)=0,x,allsolutions = true) assuming real; #also x::real, same error

Maple 2020.2 on winsows 10. Physics 897

 

 

Here is a very nice (but not easy) elementary problem.
The equality
ceil(2/(2^(1/n)-1)) = floor(2*n/ln(2));

             

is not an identity, it does not hold for each positive integer n.
How to find such a number?

[This is a re-post, because the original vanished when trying a conversion Question-->Post]

The problem appears in the recent book:
Richard P. Stanley - Conversational Problem Solving. AMS, 2020. 

The problem is related to a n-dimensional tic-tac-toe game. The first counterexample (2000) was wrong due to a multiprecision arithmetic error.
The  author of the book writes 
"To my knowledge, only eight values of n are known for which the equation fails,
and it is not known whether there are infinitely many such values",

but using Maple it will be easy to find more.

A brute-force solution is problematic because the smallest counterexample is > 7*10^14.

restart;
a := 2/(2^(1/n)-1): b := 2*n/ln(2):
asympt(b-a, n);

        

It results:  b - a → 1 (for n →oo);
So, to have a counterexample, b must be close to an integer
m ≈ 2*n/ln(2)  ==> n/m ≈ ln(2)/2

The candidates for n/m will be obviously the convergents of the continued fraction of the irrational number ln(2)/2.
 

convert(ln(2)/2, confrac, 200, 'L'):
Digits:=500:
for n in numer~(L[3..]) do
  if not evalf(ceil(a)=floor(b)) then printf("n=%d\n", n) fi;
od:

n=777451915729368
n=140894092055857794
n=1526223088619171207
n=54545811706258836911039145
n=624965662836733496131286135873807507
n=1667672249427111806462471627630318921648499
n=36465374036664559522628534720215805439659141
n=2424113537313479652351566323080535902276508627
n=123447463532804139472316739803506251988903644272
n=97841697218028095572510076719589816668243339678931971
n=5630139432241886550932967438485653485900841911029964871
n=678285039039320287244063811222441860326049085269592368999
n=312248823968901304612135523777926467950572570270886324722782642817828920779530446911
n=5126378297284476009502432193466392279080801593096986305822277185206388903158084832387
n=1868266384496708840693682923003493054768730136715216748598418855972395912786276854715767
n=726011811269636138610858097839553470902342131901683076550627061487326331082639308139922553824778693815

 

So, we have obtained 16 counterexamples. The question whether there are an infinity of such n's remains open.

 

The following command returned 1026 instead of 1000 samples. Any ideas why?

R1 := Sample(Normal(0, 1), 1000);
length(R1);
 

Thanks

restart; with(plots):unprotect(gamma):
_EnvHorizontalName := 'x';_EnvVerticalName := 'y';
line := proc (x1, y1, x2, y2) options operator, arrow; (x-x1)*(y2-y1)-(y-y1)*(x2-x1) end proc:
R := 3:
ang := [0, (1/3)*Pi, 3*Pi*(1/4)+.2, 7*Pi*(1/6)+.4, 8*Pi*(1/5), 13*Pi*(1/7)]:
for i to 6 do P || i := [R*cos(ang[i]), R*sin(ang[i])] end do:
pts := [seq(P || i, i = 1 .. 6)]:
for i to 6 do tang || i := x*P || i[1]+y*P || i[2] = R^2 end do:
sol:=solve({tang1,tang3},{x,y}):Q13:=[subs(sol,x),subs(sol,y)]:
sol := solve({tang1, tang2}, {x, y}): Q1 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang2, tang3}, {x, y}): Q2 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang3, tang4}, {x, y}): Q3 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang4, tang5}, {x, y}): Q4 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang5, tang6}, {x, y}): Q5 := [subs(sol, x), subs(sol, y)]:
sol := solve({tang1, tang6}, {x, y}): Q6 := [subs(sol, x), subs(sol, y)]:
ptQ := [seq(Q || i, i = 1 .. 6)]:
line14 := line(Q1[1], Q1[2], Q4[1], Q4[2]): L14 := implicitplot(line14, x = -10 .. 10, y = -10 .. 10, color = red):
line25 := line(Q2[1], Q2[2], Q5[1], Q5[2]): L25 := implicitplot(line25, x = -10 .. 10, y = -10 .. 10, color = red):
line36 := line(Q3[1], Q3[2], Q6[1], Q6[2]): L36 := implicitplot(line36, x = -10 .. 10, y = -10 .. 10, color = red):
sol := solve({line14, line25}, {x, y}): I1 := [subs(sol, x), subs(sol, y)]:

lineP23 := line(P2[1], P2[2], P3[1], P3[2]): lineP56 := line(P5[1], P5[2], P6[1], P6[2]):
sol := solve({lineP23, lineP56}, {x, y}): gamma := [subs(sol, x), subs(sol, y)]:
lineP12 := line(P1[1], P1[2], P2[1], P2[2]): lineP45 := line(P4[1], P4[2], P5[1], P5[2]):
sol := solve({lineP12, lineP45}, {x, y}): beta := [subs(sol, x), subs(sol, y)]:
lineP34 := line(P3[1], P3[2], P4[1], P4[2]): lineP16 := line(P1[1], P1[2], P6[1], P6[2]):
sol := solve({lineP16, lineP34}, {x, y}): alpha := [subs(sol, x), subs(sol, y)]:
pl:= line(alpha[1], alpha[2], gamma[1], gamma[2]):
hexa := seq(implicitplot(tang||i, x = -20 .. 20, y = -20 .. 20, linestyle=3,color = blue),i=1..6):
#hexa:=plot([seq([P||i,P||(i mod 6)+1],i=1..6),color=green): 
#hexa:=plot([seq([P||i,P||(i+1)],i=1..6)],thickness=4,color=green): 
hex:=plot([[Q1,Q2],[Q2,Q3],[Q3,Q4],[Q4,Q5],[Q5,Q6],[Q6,Q1]],thickness=4,color=green):
tp := textplot({seq([op(pts[i]), cat("P", i)], i = 1 .. 6)}, 'align' = {'above', 'left'}):
tpq := textplot({seq([op(ptQ[i]), cat("Q", i)], i = 1 .. 6)}, 'align' = {'above', 'left'}):
TP:=textplot([[I1[],"I"],[alpha[],"alpha"],[beta[],"beta"],[gamma[],"gamma"]],'align' = {'above', 'left'}):
slopes:=[seq(((dx,dy)->dy/dx)((pts[i]-pts[(i mod 6)+1])[]),i=1..6)]:
lines:=zip((pt,slope)->y=slope*(x-pt[1])+pt[2],pts,slopes):
plotpts:=plot(pts,style=point,colour=red,symbol=solidcircle,symbolsize=5):
plotptQ:=plot(ptQ,style=point,colour=black,symbol=solidcircle,symbolsize=5):
plotlines:=plot(rhs~(lines),style=line,linestyle=3,colour=magenta):
cir:=implicitplot(x^2+y^2=R^2,x=-R..R,y=-R..R,color=black):
PL:=implicitplot(pl,x=-1..15,y=-15..6,color=blue,thickness=3):
display(plotpts,plotptQ,plotlines,hex,cir,L14,L25,L36,PL,tp,tpq,TP,axis = [gridlines = [4, color = blue]],
view=[-6..10,-15..6],scaling=constrained,axes=none,size=[800,800]):
How to simplify this program ? Thank you.

Should dsolve has missed this solution? I used singsol=all option:

restart;
ode:=y(x)^2+(x^2+x*y(x))*diff(y(x),x) = 0;
dsolve(ode,y(x),singsol=all)

But y(x)=0 is singular solution. It can not be obtained from the above general solutions for any constant of integration value.

odetest(y(x)=0,ode)

                 0

if I change the type of ode, Maple now gives y(x)=0 but the general solution is too complicated (which is OK) but the point is that it does now find y(x)=0.

dsolve(ode,y(x),[dAlembert]);


           y(x)=0,  etc.....

my question is: Why singsol=all did not also give y(x)=0 in this example?  Is there something I am misundertanding here?

Maple 2020.2

I've been struggling to implement a more complicated version of the example from Acer here:
    https://www.mapleprimes.com/questions/231110-Typesetting-In-Plots-

The basic idea is that Maple allows XML for typesetting (and maybe MathML? I don't use the MLs, so I can't speak to limitations or differences).

It's somewhat straightforward, but extremely tedious. The statement that this is " undocumented, but not overly difficult " may be true, but it's time-consuming to learn bits and pieces of any additional language just to typeset something that resembles extremely common typesetting language, and frankly feels like a waste of time. In a world where we have LaTeX, I don't see why Maple can't use LaTeX language for typesetting in plots. Python, MatLAB have this feature, and a homebrew version of this for Mathematica came up during my searching, but nothing useful for Maple. The Physics package  has some function to take the Maple and produce LaTeX code (untested by me so far), but not being able the other direction to typeset axes, titles, and textplots with LaTeX notation is shocking to me.

When one attempts the tag formating from html/XML like here:
  https://www.maplesoft.com/support/help/Maple/view.aspx?path=MathML
or formatting, errors come up. Basic things like having control over a given character's size seem impossible without the tag formatting, and I tried for some time to get all sorts of variations of #mstyle to work using the syntax method of the linked question. The converters that I've found that go from LaTeX to MathML use this tag formatting.

Here are some examples that I made up to demonstrate acer's method and one particular area where the MathML spectactularly fails compared to LaTeX, and included to (current as of this moment) links that give element names for XML and symbol names for html/xml:
https://developer.mozilla.org/en-US/docs/Web/MathML/Element
https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

MapleXMLExamples.mw

The contents are failing to be inserted, but the file downloads correctly from the preview for me.

Hi

A user with a new install of maple 2020 is unable to plot graphs. they get the output seen in the attached image. I mostly provide desktop support and i'm not too familiar with Maple, so i'm reaching out for assistance. Thanks in advance.

I just had enough with odetest hanging (even when using with timelimit). I wait hours and hours each time (even though I have 30 second timelimit, which Maple ignores) and I do not think Maplesoft is going to fix this in my lifetime.  

So I am attempting to make my own very simple and basic odetest.

I give it an ode and explicit solution in for form sol:= y(x)=... and the function uses algsubs(sol,ode) and checks it is gets zero or not (it will also do simplify if needed)

But there is a BIG problem.   Even though algsubs(z=0,z/z);  gives back 1 as expected,  but

restart;
ode:=diff(y(x), x)/y(x);
sol:=y(x)=0;

algsubs(sol,ode);   #this gives ZERO. It should be 1

If we do algsubs on each term one by one

algsubs(sol,numer(ode));
algsubs(sol,denom(ode));

            0
            0

So why did algsubs give zero in the first case, since  the result of the algsubs should be 0/0 which algsubs knows in the limit it is 1?   How did it come up with zero?

Clearly my simple method of replacing odetest with algsubs is not working. I need a more robust way to handle this.

subs does not work. Since subs does not know how substitute y(x)=f(x) into derivatives involved in an ODE.

My question is: Is there a way to teach algsubs to give 1 for the above example? or better function to use?

I tried applyrule instead of algsubs, but that does not work.

applyrule(sol, ode)

Error, (in rec) numeric exception: division by zero
 

Is there a better method to use? I am trying to do simple version of odetest that does not hang. Even if not perfect. Will only use it for explicit solutions, not implicit since implicit is much harder.

Here is a more full example

ode:=diff(y(x),x)^2+2*x*diff(y(x),x)/y(x)-1 = 0;
sol:=y(x)=0;
odetest(sol,ode)

                            0

But when I use my simple method

ode:=diff(y(x),x)^2+2*x*diff(y(x),x)/y(x)-1 = 0;
sol:=y(x)=0;
algsubs(sol,ode);

                          -1 = 0

The reason it failed, because algsubs replaced the second term by 0 instead of 1. The second term in the ode is diff(y(x),x)/y(x)

Which is 0/0 but this is 1 in the limit. But algsubs used 0 instead for some reason.

So I need a little bit smarter way to replace my solution into the ode than just using algsubs. May need to use some of the tricks I've seen used here before using freez/thaw/frontend, etc.. which I still do not understand.

Any recommendation?  This is meant to work for any single ode and any explicit solution of the form y(x)=....

This algsubs method works actually pretty well on many ode's. I've tested it on 2,000 ode's. It just fails so far on subtle ones like the above. Here is just random example where it works

restart;
ode:=diff(y(x),x)^2 = (-x+1)/x;
sol:=y(x)=_C1+arcsin(2*x-1)/2+sqrt(x-x^2);

evalb(simplify(algsubs(sol,ode)))

                     true

So I just need a way to handle the cases where it gives 0/0 I think. I have 20 ODE's which now fail out of about 2,000 using this basic method compared to using odetest.

 

Thank you

I was trying to simplify long expression of the form    f(x)=g(x), where f(x) should simplify to be the same as g(x) and get 0=0. But Maple simplify just return the input back.

Then I wrote simplify(f(x)-g(x)) and now Maple returned 0 back.

What is the difference between simplify (f(x)=g(x)) and simplify(f(x)-g(x))? And why the second worked but not the first?

restart;
f:=(9*(x^(-2/3*a))^2*exp(6/a*(x^(-2/3*a))^(1/2))^2*_C0^2-6*(x^(-2/3*a))^(3/2)*exp(
6/a*(x^(-2/3*a))^(1/2))^2*_C0^2*a+x^(-2/3*a)*exp(6/a*(x^(-2/3*a))^(1/2))^2*_C0^
2*a^2+18*(x^(-2/3*a))^2*exp(6/a*(x^(-2/3*a))^(1/2))*_C0-2*x^(-2/3*a)*exp(6/a*(x
^(-2/3*a))^(1/2))*_C0*a^2+6*(x^(-2/3*a))^(3/2)*a+x^(-2/3*a)*a^2+9*(x^(-2/3*a))^
2)/(3*_C0*exp(6/a*(x^(-2/3*a))^(1/2))*(x^(-2/3*a))^(1/2)-exp(6/a*(x^(-2/3*a))^(
1/2))*_C0*a+3*(x^(-2/3*a))^(1/2)+a)^2:

g:=x^(-2/3*a):

And now

simplify(f=g);

But

simplify(f-g);

                                                           0

And

simplify(f-g=0);

                 0 = 0 

Why Maple behaves like this? I did not know it makes difference if one writes f=g vs. f-g in terms of simplification. 

I copied the code to Mathematica to see how it behaves, and Mathematica Simplify worked on both f=g and also on f-g as one would have expected:

 

Maple 2020.2 on windows

 

I need to label the roots, extrema, and inflection points of this function I have, of which there are six in total. The official help pages didn't seem to have anything on labelling individual points of a plot, and the only relevant question in the forums I could find pertained to labelling one point, not several. Thank you for your help.

With this application, the differential equation of forced systems is studied directly. It comes with embedded components and also with native Maple code. Soon I will develop this same application with MapleSim. Only for engineering students.

Damped_Forced_Movement.mw

Lenin AC

Ambassador of Maple

I have a procedure for calculating flow through a control valve and part of the calculatiion requires an interative solution if the Reynolds number is less than 10000.  I wrote a little proc in Maple to house the calculation and then I am trying to call it from fsolve.  One of the conditions in the calculation is hat if the Re >= 10000 then just exit and return the input since no correction is necessary.  However, I can't get the Reynolds number to evaluate in the condition Reynolds >= 10000 it keeps returning this error.

Error, (in ValveLaminarMassFlow_proc) cannot determine if this expression is true or false: 10000.0 <= 8848.331994*x
 

where x is an input parameter in the procedure call.

I have tried everything I could think of and I just have to give up and I would appreciate any help with this.

 

fsolve_if_then_not_evaluating_in_proc.mw

Loading a package and using a member with single quotes leads Maple to display the package name, for example

with(IntegrationTools):
Int(f(x), x):

'Change(%, x=1/t, t)'; 
                                     /
                                    |
          IntegrationTools:-Change( |  f(x) dx, x = 1/t, t)
                                    |
                                   /

Is there an easy way to avoid the display of the package name in such a command?


Moreover I sometimes use eval(foo) to display a (former) definition of a function foo and then also the package name is printed (which I do not always want to see) if it was used in the definition.

For the last hr, I've been trying to find out why Maple solve was hanging inside one module in my .mla when called.

I would try the same code in new worksheet, no hang. I had timelimit on it. Same exact code as in the module.

I go back to the other worksheet, do restart, call the module (after loading the library by setting libname) which calls solve(), and it hangs. Each time.

I tried may be 10 times. No difference between the code in the mla and the other worksheet where I had copy of the solve command. All other settings are the same. 

ONLY after I closed Maple, and restarted Maple, and opened the worksheet where the call used to hang, and called the module again, now it did not hang and solve completed.

This is not the first time I've seen such a strange thing. Sometimes Maple will hang for hrs (I start  a test, go to sleep,. wake up hrs later, and see maple hanged for hrs from the time stamp).

Closes Maple, start the test from where it was hanging, and now no hang. It runs OK from then on.

This tells me that doing just restart from the worksheet do not clean everything. (I use the command restart, not by pressing the restart button in the menu, not sure if these are different, they should be the same  I would think).

I've seen this problem before. sometimes the test just hangs. No matter how many time I do restart from the worksheet, it just hangs. When I restart Maple, it works from same place it was hanging.

My question is, what could possibly make Maple not hang when starting fresh. vs. using the restart command?  I am using the same worksheet, and I have "create new engine for each document" selected in options.

The hang used to happen in solve, in here

#this is inside a function inside a module inside .mla library
#

eq:=x = 1/2/(p^2+2)^(1/8)*2^(1/2)*((1+(-4*p^2+1)^(1/2))/(1/(4*p^2-1)*p^2)^(1/2)/(-4
*p^2+1)^(1/2))^(3/4)/(((-4*p^2+1)^(1/2)+3)/(p^2+2)^(1/2))^(1/4)*_C1*p^(1/4);

        try               
            sol_p:=timelimit(20,[:-solve(x=rhs(eq),p)]);
        catch:
           return [];
        end try;
#hangs here. Never completes. Only when starting Maple the hang is gone. 

#trace below
......
Main: polynomial system split into 1 parts under preprocessing
Main: using RegularChains based methods
SolverVariableOrder: using the variable order  _S000008 > _S000011 > _S000009 > _S000006 > _S000005
TriangularDecomposition: using deterministic algorithm for decomposition
<<<< HANGS HERE EACH TIME >>>>

Again, only when I restarted Maple, did the hang go away. it is one equation solving for one variable.

So now, I get into the habit of closing all of Maple and starting it again when I get a hang. I do not trust restart command any more to clear everything.

Any idea why this happens? Memory not cleared somewhere? Cache problem? Does the frontend itself stores something that could cause this? does restart use new mserver.exe each time or same mserver.exe process as last time?

if restart does not actually terminate the mserver.exe that the worksheet was talking to, but only sends request to mserver.exe to clear its own memory, this could explain things.

It is possible that mserver.exe which is attached to that worksheet does not fully clear all its own memory and something remain there which affects why it hangs in same place each time, even though restart was issued each time, and only when restarting Maple itself will clear this and the hangs goes away.

 

 

 

Is there a way in Maple to extract the indices themselves?

Example:

node [2,3,5]: = 7

 I want is to be able to obtain the number 2, 3 and 5 separetly.

Thanks.

 

First 329 330 331 332 333 334 335 Last Page 331 of 2097