MaplePrimes Questions

Search Questions:

"What's new in Maple 2020" explain an exciting new option for DrawGraph: layout=interactive, that should allow you to move vertices in the plot. I tried this in the help page opened in a worksheet window and it works.

Unfortunately when I write in a new worksheet the command

with(GraphTheory): with(RandomGraph): G:=RandomGraph(10,25); DrawGraph(G,layout=interactive)

I get the error

"Error, invalid input: GraphTheory:-DrawGraph expects value for keyword parameter [style, layout] to be of type identical(none, bipartite, circle, default, fixed, grid, interactive, network, spectral, spring, spring[constant], tree, user, planar, random), but received plots:-interactive"

Could you help me? Thanks

This is really a math question. But I can't figure how Maple did it.

Maple solves the ODE with 2 initial conditions correctly.

But if I use the general solution, and setup the set 2 equations, and tell Maple to solve _C1 and _C2, it says there is no solutions. Which is correct.

I would really like to know how Maple then managed to solve for these initial conditions.  This is problem from text book

I know how to solve it by hand to obtain general solution. But do not know how find solution that satisfies the IC's. when pluggin the initial conditions, the resulting 2 equation have no solution.


The goal is to now take the general solution found by Maple above, and manually solve for _C1 and _C2:

the_derivative:= diff(rhs(maple_general_sol),x):

Two equations, two unknown. But using solve or PDEtools:-Solve produce no solution.


Looking at equation (1) above, we see that it is the same as 

eq1:=1=(tan(_C2/(2*_C1))^2 + 1)/_C1^2;

Because 0=ln(Z) means Z=1. Using the above simpler equation now gives

eq1:=1=(tan(_C2/(2*_C1))^2 + 1)/_C1^2;
the_derivative:= diff(rhs(maple_general_sol),x):

We see that there is indeed no solution. Second equation above says _C1= tan(.). Let tan(.)=Z. Plugging this in first equation gives Z^2= (Z^1+1) which has no solution for Z since this says 0=1 

So direct appliction of the initial conditions produces no solution. So how did Maple find the solution it obtained? I also tried using limits. But no luck. Book does not show how to obtain solution either. 

Any ideas?


When solving this by hand   sqrt(y)=tanh(x), I would square both sides to obtain  y=tanh(x)^2 as solution.  

Maple does this when RHS is tan,cos,sin, but not when RHS is hyperbolic.

Why is that, and how to best tell Maple to give  the simple solution? Here is an example


Compare to Mathematica:

I can post-process Maple solution like this


Which is tanh(x)^2.  

But this is all too much work, since this is done in a program, and I do not know what specific convert to use at the time to try.

My question is, why does not maple simply solves   sqrt(y) = f(x)  giving     y=f(x)^2?  it works for generic function


it works for non-hyper trig functions also


Is there a trick to make it work for hyperbolic functions also automatically?

ps. for now, to avoid all these issues, I am doing this


Since I know that the RHS contains no y before hand. The above bypasses any issues Maple has with hyper trig functions.


Without any success, I've been trying to hide the input/code, such that only the output (moment and shear) diagram is shown. I've tried guides with Document Blocks method but all seem outdated, since they're referring to commands which don't seem to exist i.e. "collapse document block". I can't understand that there isn't some neat and user-friendly way to something as simple as show/hide the input, to make it more document-reader friendly? It seems the only way is to just hightlight the input and color it white, which isn't too viable long term. 

I hope you can help, it would be alot of help to me and my classmates. 
Kind regards and thanks for your time.


PS. Here's a picture of the input and diagram.

restart, with(plots);
startingTime := 1800;
interval := 10;
P(0) := 5.308;
P(t) = 5.308*M/(5.308 + (M - 5.308)*exp(-kMt));
                                5.308 M           
              P(t) = -----------------------------
                     5.308 + (M - 5.308) exp(-kMt)

diff(P(t), t) = kP(t)*(M - P(t));
                  --- P(t) = kP(t) (M - P(t))

Explore(plot([P(t), [[0, 5.308], () .. (), [140, 131.7]]], t = 0 .. 0.140, P = 0 .. 140, style = [line, point], gridlines = true), parameters = [[M = M_0 .. M_1], [k = k_0 .. k_1]]);
Error, (in Explore) incorrect first argument [P(t), [[0, 5.308], () .. (), [140, 131.7]]]

I am currently trying to solve the following ODE using numerical methods:

diff(U(x), x$2) + [(z+ I*y)2/k12 -k22 + ((z+I*y)/k3)*sech(x)^2U(x)

Where the complex value (in this case, omega, has been written as z+Iy). I believe dsolve has capabilities for solving this as an initial value problem with complex values and thus to solve this as a boundary value problem I aim to use fsolve to find a zero other a function which is the (IVP solution) - (the non-initial boundary). This has worked very well for the case where y=0 however does not work for values of y>0, and it seems the problem is with fsolve. Any advice on how to deal with this problem, perhaps alternatives to fsolve? 

Is there any possibility to modify column width within tables, so that they become equal?

Dear Users! 

I want to evaluate following integral (f[i]'s) for different values of rho as shown. But find some problem and can't find f[3], f[4], f[5] and f[6]. If the integral from direct way is hard to calculate please guide me how I can evaluate it using numerical integration?

restart; HAM := [1, 2, 3, 4, 5, 6]; U := y^6*sin(x); alpha := 1/3;

for i while i <= nops(HAM) do

rho := op(i, HAM);

f[i] := int(int(U/((x^rho-p^rho)^alpha*(y^rho-q^rho)^alpha), q = 0 .. y), p = 0 .. x)

end do

Thanks in advance!

Special request to @acer @Carl Love @Kitonum @Preben Alsholm


I want to simulate a decision rule (let's say a production control strategy to fix the ideas) based on the outcomes of a binomial random variable.

One stage of this simulation involves operations which correspond to the NaiveProc described below. This procedure is a straightforward and rather naive translation in Maple of these operations.
It is given here to help you to understand what is to be done.

This coding being extremely slow, I implemented the required operations differently.
Given the fact that I'm only concerned by binomial samplings with outcomes 0 and 1, I basically replaced these samplings by three operations  U:=... , Got01:=... , Got0:= ... .
Each new implementation is about 200 times faster than the naive one.

My question is: Can we do still better?
For information the same simulation realized with R runs in less than 15s when REP = 10^8 (more than 100 times faster than what I'm capable to do with Maple)

Thanks for your help.




# This is the naive coding of the problem
# It has the advantage to explain clearly (at least I hope so) what is to be done.

NaiveProc := proc(REP, a, b, N)
  local roll, rep, p, K, N0, N1:
  roll := rand(a .. b);
  N0   := 0:
  N1   := 0:
  for rep from 1 to REP do
    p := roll();
    K := Sample(Binomial(N, p), 1)[1]:
    if K=0 then
      N0 := N0+1:
    elif K=1 then
      N1 := N1+1:
    end if:
  end do:
  N0, N1:
end proc:
CodeTools:-Usage(NaiveProc(10^3, 0, 5e-4, 25000));

memory used=78.92MiB, alloc change=68.00MiB, cpu time=1.21s, real time=6.30s, gc time=24.80ms


93, 80


# As the previous code is very slow I implemented several variants based on the fact
# that I care only on values of K equal to 0 and 1 and that it is then useless to sample
# a Binomial random variable to do this.
# Each of them is much faster than the naive coding... but can we even faster?
# For comparison, the same simulation realized in R takes less than 15s to run with REP=10^8

pi := (n, p, k) -> binomial(n, k) * (1-p)^(n-k) * p^k;

f1 := proc(REP, a, b, N)
  local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:
  Q     := Sample(Uniform(a, b), REP)^+:
  P0    := pi~(N, Q, 0):
  P1    := pi~(N, Q, 1):
  P01   := P0 + P1:
  U     := Sample(Uniform(0, 1), REP)^+:
  Got01 := Select(t -> is(t <= 0), U-P01):
  Got0  := Select(t -> is(t <= 0), U-P0 );
  N01   := numelems(Got01):
  N0    := numelems(Got0):
  N1    := N01-N0:
  N0, N1;
end proc:

CodeTools:-Usage(f1(10^5, 0, 5e-4, 25000));


f2 := proc(REP, a, b, N)
  local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:
  Q     := Sample(Uniform(a, b), REP)^+:
  P0    := pi~(N, Q, 0):
  P1    := pi~(N, Q, 1):
  P01   := P0 + P1:
  U     := Sample(Uniform(0, 1), REP)^+:
  Got01 := select[flatten](`<=`, U-P01, 0):
  Got0  := select[flatten](`<=`, U-P0 , 0):
  N01   := numelems(Got01):
  N0    := numelems(Got0):
  N1    := N01-N0:
  N0, N1;
end proc:

CodeTools:-Usage(f2(10^5, 0, 5e-4, 25000));


f3 := proc(REP, a, b, N)
  local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:
  Q     := Sample(Uniform(a, b), REP)^+:
  P0    := pi~(N, Q, 0):
  P1    := pi~(N, Q, 1):
  P01   := P0 + P1:
  U     := Sample(Uniform(0, 1), REP)^+:
  Got01 := Vector(REP, i -> `if`(U[i] <= P01[i], 1, 0)):
  Got0  := Vector(REP, i -> `if`(U[i] <= P0 [i], 1, 0)):
  N01   := add(Got01):
  N0    := add(Got0):
  N1    := N01-N0:
  N0, N1;
end proc:

CodeTools:-Usage(f3(10^5, 0, 5e-4, 25000));

proc (n, p, k) options operator, arrow; binomial(n, k)*(1-p)^(n-k)*p^k end proc


memory used=376.83MiB, alloc change=296.77MiB, cpu time=4.12s, real time=4.03s, gc time=430.38ms


8118, 7979



memory used=173.26MiB, alloc change=0 bytes, cpu time=2.30s, real time=1.98s, gc time=461.22ms


7993, 7793



memory used=154.19MiB, alloc change=0 bytes, cpu time=2.28s, real time=2.01s, gc time=432.40ms


7989, 7869






When Maple converts a matrix or a vector to Latex it uses latex array, which  is fine, but what it does is insert an exatra \\ at the end of the last row, just before the \end{array} 

This causes problem for some software which reads the latex file. It causes the software to take this as empty row and inserts a blank row at the end.

Here is a small example


              \left[\begin{array}{cc}1 & 2 \\3 & 4 \\\end{array}\right]

Notice the extra \\  just before the \end{array} In Latex, this tells latex compiler to insert newline basically.

When opening the latex file using external software, which reads Latex and converts it to GUI, it show this

And now I have to go edit the latex by hand removing the extra \\ (inside the editor I can do global search and replace)

A better outout from Maple's Latex command would be the following

\left[\begin{array}{cc}1 & 2 \\3 & 4 \end{array}\right]

Even though both are valid Latex, the above is better.  I was wondering how hard it is to do this change.

All what the conversion needs to do is just check if the row in the matrix (or Vector) is the last one, and omit the extra \\ at the end of the last row. That is all. 

I could ofcourse write code to try to parse this each time I call Latex and to remove \\ myself in the program, but it will be much easier if Maple automatically did this.


ps. if the Latex conversion source code could be made public, others could help make improvement to it for free, benefiting Maple and everyone using it. Maplesoft would still approve the changes before checkin, and retain the copy right of the source code ofcourse. 


Maple 2020.1


One of the known issues with Maple GUI (written in Java) is that it is slow.

When I run a long script, which prints few lines to the screen for each step (to help tell where it is during a long run), and if there are 20,000 steps to run which takes 2 days to finish), then the worksheet and I think all of Maple seem to slow down. May be due to GUI trying to flush output to worksheet which now has lots of output. 

I noticed when I terminate the loop in the middle and then clear the worksheet from the output and start it again from where it stopped, then it runs/scrolls much faster initially untill the worksheet starts to fill up. 

The problem is that one can no longer do Evaluate->Remove output from worksheet as worksheet is busy. This option becomes grayed out.

Is there a trick to bypass this limitation? It will be really nice to be able to clear output from worksheet while it is running.  I do not understand why a user can not do this now even if worksheet is running. In Mathematica for example, this is possible to clear the output while notebook is busy running. Not in Maple.

ps. I want to try to change my program to print output to external file instead to the worksheet and then can monitor the output progress using that file outside of Maple to see if this helps with performance.

This is until Maplesoft adds support to allow one to clear worksheet while it is busy.

Using Maple 2020.1 on windows. Using worksheet mode, not document mode.

Hello again,   I'm trying to write a procedure to multiply quaternions.   We know that they can be represented as a vector of length 4.   See Wikipedia.   My try  -

qaa=[8,4,6,2] and qab =[2,,4,6,8]

end proc;

maybe needs some looping or data from a table.  



Hello All, is there a command/instruction that can tell me the phase margin, gain margin automatically after I have a bode plot, please?

Units are a neverending story, here's a variant of a problem raised before.

How can i get the minimum of 2 values with Units[Standard] loaded, when one of them could be zero (this loosing its units)?

See also 



a := 15*Unit('m')



b := 13000*Unit('mm')



min(a, b)



c := 0*Unit('m')



min(a, c)

Error, (in Units:-Standard:-min) units with incompatible dimensions found: {1, length}







M__h := 0.352e-1;







































pdes := [diff(B(t, x), t) = M__h-beta__1*B(t, x)*G(t, x)/N__h+beta__2*B(t, x)*G(t, x)/N__h-mu__h*B(t, x)+sigma__h*E(t, x)*(diff(B(t, x), x, x)), diff(C(t, x), t) = beta__1*B(t, x)*G(t, x)/N__h-u[1]*C(t, x)/(1+C(t, x))-mu__h*C(t, x)*(diff(C(t, x), x, x)), diff(DD(t, x), t) = beta__2*DD(t, x)*G(t, x)/N__h-u[1]*DD(t, x)/(1+DD(t, x))-mu__h*DD(t, x)-delta__1*DD(t, x)*(diff(DD(t, x), x, x)), diff(E(t, x), t) = u[1]*C(t, x)/(1+C(t, x))+u[1]*DD(t, x)/(1+DD(t, x))-(mu__h+sigma__h)*E(t, x)*(diff(E(t, x), x, x)), diff(F(t, x), t) = M__b-beta__3*F(t, x)*C(t, x)/N__b+beta__4*F(t, x)*DD(t, x)/N__b-mu__b*F(t, x)*(diff(F(t, x), x, x)), diff(G(t, x), t) = beta__3*F(t, x)*C(t, x)/N__b+beta__4*F(t, x)*DD(t, x)/N__b-mu__b*G(t, x)*(diff(G(t, x), x, x))];

[diff(B(t, x), t) = 0.352e-1-0.891056911e-1*B(t, x)*G(t, x)-0.96e-2*B(t, x)+0.8910e-1*E(t, x)*(diff(diff(B(t, x), x), x)), diff(C(t, x), t) = .6791869919*B(t, x)*G(t, x)-0.45e-1*C(t, x)/(1+C(t, x))-0.96e-2*C(t, x)*(diff(diff(C(t, x), x), x)), diff(DD(t, x), t) = .5900813008*DD(t, x)*G(t, x)-0.45e-1*DD(t, x)/(1+DD(t, x))-0.96e-2*DD(t, x)-0.235e-1*DD(t, x)*(diff(diff(DD(t, x), x), x)), diff(E(t, x), t) = 0.45e-1*C(t, x)/(1+C(t, x))+0.45e-1*DD(t, x)/(1+DD(t, x))-0.9870e-1*E(t, x)*(diff(diff(E(t, x), x), x)), diff(F(t, x), t) = .7214-.1739837398*F(t, x)*C(t, x)+.1780487805*F(t, x)*DD(t, x)-1.354*F(t, x)*(diff(diff(F(t, x), x), x)), diff(G(t, x), t) = .1739837398*F(t, x)*C(t, x)+.1780487805*F(t, x)*DD(t, x)-1.354*G(t, x)*(diff(diff(G(t, x), x), x))]


bcs := [(D[2](B))(t, 0) = 0, (D[2](B))(t, 1) = 0, (D[2](C))(t, 0) = 0, (D[2](C))(t, 1) = 0, (D[2](DD))(t, 0) = 0, (D[2](DD))(t, 1) = 0, (D[2](E))(t, 0) = 0, (D[2](E))(t, 1) = 0, (D[2](F))(t, 0) = 0, (D[2](F))(t, 1) = 0, (D[2](G))(t, 0) = 0, (D[2](G))(t, 1) = 0, B(0, x) = 100, C(0, x) = 70, DD(0, x) = 50, E(0, x) = 70, F(0, x) = 100, G(0, x) = 70]

[(D[2](B))(t, 0) = 0, (D[2](B))(t, 1) = 0, (D[2](C))(t, 0) = 0, (D[2](C))(t, 1) = 0, (D[2](DD))(t, 0) = 0, (D[2](DD))(t, 1) = 0, (D[2](E))(t, 0) = 0, (D[2](E))(t, 1) = 0, (D[2](F))(t, 0) = 0, (D[2](F))(t, 1) = 0, (D[2](G))(t, 0) = 0, (D[2](G))(t, 1) = 0, B(0, x) = .100, C(0, x) = .70, DD(0, x) = .50, E(0, x) = .70, F(0, x) = .100, G(0, x) = .70]


sol := pdsolve(pdes, bcs, numeric);

module () local INFO; export plot, plot3d, animate, value, settings; option `Copyright (c) 2001 by Waterloo Maple Inc. All rights reserved.`; end module


sol:-plot3d([B(t, x), C(t, x)], t = 0 .. 20, x = 0 .. 20)

Error, (in pdsolve/numeric/plot3d) unable to compute solution for t>HFloat(0.25):
Newton iteration is not converging





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