MaplePrimes Questions

When running "C:\Program Files\Maple 2023\bin.X86_64_WINDOWS\cmaple.exe" on my application which makes plots and export them to ps, sometimes I get an exception

              "cannot locate postscript AFM files"

This happens on some plots. Not all. The strange thing, using the same exact run, but from the worksheet, it works fine and I get the .ps generated with no such error. This only happens when running from the command line. It happens here


try
   plotsetup(ps, plotoutput="plot.ps",plotoptions=noborder);
   print(p1);   
   plotsetup(default):
catch:
   print(StringTools:-FormatMessage( lastexception[2..-1] ));
end try;

where p1 above is a plot that was generated earlier OK with no error. I made sure there is no font settings on the plot or any extra options that might cause a problem.

I am not able to make MWE as this problem only shows deep inside my application and only when calling Maple from command line and only shows up on very few plots for some reason I do not understand.  When I made a small .mpl with same code used to make the plot, and run it from command line, the error do not show up. It only shows up when running the whole application from the command line. 

My question is: How does Maple find these postscript AFM files? It looks like the postscript driver used by command like Maple is older than the one used by the frontend/GUI and this is why this error only shows from the command line. Has anyone seen such a Maple error before? 

I have no idea where to find these AFM postscript files it says it can't find and what to do now. I am on windows 10.

Any suggestion what to lookfor and anything else I can do to help me find the cause of this?

If it is any help, here is the MWE I tried to reproduce this with. But this generated no error. Call this foo.mpl

foo:=proc()
local p1,ode,y,x;
   ode:=3*y(x)+x*diff(y(x),x) = 2*x^5;
   p1 := DEtools:-phaseportrait(ode,y(x),x=-1..5,[y(2)=1],y=-1000..1000):
   try
      plotsetup(ps, plotoutput=cat("C:/tmp/plot.ps"),plotoptions=noborder);
      print(p1);   # also tried without "display"
      plotsetup(default):
   catch:
      print(StringTools:-FormatMessage( lastexception[2..-1] ));
      print("Exception");
   end try;
end proc;

foo();

Then run 

 

C:\tmp>"C:\Program Files\Maple 2023\bin.X86_64_WINDOWS\cmaple.exe"  foo.mpl

No error. The error only shows in my large application.

                             "cannot locate postscript AFM files"

Will keep trying to make a MWE, but for 3 hrs now, no luck yet.

Update

I've added 

if lasterrorlocus<>'lasterrorlocus' then
                     print(lasterrorlocus);
                     showsource();
end if; 

Inside the catch, which print the exact location of the exception generated. It is at print(p1) as you see

again, same code runs with no problem from the worksheet. This only shows when running from command line. Will keep trying to make MWE...

When translating Maple expression with special math functions, Maple does not use the same familar name shown in worksheet, but replaces these special functions with one letter. 

This makes it very hard when looking at the equations in latex and the pdf to know what these special functions are. 

Is there an option to keep the same name used in Maple but use the \operatorname{name} in the latex generated? This will go a long way to improve the output and make one understand what they are looking at.

Here are examples below. Notice as side note, that Maple does not translate pochhammer at all. Is this a bug? It only gave its arguments in the latex. 

I think everyone will agree that reading BesselJ in the equation is more clear than reading J and reading hypergeom is more clear than and reading  MeijerG is more clear than and so on as one does not have to guess what these letters mean when looking at the final output in pdf.  
 

1384004

restart;

1384004

expr:=BesselJ(1,x);
latex(expr)

BesselJ(1, x)

J_{1}\! \left(x \right)

expr:=hypergeom( [],[],z );
latex(expr)

hypergeom([], [], z)

{}_{0}^{}{\moversetsp{}{\mundersetsp{}{F_{0}^{}}}}\! \left(;;z \right)

expr:=pochhammer(3/10, n);
latex(expr)

pochhammer(3/10, n)

\left(\frac{3}{10}\right)_{n}

expr:=MeijerG([[1, 1, 1, 1], []],[[], [4, 3, 2, 2]],Pi);
latex(expr)

MeijerG([[1, 1, 1, 1], []], [[], [4, 3, 2, 2]], Pi)

G_{4,4}^{0,4}\! \left(\pi \bigg| {\mstack{1,1,1,1}{4,3,2,2}}\right)

 


It should not be hard to provide an option for latex() in Maple (say Keep_special_function_math_names:=true) and keep default as is now.

Then all what Maple needs to do is simply generate \operatorname{BesselJ} instead of and \operatorname{hypergeom} instead of and \operatorname{pochhammer} and so on for any special function that does not have any standard Latex known notation. Even if one can argue that somewhere somehow someone should know that F is hypergeom and one should know that J means BesselJ and so on for dozens of other single letters used, I think it is much more clear to the reader to see the full name of the function as it shows in Maple worksheet.

The rest of the arguments remain the same exactly as shown by Maple on the screen and no need to make any changes there. It is only the name of the function which is the problem.

This only applies for all the special math function names ofcourse.

Any chance of making such changes to Maple's latex()? I tried to make the changes by post-processing the latex as string using patterns and string replace, but this was breaking things as it is not possible to just simply change letter J to BesselJ for example, as the letter J can be anything else in the latex. I think the best solution is to do this at the source, when the latex is generated by Maple.

Version 2023 on windows.

Download latex_math_functions.mw

ps. removed the list to make the question shorter as requested.

 

Let's put aside the drawbacks of using goto for now. Below is the program I wrote. When I run it, it seems to execute, but the Maple interface displays the message "System error,,at top level". Does this trigger an internal warning in Maple?

for i to 4 do
    for j to 4 do
         print([i,j]):
        if i = 2 and j = 3 then
             goto(al):
        end if:
    end do:
end do:
al;

                             [1, 1]

                             [1, 2]

                             [1, 3]

                             [1, 4]

                             [2, 1]

                             [2, 2]

                             [2, 3]

                  System error, , at top level

                               al

I have the following code below:

eq := -((2*(alpha[3]+alpha[2]))*((1/2)*cos(Theta(z, t))^2-(1/2)*sin(Theta(z, t))^2)+(alpha[3]-alpha[2])*(sin(Theta(z, t))^2+cos(Theta(z, t))^2))*(diff(U(z, t), z))-(alpha[3]-alpha[2])*(2*sin(Theta(z, t))^2*(diff(Theta(z, t), t))+2*cos(Theta(z, t))^2*(diff(Theta(z, t), t)))+(diff(Theta(z, t), z, z))*k

simplify(subs(simplify(coeff(eq, diff(U(z, t), z))) = t1, eq))

Please, why is maple not assigning t1 to the coefficient of diff(U(z, t), z)) in the expression? 

The example below is an attempt to solve a boundary value problem (BVP) without manually replacing terms in expressions and some questions where there might be room for improvement. (Only the first integration step is shown to keep it short)

My objective is to have clean Maple input with minimal manual interventions or low-level manipulations (such as using op and similar commands).

NULL

ode := diff(phi(s), s, s)+K*cos(phi(s)) = 0

diff(diff(phi(s), s), s)+K*cos(phi(s)) = 0

(1)

NULL

map(int, ode, s)

int(diff(diff(phi(s), s), s)+K*cos(phi(s)), s) = 0

(2)

Student[ODEs]:-Integrate(ode, phi(s))

Error, (in assuming) when calling 'Student:-ODEs:-Integrate'. Received: 'The given ODE, diff(diff(phi(s),s),s)+K*cos(phi(s)) = 0, is not exact'

 

...not a clue for me


Since I know the result: Multiplying by diff(phi(x), x) to make integration work.  Q1: Are there other ways to integrate a single step without a priori knowledge?

(diff(phi(s), s))*ode

(diff(phi(s), s))*(diff(diff(phi(s), s), s)+K*cos(phi(s))) = 0

(3)

NULL

int(lhs((diff(phi(s), s))*(diff(diff(phi(s), s), s)+K*cos(phi(s))) = 0), s)+c__1 = 0

(1/2)*(diff(phi(s), s))^2+K*sin(phi(s))+c__1 = 0

(4)

Boundary condition for s = L 

Eval(diff(phi(s), s), s = L) = `&phi;'`[0]

Eval(diff(phi(s), s), s = L) = `&phi;'`[0]

(5)

(4) evaluated at the boundary

expand(map(Eval, (1/2)*(diff(phi(s), s))^2+K*sin(phi(s))+c__1 = 0, s = L))

Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)

(6)

Q2: How to simplify expression (6) with (5) using Maple commands to get this expression for the integration constant

``

c__1 = -(1/2)*`&phi;'`[0]^2-K*sin(Eval(phi(s), s = L))

c__1 = -(1/2)*`&phi;'`[0]^2-K*sin(Eval(phi(s), s = L))

(7)

Some attempts

algsubs(Eval(diff(phi(s), s), s = L) = `&phi;'`[0], Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)); applyrule(Eval(diff(phi(s), s), s = L) = `&phi;'`[0], Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)); simplify(Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L), {Eval(diff(phi(s), s), s = L) = `&phi;'`[0]}); Physics:-Substitute(Eval(diff(phi(s), s), s = L) = `&phi;'`[0], Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L))

Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)

 

Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)

 

Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)

 

Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)

(8)

``

map(`^`, Eval(diff(phi(s), s), s = L) = `&phi;'`[0], 2)

(Eval(diff(phi(s), s), s = L))^2 = `&phi;'`[0]^2

(9)

Doing it manually

isolate(subs({Eval(0, s = L) = 0, Eval((1/2)*(diff(phi(s), s))^2, {s = L}) = (1/2)*`&phi;'`[0]^2}, Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L)), c__1)

c__1 = -(1/2)*`&phi;'`[0]^2-(Eval(K*sin(phi(s)), {s = L}))

(10)

or

isolate(algsubs(value(Eval(diff(phi(s), s), s = L) = `&phi;'`[0]), value(Eval((1/2)*(diff(phi(s), s))^2, {s = L})+Eval(K*sin(phi(s)), {s = L})+c__1 = Eval(0, s = L))), c__1)

c__1 = -(1/2)*`&phi;'`[0]^2-K*sin(phi(L))

(11)

subs(phi(L) = Eval(phi(s), s = L), c__1 = -(1/2)*`&phi;'`[0]^2-(Eval(K*sin(phi(s)), {s = L})))

c__1 = -(1/2)*`&phi;'`[0]^2-(Eval(K*sin(phi(s)), {s = L}))

(12)

Q3: Are there ways to prevent commands evaluating Eval(phi(s), s = L)to phi(L)which might suggest incorrectly a new independent variable?

Q4: In (6), why is s = L sometimes in brackets {} ?

``

Download BVP_with_questions.mw

Could someone help me understand why Maple's int hangs when using int on an integrand if evala is not first applied to the integrand?

When I mean hangs, I mean really hangs. I have timelimit and maple server.exe runs at high CPU for hrs. When adding evala(), it completes instantly and returns unevaluated integral (which is just fine as I did not expect this to be evaluated) but it does not hang which is the main point.

Is this considered normal behaviour or a bug?  Should then one always add evala() on the integrand before using int?  As I get many hangs on int (even when using timelimit). I am not familiar with evala command as I have never had to use it before, but by chance I tried it and noticed this.

V 2023 on windows 10. Worksheet attached.


 

186932

restart;

186932

expr:=-1/3*2^(2/3)/((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)*((-1/2*a^2*p-1/2*p^2*a+1/2*p*((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)*a-3)*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(2/3)+2^(2/3)*p*(-(a+3/2*p)*p*((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a^2*p+5/2*p^2*a+3/2*p^3+3))/(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p)/(-1/2*2^(2/3)*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(2/3)+p*(p*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(1/3)+2^(1/3)))/p^2:
try
    anti := timelimit(30,int(evala(expr),p));
catch:
    print("timed out OK");
end try:
print("done");

"done"

restart;

expr:=-1/3*2^(2/3)/((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)*((-1/2*a^2*p-1/2*p^2*a+1/2*p*((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)*a-3)*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(2/3)+2^(2/3)*p*(-(a+3/2*p)*p*((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a^2*p+5/2*p^2*a+3/2*p^3+3))/(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p)/(-1/2*2^(2/3)*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(2/3)+p*(p*(-p^2*(-((a^2*p+2*a*p^2+p^3+4)/p)^(1/2)+a+p))^(1/3)+2^(1/3)))/p^2:
try
    anti := timelimit(30,int(expr,p));
catch:
    print("timed out");
end try;
print("done");


The second case above just hangs. Make sure to save all your work. I found I have to terminate all of Maple sometimes as killing server.exe seems to make the frontend hangs and not respond, ending up losing work in other worksheets which I did not save.

Download int_hangs_june_2_2023.mw

I'm new in maple.I'm just learning, i couldn't get the solution.Please help me to solve this Error.

Here is my code.

sps-RK_Method.mw

I am updating older files.

Executing with the attached code snippet from a worksheet created with Maple 16 outputs for an inert integral

instead of

Why is that and how can I fix my old worksheets to make them work with Maple 2023?

Maybe related: Execution with (or return) does not evaluate the document blocks. When all document blocks are expanded with "right click show command" the cursor does not advance to the next execution group. I can't remenber if this behaviour was allways like this or has changed.

A suggestion for Maplesoft: I have stopped using document blocks with hidden code since hiding and showing commands requires too much time (to many clicks and mouse movements). A simple double click on the marker of the document block could facilitate hiding and showing code allot.

Output_of_Int_not_in_2d.mw

Hello there, 

Is there any chance to ask for your expertise in this issue of substitution?

I tried to make the expression 'eq_m1' to 'eq_m1_desired' by substituting 'L__ads*L__fd/(L__fd + L__ads)' as 'L__ads_p', but did not succeeded, after a series of different attempts. Would you show me how to achive the desired expression?

restart;

with(LinearAlgebra):

with(DynamicSystems):

interface(imaginaryunit=j):

eq_m1 := m1 = (X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/(R__E^2 + 2*R__a*R__E + R__a^2 + X__E^2 + X__E*L__ads*L__fd/(L__fd + L__ads) + 2*X__E*L__l + L__aqs*X__E + L__aqs*L__ads*L__fd/(L__fd + L__ads) + L__aqs*L__l + L__l*L__ads*L__fd/(L__fd + L__ads) + L__l^2);

m1 = (X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(R__E^2+2*R__a*R__E+R__a^2+X__E^2+X__E*L__ads*L__fd/(L__fd+L__ads)+2*X__E*L__l+L__aqs*X__E+L__aqs*L__ads*L__fd/(L__fd+L__ads)+L__aqs*L__l+L__l*L__ads*L__fd/(L__fd+L__ads)+L__l^2)

(1)

eq_m1_desired := m1 = (X__Tq*E__B*sin(delta) - R__T*E__B*cos(delta))/(R__E^2 + 2*R__a*R__E + R__a^2 + X__E^2 + X__E*L__ads_p + 2*X__E*L__l + L__aqs*X__E + L__aqs*L__ads_p + L__aqs*L__l + L__l*L__ads_p + L__l^2);

m1 = (X__Tq*E__B*sin(delta)-R__T*E__B*cos(delta))/(L__aqs*L__l+L__aqs*X__E+L__aqs*L__ads_p+L__l^2+2*L__l*X__E+L__l*L__ads_p+R__E^2+2*R__E*R__a+R__a^2+X__E^2+X__E*L__ads_p)

(2)

######

#eq_m1a := subs({L__ads*L__fd/(L__fd + L__ads) = L__ads_p}, eq_m1);

#eq_m1a := subs({L__ads_p = L__ads*L__fd/(L__fd + L__ads)}, eq_m1);

#eq_m1a := applyrule(L__ads*L__fd/(L__fd + L__ads) = L__ads_p, eq_m1);

#eq_m1a := algsubs(L__ads_p = (L__ads*L__fd)/(L__fd + L__ads), eq_m1);

#eq_m1a := algsubs((L__ads*L__fd)/(L__fd + L__ads) = L__ads_p, eq_m1);

#eq_m1a := eval(eq_m1, L__ads_p = (L__ads*L__fd)/(L__fd + L__ads));

 

Download Q20230602.mw

  • A set D of vertices in a graph G is a dominating set if each vertex of G that is not in D is adjacent to at least one vertex of D.
  • The minimum cardinality among all dominating sets in G is called the domination number of G and denoted σ(G).
  • We define the bondage number b(G) of a graph G to be the cardinality of a smallest set E of edges for which σ(GE)>σ(G). 

In the previous post, Carl Love provided a code for calculating domination number, so we could use it to calculate bondage number. I wrote a piece of code using a relatively basic approach. I feel like there is room for improvement.  I still can't determine the bondage number of the following graph so far.

 

restart:
with(GraphTheory):
with(Iterator):
#Author: Carl Love <carl.j.love@gmail.com>, the Glorious 1st of June, 2023
#
Domination_number:= (G::Graph)->
local V:= {$nops(op(3,G))}, A:= op(4,G) union~ `{}`~(V), s, v, U:= table([{}= {}]), Us;
    in V do
        for s in {indices}(U, 'nolist') do
            Us:= U[s]; U[s]:= evaln(U[s]);
            for v in V minus s do
                if (U[s union {v}]:= Us union A[v]) = V then return nops({s[], v}) fi
            od
        od
    od
:

 

Bondage_number:=proc(g::Graph)
local dom,vn,edge_ofg,t,M,removeedge,H,i,hasNext, getNext,result;
dom:=Domination_number(g);
vn:=nops(op(3,g));
edge_ofg:=convert(Edges(g),list);
result:="Null";
for t from 1 to vn do
    M := Combination(vn, t);
    hasNext, getNext := ModuleIterator(M);
      while hasNext() do
        removeedge:= {seq(edge_ofg[i], i in getNext()+~1)};
        H := DeleteEdge(g, removeedge,inplace = false);
        if Domination_number(H)> dom then       
         result:=nops(removeedge);
         break t;
        end if;  
      end do;
end do:
return result;
end proc:

ed:={{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 7}, {1, 9}, {1, 11}, {2, 3}, {2, 5},
 {2, 6}, {2, 7}, {2, 12}, {2, 14}, {3, 4}, {3, 7}, {3, 8}, {3, 9}, {3, 16}, {4, 5},
 {4, 9}, {4, 10}, {4, 11}, {4, 17}, {5, 6}, {5, 11}, {5, 12}, {5, 19}, {6, 7}, {6, 12},{6, 13}, {6, 14}, {6, 21}, {7, 8}, {7, 14}, {7, 15}, {8, 9}, {8, 14}, {8, 15}, {8, 16}, {8, 22}, {9, 10}, {9, 16}, {9, 17}, {10, 11}, {10, 17}, {10, 18}, {10, 19}, {10, 23}, {11, 12},{11, 18}, {11, 19}, {12, 13}, {12, 19}, {12, 20}, {13, 14}, {13, 19}, {13, 20}, {13, 21}, {13, 24},{14, 15}, {14, 21}, {15, 16}, {15, 21}, {15, 22}, {15, 24}, {16, 17}, {16, 22}, {16, 23}, {17, 18},
{17, 22}, {17, 23}, {18, 19}, {18, 20}, {18, 23}, {18, 24}, {19, 20}, {20, 21}, {20, 23}, {20, 24},{21, 22}, {21, 24}, {22, 23}, {22, 24}, {23, 24}}:
g:=Graph(ed);

GRAPHLN(undirected, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], Array(1..24, {(1) = {2, 3, 4, 5, 7, 9, 11}, (2) = {1, 3, 5, 6, 7, 12, 14}, (3) = {1, 2, 4, 7, 8, 9, 16}, (4) = {1, 3, 5, 9, 10, 11, 17}, (5) = {1, 2, 4, 6, 11, 12, 19}, (6) = {2, 5, 7, 12, 13, 14, 21}, (7) = {1, 2, 3, 6, 8, 14, 15}, (8) = {3, 7, 9, 14, 15, 16, 22}, (9) = {1, 3, 4, 8, 10, 16, 17}, (10) = {4, 9, 11, 17, 18, 19, 23}, (11) = {1, 4, 5, 10, 12, 18, 19}, (12) = {2, 5, 6, 11, 13, 19, 20}, (13) = {6, 12, 14, 19, 20, 21, 24}, (14) = {2, 6, 7, 8, 13, 15, 21}, (15) = {7, 8, 14, 16, 21, 22, 24}, (16) = {3, 8, 9, 15, 17, 22, 23}, (17) = {4, 9, 10, 16, 18, 22, 23}, (18) = {10, 11, 17, 19, 20, 23, 24}, (19) = {5, 10, 11, 12, 13, 18, 20}, (20) = {12, 13, 18, 19, 21, 23, 24}, (21) = {6, 13, 14, 15, 20, 22, 24}, (22) = {8, 15, 16, 17, 21, 23, 24}, (23) = {10, 16, 17, 18, 20, 22, 24}, (24) = {13, 15, 18, 20, 21, 22, 23}}), `GRAPHLN/table/1`, 0)

(1)

Domination_number(g)

4

(2)

Bondage_number(g);#Long time..

 

 

Bondage_number.mw

For arbitrarily given graph, it has been proved that determining its bondage number is NP-hard.

I always have a feeling that when removing subsets of edges, the symmetry of these edge subsets can be utilized. Above, we blindly traverse k-subsets of edges. If the graph is symmetric enough, perhaps we can reduce the amount of traversal. However, I have been struggling to understand how to express the symmetry of these edge subsets. Recently, I raised a similar question.