Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I cant get the error. Any one can help me?

r := 0.5e-2; k := 10000; a := .4; alpha := .25; epsilon := 0.2e-1; mu := 0.4e-1; delta := 0.3e-2; Lambda := 0.2e-1;
beta[2] := .45; beta[1] := .2; c[1] := 2; c[2] := 5; w[1] := 10; w[2] := 30; T := 3;
u[1] := min(max(0, z), 1); z := beta[2]*s(t)*i(t)*(lambda[2](t)-lambda[1](t))/(w[1]*(s(t)+i(t)+e(t))); u[2] := min(max(0, c), 1); c := (beta[1]*s(t)*p(t).(lambda[2](t)-lambda[1](t)))/(w[2]*(a+p(t)))+(lambda[2](t).e(t)+(i(t)+alpha.e(t)).lambda[3](t)-(gamma.i(t)+p(t)).lambda[4](t))/w[2]; 

sys := diff(s(t), t) = r*s(t)*(1-(s(t)+i(t)+e(t))/k)-beta[1]*s(t)*p(t)*(1-u[2])/(a+p(t))-beta[2]*s(t)*i(t)*(1-u[1])/(s(t)+i(t)+e(t)), diff(e(t), t) = beta[1]*s(t)*p(t)*(1-u[2])/(a+p(t))+beta[2]*s(t)*i(t)*(1-u[1])/(s(t)+i(t)+e(t))-(mu+alpha+u[2])*e(t), diff(i(t), t) = (alpha+u[2]).e(t)-(mu+epsilon+u[2])*i(t), diff(p(t), t) = Lambda+(epsilon+u[2]).i(t)-delta*p(t), diff(lambda[1](t), t) = -lambda[1](t)*(r*(1-(2*s(t)+i(t)+e(t))/k)-beta[1]*p(t)*(1-u[2])/(a+p(t))-beta[2]*i(t)*(1-u[1])/(s(t)+i(t)+e(t)))-lambda[2](t).(beta[1]*p(t)*(1-u[2])/(a+p(t))-beta[2]*i(t)*(1-u[1])/(s(t)+i(t)+e(t))), diff(lambda[2](t), t) = -c[1]+lambda[1](t)*r*s(t)/k+lambda[2](t)*(mu+alpha+u[2])-(1-u[2]).alpha.lambda[3](t), diff(lambda[3](t), t) = -c[2]+lambda[1](t).(r*s(t)/k+beta[2]*s(t)*(1-u[1])/(s(t)+i(t)+e(t)))-lambda[2](t)*beta[2]*s(t)*(1-u[1])/(s(t)+i(t)+e(t))+lambda[3](t)*(u[2]+mu+gamma)-lambda[4](t).gamma.(1-u[2]), diff(lambda[4](t), t) = ((lambda[1](t).beta[1])*s(t).a.(1-u[2]))/(a+p(t))^2-((lambda[2](t).beta[1])*s(t).a.(1-u[2]))/(a+p(t))^2-lambda[4](t)*(delta+u[2]), s(0) = 1000, e(0) = 10, i(0) = 0, p(0) = 100, lambda[1](T) = 0, lambda[2](T) = 0, lambda[3](T) = 0, lambda[4](T);
p1 := dsolve({sys}, type = numeric, abserr = 0.1e-3, maxmesh = 2400);
Error, (in fproc) unable to store '-1.*HFloat(0.0)[1]' when datatype=float[8]
p2o := odeplot(p1, [t, i(t)], 0 .. 2, numpoints = 100, labels = ["Time (months)", " infectious "*`Maize"`], labeldirections = [horizontal, vertical], style = line, color = red, axes = boxed);
Error, (in plots/odeplot) input is not a valid dsolve/numeric solution

Example of Duffing equation with boundary conditions.
y'' + 0.2y' + y^3 - 0.3cos(s) = 0;
y(0) = y (2Pi);
y'(0) = y'(2Pi);
For convenience, we replace the original equation with a system of two first order equations:
x1'(t) = 2*Pi*x2(t);
x2'(t) = - 0.4*Pi*x2(t) - 2*Pi*x1(t)^3 +0.6*Pi*cos(2*Pi*t);
x1(0) = x1(1);
x2(0) = x2(1);
I have long wanted to apply an optimization package to solve a boundary value problem for ODE. The decision helped procedure for solving ODE, written by forum member vv.
It seems to me that two solutions have been found and that the solutions are weakly sensitive to the initial approximations. These are two closed trajectories. For example, these are points that belong to these solutions:
(0.5966963,  1.0482816) , ( - 0.3132584, 0.0664941).
I am wondering: are the solutions right, and how justified is the use of optimization methods for such tasks?
At the end of the program, the solution is checked on the original Duffing equation using standard Maple functions.

(In the figures, the trajectory bypass occurs three times.)

For some reason when I do n mod 2, it spits out n. Im trying to figure out what is wrong. I have to evaluate at two points in order for this to work.




Last year, I read a fascinating paper that presented evidence of an exoplanet, inferred through the “wobble” (or radial velocity) of the star it orbits, HD 3651. A periodogram of the radial velocity revealed the orbital period of the exoplanet – about 62.2 days.

I found the experimental data and attempted to reproduce the periodogram. However, the data was irregularly sampled, as is most astronomical data. This meant I couldn’t use the standard Fourier-based tools from the signal processing package.

I started hunting for the techniques used in the spectral analysis of irregularly sampled data, and found that the Lomb Scargle approach was often used for astronomical data. I threw together some simple prototype code and successfully reproduced the periodogram in the paper.


After some (not so) gentle prodding, Erik Postma’s team wrote their own, far faster and far more robust, implementation.

This new functionality makes its debut in Maple 2019.

From a simple germ of an idea, to a finished, robust, fully documented product that we can put in front of our users – that, for me, is incredibly satisfying.

That’s a minor story about a niche I’m interested in, but these stories are repeated time and time again.  Ideas spring from users and from those that work at Maplesoft. They’re filtered to a manageable set that we can work on. Some projects reach completion in under a year, while other, more ambitious, projects take longer.

The result is software developed by passionate people invested in their work, and used by passionate people in universities, industry and at home.

We always pack a lot into each release. Maple 2019 contains improvements for the most commonly used Maple functions that nearly everyone uses – such as solve, simplify and int – as well features that target specific groups (such as those that share my interest in signal processing!)

I’d like to to highlight a few new of the new features that I find particularly impressive, or have just caught my eye because they’re cool.

Of course, this is only a small selection of the shiny new stuff – everything is described in detail on the Maplesoft website.

Edgardo, research fellow at Maplesoft, recently sent me a recent independent comparison of Maple’s PDE solver versus those in Mathematica (in case you’re not aware, he’s the senior developer for that function). He was excited – this test suite demonstrated that Maple was far ahead of its closest competitor, both in the number of PDEs solved, and the time taken to return those solutions.

He’s spent another release cycle working on pdsolve – it’s now more powerful than before. Here’s a PDE that Maple now successfully solves.

Maplesoft tracks visits to our online help pages - simplify is well-inside the top-ten most visited pages. It’s one of those core functions that nearly everyone uses.

For this release, R&D has made many improvements to simplify. For example, Maple 2019 better simplifies expressions that contain powers, exponentials and trig functions.

Everyone who touches Maple uses the same programming language. You could be an engineer that’s batch processing some data, or a mathematical researcher prototyping a new algorithm – everyone codes in the same language.

Maple now supports C-style increment, decrement, and assignment operators, giving you more concise code.

We’ve made a number of improvements to the interface, including a redesigned start page. My favorite is the display of large data structures (or rtables).

You now see the header (that is, the top-left) of the data structure.

For an audio file, you see useful information about its contents.

I enjoy creating new and different types of visualizations using Maple's sandbox of flexible plots and plotting primitives.

Here’s a new feature that I’ll use regularly: given a name (and optionally a modifier), polygonbyname draws a variety of shapes.

In other breaking news, I now know what a Reuleaux hexagon looks like.

Since I can’t resist talking about another signal processing feature, FindPeakPoints locates the local peaks or valleys of a 1D data set. Several options let you filter out spurious peaks or valleys

I’ve used this new function to find the fundamental frequencies and harmonics of a violin note from its periodogram.

Speaking of passionate developers who are devoted to their work, Edgardo has written a new e-book that teaches you how to use tensor computations using Physics. You get this e-book when you install Maple 2019.

The new LeastTrimmedSquares command fits data to an equation while not being signficantly influenced by outliers.

In this example, we:

  • Artifically generate a noisy data set with a few outliers, but with the underlying trend Y =5 X + 50
  • Fit straight lines using CurveFitting:-LeastSquares and Statistics:-LeastTrimmedSquares

LeastTrimmedSquares function correctly predicts the underlying trend.

We try to make every release faster and more efficient. We sometimes target key changes in the core infrastructure that benefit all users (such as the parallel garbage collector in Maple 17). Other times, we focus on specific functions.

For this release, I’m particularly impressed by this improved benchmark for factor, in which we’re factoring a sparse multivariate polynomial.

On my laptop, Maple 2018 takes 4.2 seconds to compute and consumes 0.92 GiB of memory.

Maple 2019 takes a mere 0.27 seconds, and only needs 45 MiB of memory!

I’m a visualization nut, and I always get a vicarious thrill when I see a shiny new plot, or a well-presented application.

I was immediately drawn to this new Maple 2019 app – it illustrates the transition between day and night on a world map. You can even change the projection used to generate the map. Shiny!


So that’s my pick of the top new features in Maple 2019. Everyone here at Maplesoft would love to hear your comments!


I have a problem in the solution of this system of ODEs:

de[1] := M*(diff(x(t), t, t))+sum(FxjR, j = 1 .. m)+sum(FxjL, j = 1 .. m) = M*g+Us*omIn^2*cos(omIn*t); ini[1] := x(10^(-6)) = 1.00013081730872*10^(-6); ini[2] := (D(x))(10^(-6)) = 0.261632327671976e-3;

de[2] := M*(diff(y(t), t, t))+sum(FyjR, j = 1 .. m)+sum(FyjL, j = 1 .. m) = Us*omIn^2*sin(omIn*t); ini[3] := y(10^(-6)) = 9.99989124246935*10^(-8); ini[4] := (D(y))(10^(-6)) = -2.50318090194868*10^(-6);

de[3] := M*(diff(z(t), t, t))+sum(FzjR, j = 1 .. m)+sum(FzjL, j = 1 .. m) = 0; ini[5] := z(10^(-6)) = 9.99065455347471*10^(-9); ini[6] := (D(z))(10^(-6)) = -0.186933812655399e-4;

de[4] := Ix*(diff(thx(t), t, t))+Iz*(diff(thy(t), t))*omIn+sum(MxjL, j = 1 .. m)-sum(MxjR, j = 1 .. m) = 0; ini[7] := thx(10^(-6)) = 8.60546055625759*10^(-7); ini[8] := (D(thx))(10^(-6)) = 1.72109307183424;

de[5] := Iy*(diff(thy(t), t, t))-Iz*(diff(thx(t), t))*omIn+sum(MyjL, j = 1 .. m)-sum(MyjR, j = 1 .. m) = 0; ini[9] := thy(10^(-6)) = 1.02142988540396*10^(-10); ini[10] := (D(thy))(10^(-6)) = 0.285764338010142e-3;

sys_ode := seq(de[n], n = 1 .. 5);
ICs := seq(ini[n], n = 1 .. 10);
F := dsolve([sys_ode, ICs], type = numeric, range = 10^(-6) .. 0.1);

Then I found this response:

Warning, cannot evaluate the solution further right of .10473416e-4, probably a singularity
F:=proc(x_rkf45) ... end proc


The details of the parameters inside the SUMMATION sign are very complicated and it is useless to mention them (in my point of view). Each one of (FxjR) and its similars is more than 20 Word pages, so it is useless to mention, but I can confirm that all of them include the (time and the 5 variables of ODE and their first derivatives only).

How can I solve that?
Any ideas to get rid of this singularity problem?

I am thinking of using a fixed step method, but I do not know if this will solve the problem? Also, I do not know how can I use a fixed step and what are the methods that use fixed step in maple?

Your participations are greatly appreciated! 





I am trying to write a code to calculate, for a given prime p the string length k of the repunit

R_k=1111111....1111 (with k 1s) such that the number R_kpR_k is prime.  

Example: If p=59, then k=42 is the smallest k such that R_k59R_k is prime. Note that for some primes it can be shown that no such k exists (2,11,37,101..)

I can usually figure out from the factor cycle of a “repunit wrapped” prime whether such a k exists or not. But if the indications are that a k does exist then finding it is very time consuming. Eg for p =71, 167. 


What i want to do, for given p is set an upper limit N for k then check to see if R_kpR_k is prime for values of k from 1 to N

The bit I can’t handle is expressing the “wrapped” number for a given p and k, and also indexing from k to k+1, until N is reached or a prime found.

Any assistance gratefully received.

Best regards







If worksheet execution was started and computer is locked before execution ends, Maple will stop responding and all work is lost. Execution of whole worksheet takes very long time, sometimes over 3 hours, so "do not lock computer during execution" is not solving the problem.

Dear All,
Perhaps my question is basic question, but I want to know more about LPSolve
Is it possible to join 2 solutions from different LPSolve?

For example, I have 2 solutions,
Sol[1] := [72.011122301, [t[4] = -.500000000000000, t[13] = .500000000000000, x[1, 4] = 1, x[1, 13] = 0, x[4, 1] = 0, x[4, 13] = 1, x[13, 1] = 1, x[13, 4] = 0]];
Sol[2] := [53.128387340, [t[6] = -2.00000000000000, t[7] = 0., t[8] = -.999999999999999, x[1, 6] = 1, x[1, 7] = 0, x[1, 8] = 0, x[6, 1] = 0, x[6, 7] = 0, x[6, 8] = 1, x[7, 1] = 1, x[7, 6] = 0, x[7, 8] = 0, x[8, 1] = 0, x[8, 6] = 0, x[8, 7] = 1]].

What I want to achieve is following:

(1) eliminating t variable and join those solution (all values of x). Thus, I got [ x[1, 4] = 1, x[1, 13] = 0, x[4, 1] = 0, x[4, 13] = 1, x[13, 1] = 1, x[13, 4] = 0,x[1, 6] = 1, x[1, 7] = 0, x[1, 8] = 0, x[6, 1] = 0, x[6, 7] = 0, x[6, 8] = 1, x[7, 1] = 1, x[7, 6] = 0, x[7, 8] = 0, x[8, 1] = 0, x[8, 6] = 0, x[8, 7] = 1]].
(2) Extracting the value of X. I know that sol[1][2] indicates the values of right hand side. But I want to get the value of each of x in sequence.
for example: I can get x[1,2]=1, x[1,8]=0, x[7,1]=0 and so on.
In this case, Maybe I can use
eval(x[1,8],sol[1]) for specific x.
But is there any nice way to get all values of x with some procedures?

Thanks for reading


What are the most efficient way to write and evaluate a procedure in maple? Thank you.

Dear sir,

I am using the Maple to solve pde equations but I am not getting analytical solutions for some of the equations. Can you please help me on how to solve one of the pde, like as I have 

(sin(theta)^2*(diff(a(r, theta), r, r))+cos(theta)^2*(diff(a(r, theta), r))/r-sin(2*theta)*(diff(a(r, theta), theta))/r^2+sin(2*theta)*(diff(a(r, theta), theta, r))/r+cos(theta)^2*(diff(a(r, theta), theta, theta))/r^2)*`α__d`^2+cos(theta)^2*(diff(a(r, theta), r, r))+sin(theta)^2*(diff(a(r, theta), r))/r+sin(2*theta)*(diff(a(r, theta), theta))/r^2-sin(2*theta)*(diff(a(r, theta), theta, r))/r+sin(theta)^2*(diff(a(r, theta), theta, theta))/r^2 = 0

this equation is in polar corrdinates, this is analogous to diff(a(x, y), x, x)+`α__d`^2*(diff(a(x, y), y, y)) = 0


in cartesian coordinates

Duo:=proc(a)  #a nombre congruent connu
local u,v,n,m,k,t:
for m to t do
  for n to m do
    if (igcd(m,n)=1 and m>n) then
      k:=op(2,sqrt(v-u))^2: # k nombre congruent réduit
        if k=a then return (m,n): break 
        elif n=t then break fi:

                              3, 2
                             26, 23
                              2, 1
u, v, w sont des carrés en progression arithmétique dont la raison est un nombre congruent
Procédure permettant de trouver un triplet pythagoricien primitif correspondant au nombre congruent a connu
TriPy:=proc(m,n)# triangles pythagoriciens
local a,a1,b1,c1,d,k,q,u,v,w:
 if (igcd(m,n)=1 and m>n) then
 a:=(op(2,sqrt(v-u)))^2:#nombre congruent réduit
 q:=sqrt((v-u)/a)/2:#rapport de réduction
                              17  145
                          24, --, ---
                              6    6 

                          156  5  313
                          ---, -, ---
                           5   2  10 

                         444  35  1513
                         ---, --, ----
                         35   2    70 
                         1196      1205
                         ----, 21, ----
                          7         7  
TriPy(Duo(23));don't work, "part dans les choux"

Hi, how can you in maple take the derivitve of a function that consists of sum terms in it? (preferable in document mode)

For example I have this expression (from a math book):

f = N+k*(sum(ln(x__i-B), i = 1 .. N))-N*k*(sum((x__i-B)^k*ln(x__i-B), i = 1 .. N))/(sum((x__i-B)^k, i = 1 .. N))

What I then want to do is to derive this function with respect to k.
However just writing the expression like above it seems like mable doesn't keep the summation terms but evaluates them in a sense. So not sure how to set it up correctly in order to make the derivitive.

Taking the derivitive of f with respect to k, the solution should give something like this:



How  I can use from equations 1-6 and repleacing them into equation 7 to remove qx,qy,qz?

Thank you

A := q__x(x, y, z, t)+`τ__q`*(diff(q__x(x, y, z, t), t))+(1/2)*`τ__q`^2*(diff(q__x(x, y, z, t), t, t)) = -k*(diff(T(x, y, z, t), x))-k*`τ__T`*(diff(T(x, y, z, t), x, t))-(1/2)*k*`τ__T`^2*(diff(T(x, y, z, t), x, t, t))

q__x(x, y, z, t)+tau__q*(diff(q__x(x, y, z, t), t))+(1/2)*tau__q^2*(diff(diff(q__x(x, y, z, t), t), t)) = -k*(diff(T(x, y, z, t), x))-k*tau__T*(diff(diff(T(x, y, z, t), t), x))-(1/2)*k*tau__T^2*(diff(diff(diff(T(x, y, z, t), t), t), x))


A__x := diff(A, x)

diff(q__x(x, y, z, t), x)+tau__q*(diff(diff(q__x(x, y, z, t), t), x))+(1/2)*tau__q^2*(diff(diff(diff(q__x(x, y, z, t), t), t), x)) = -k*(diff(diff(T(x, y, z, t), x), x))-k*tau__T*(diff(diff(diff(T(x, y, z, t), t), x), x))-(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), x), x))



B := q__y(x, y, z, t)+`τ__q`*(diff(q__y(x, y, z, t), t))+(1/2)*`τ__q`^2*(diff(q__y(x, y, z, t), t, t)) = -k*(diff(T(x, y, z, t), y))-k*`τ__T`*(diff(T(x, y, z, t), y, t))-(1/2)*k*`τ__T`^2*(diff(T(x, y, z, t), y, t, t))

q__y(x, y, z, t)+tau__q*(diff(q__y(x, y, z, t), t))+(1/2)*tau__q^2*(diff(diff(q__y(x, y, z, t), t), t)) = -k*(diff(T(x, y, z, t), y))-k*tau__T*(diff(diff(T(x, y, z, t), t), y))-(1/2)*k*tau__T^2*(diff(diff(diff(T(x, y, z, t), t), t), y))


B__y := diff(B, y)

diff(q__y(x, y, z, t), y)+tau__q*(diff(diff(q__y(x, y, z, t), t), y))+(1/2)*tau__q^2*(diff(diff(diff(q__y(x, y, z, t), t), t), y)) = -k*(diff(diff(T(x, y, z, t), y), y))-k*tau__T*(diff(diff(diff(T(x, y, z, t), t), y), y))-(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), y), y))



C := q__z(x, y, z, t)+`τ__q`*(diff(q__z(x, y, z, t), t))+(1/2)*`τ__q`^2*(diff(q__z(x, y, z, t), t, t)) = -k*(diff(T(x, y, z, t), z))-k*`τ__T`*(diff(T(x, y, z, t), z, t))-(1/2)*k*`τ__T`^2*(diff(T(x, y, z, t), z, t, t))

q__z(x, y, z, t)+tau__q*(diff(q__z(x, y, z, t), t))+(1/2)*tau__q^2*(diff(diff(q__z(x, y, z, t), t), t)) = -k*(diff(T(x, y, z, t), z))-k*tau__T*(diff(diff(T(x, y, z, t), t), z))-(1/2)*k*tau__T^2*(diff(diff(diff(T(x, y, z, t), t), t), z))


C__z := diff(C, z)

diff(q__z(x, y, z, t), z)+tau__q*(diff(diff(q__z(x, y, z, t), t), z))+(1/2)*tau__q^2*(diff(diff(diff(q__z(x, y, z, t), t), t), z)) = -k*(diff(diff(T(x, y, z, t), z), z))-k*tau__T*(diff(diff(diff(T(x, y, z, t), t), z), z))-(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), z), z))



expand(simplify(-A__x-B__y-C__z+Q = rho*c__p*(diff(T(x, y, z, t), t))))

(-(diff(q__x(x, y, z, t), x))-tau__q*(diff(diff(q__x(x, y, z, t), t), x))-(1/2)*tau__q^2*(diff(diff(diff(q__x(x, y, z, t), t), t), x))-(diff(q__y(x, y, z, t), y))-tau__q*(diff(diff(q__y(x, y, z, t), t), y))-(1/2)*tau__q^2*(diff(diff(diff(q__y(x, y, z, t), t), t), y))-(diff(q__z(x, y, z, t), z))-tau__q*(diff(diff(q__z(x, y, z, t), t), z))-(1/2)*tau__q^2*(diff(diff(diff(q__z(x, y, z, t), t), t), z))+Q = k*(diff(diff(T(x, y, z, t), x), x))+k*tau__T*(diff(diff(diff(T(x, y, z, t), t), x), x))+(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), x), x))+k*(diff(diff(T(x, y, z, t), y), y))+k*tau__T*(diff(diff(diff(T(x, y, z, t), t), y), y))+(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), y), y))+k*(diff(diff(T(x, y, z, t), z), z))+k*tau__T*(diff(diff(diff(T(x, y, z, t), t), z), z))+(1/2)*k*tau__T^2*(diff(diff(diff(diff(T(x, y, z, t), t), t), z), z))+Q) = rho*c__p*(diff(T(x, y, z, t), t))







for x to 10 do Disp[x] := plot([x+cos(a), sin(a), a = 0 .. 2*Pi], colorscheme = ["Red", "Green"]) end do;

display(seq(Disp[i], i = 1 .. x-1), insequence = true, scaling = constrained);

What coding in the color or colorscheme parameter in the plot command above would rotate the circle's colors in conjunction with the circle's movement along the x axis to give the appearance of a rolling wheel? 

I am submitting a maple job written in vim editor through windows 10 command line. but no result is obtained.I found maple gui version hang most of the time. So i decided to submit through command line by writing codes using an editor. Thank you

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