Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Hi everyone,

i want to to skip some code lines if a certain condition is/isn't given. I would prefer using a if..then expression. Is this possible.

Thanks for your help in advance.


As is well known, a number n is a Charmichael number if and only if for every prime factor p of n, p-1 divides n-1. 

I would like to find a way to identify the following: Odd square free composite numbers n, having at least one prime factor p, with the property that p-1 divides n-1.

obviously the Carmichael numbers are a sub sequence of this. I have already managed to write a code to identify odd square free numbers divisible by the sum of their prime divisors and am interested to see how these data will differ from those of  this new sequence. 

My problem here is to find, given an odd square free number, a way to select and test each prime divisor for the above divisibility requirement. I hope someone can help, thanks in advance

Best regards

David Sycamore.


I would like to combine and output different text modules that are saved in variables as strings but cannot get rid off the brackets and quotation marks

use DocumentTools in
textTwo:="How are you?";
SetProperty(Label0, caption,[textOne, textTwo]);
end use;

I alway get  ["Hello", "How are you?"] istead of Hello How are you?

If i remove the brackets [ ] after caption, the output is fine but only the first element appears. Hello

If I try the printf command, which apparently should remove the marks, the label won't output anything at all.

use DocumentTools in
textTwo:="How are you?";
SetProperty(Label0, caption,[printf(textOne), printf(textTwo)]);

end use;

How ist it done? Help would be much appreciated.

Thanks a lot!

Regards, Ben

I am working on a physics problem where I will need to generate random unitaries of size N x N.   

As I understand it this would require me to sample uniformly from U(N), where 'uniform' is in the sense of the Haar measure.  I believe this construction in Mathematica is called 'circular unitary ensemble' and was wondering if there was a similar routine in Maple or some simple code that would allow me to generate random unitaries of particular size.


I have the following two equations:


x = f+t-(8*(-2.28*t+.64*f))/(2.28+2*(-t+.64*f)^2+2.56*t^2);


How can I plot the contours of u in the x-t plane (with its elevation value labelled in the line of each contour)?


Thank you a lot for your help!


As in title: How can I generate random numbers sampled from, say, the logarithmic distribution (with a given value of the parameter)?

Thank you very much.

Anyone can help me to convert the following maple solution expressed by the hypergeom function to the LegendreP(n,b,x) or Q function?




infolevel[pdsolve] := 3:

sol[1] := dsolve((1-x^2)*(diff(y(x), x, x))+n(n+1)*y(x) = 0)

y(x) = _C1*(-1+x^2)*hypergeom([3/4+(1/4)*(4*n(n+1)+1)^(1/2), 3/4-(1/4)*(4*n(n+1)+1)^(1/2)], [1/2], x^2)+_C2*(x^3-x)*hypergeom([5/4+(1/4)*(4*n(n+1)+1)^(1/2), 5/4-(1/4)*(4*n(n+1)+1)^(1/2)], [3/2], x^2)


convert(sol[1], LegendreP)

y(x) = _C1*(-1+x^2)*hypergeom([3/4+(1/4)*(4*n(n+1)+1)^(1/2), 3/4-(1/4)*(4*n(n+1)+1)^(1/2)], [1/2], x^2)+_C2*(x^3-x)*hypergeom([5/4+(1/4)*(4*n(n+1)+1)^(1/2), 5/4-(1/4)*(4*n(n+1)+1)^(1/2)], [3/2], x^2)




I just want y(x) to be expressed in the form of LegendreP(n,b,x).




I'm use Maple 13 (Linux)

I want save the value of u(x,t) at output file. This function is solution of PDE.


Can I get one file to each time value??






I am truing to simplify kretchmann variable in the following worksheet:


M > 

# Obtaining Ricci and Kretchmann;

DGsetup([t, r, theta, phi], M);
g := evalDG(-(1-2*M*mu/r)^(1/mu)*dt &t dt+(1-2*M*mu/r)^(-1/mu)*`&t`(dr, dr)+r^2*(1-2*M*mu/r)^(1-1/mu)*(`&t`(dtheta, dtheta)+sin(theta)^2*`&t`(dphi, dphi)));
C := Christoffel(g):

`frame name: M`


_DG([["tensor", M, [["cov_bas", "cov_bas"], []]], [[[1, 1], -(-(2*M*mu-r)/r)^(1/mu)], [[2, 2], (-(2*M*mu-r)/r)^(-1/mu)], [[3, 3], r^2*(-(2*M*mu-r)/r)^((mu-1)/mu)], [[4, 4], r^2*(-(2*M*mu-r)/r)^((mu-1)/mu)*sin(theta)^2]]])


Rie := CurvatureTensor(C):
R := RicciScalar(g,Rie);
h := InverseMetric(g):
kretchmann := ContractIndices(RaiseLowerIndices(g, Rie, [1]), RaiseLowerIndices(h, Rie, [2, 3, 4]), [[1, 1], [2, 2], [3, 3], [4, 4]]);




M > 

# simplification

M > 



M > 



M > 




The problem is that I cannot obtain a good form of it. With Mathematica FullSimplify[] function I got the following form (LaTeX code incoming): $K =& 4 M^2 \Bigl(A-B r+C r^2\Bigr)(r-2 M \mu)^{\frac{2}{\mu}-4}r^{-\frac{2}{\mu}-4},\
    A =&M^2 (\mu (3 \mu+2)+7) (\mu+1)^2,\,B = 8 M (\mu+2) (\mu+1),\, C = 12$, i.e. terms $(r-2 M \mu)$ and $r$ got fully factorized. However, I could never achieve the same form in Maple. Any help?

I am sorry if this is a silly and many-times-answered question, but I tried consulting with Maple help and googling solutions without any success.


Is there anyway, i can using maple software command to create a symbol for either math or nursing.Math sumbol or nursing symbol..if there is a way, can u please let me kw the way, i need it urgently.Thanks

Hi Maple experts and others,

We want to make a graph with 6 vertical lines.  One end of every vertical line will be on the x axis.  The other end of the vertical lines will be on integers of data points.






ab := Vector[row](6); cd := Vector[row](6)

ab := Vector[row](6, {(1) = 5, (2) = 8, (3) = 11, (4) = 14, (5) = 17, (6) = 20})


cd := Vector[row](6, {(1) = 1, (2) = 2, (3) = 3, (4) = 4, (5) = 5, (6) = 6})


for count to 6 do ab[count] := 3*count+2; cd[count] := count end do;


























Vector[row]([5, 8, 11, 14, 17, 20])



Vector[row]([1, 2, 3, 4, 5, 6])





Please assist us.




I'm trying to do something very simple, but I can not do it. I would like to fill the chart with colors of my choice.

restart: with (plots):
plots [animate] (plot, [[sqrt (x), sqrt (x) -1], x = 0..t, filled = true, view = [0..20, 0..5]], t = 0..20);

The filled = true option fills the graph with random colors.
I tried to use filled = ["Blue", "Red"], but that does not work.

Any tips?

Thank you


I got this solution from a PDE. I normally use unapply on the RHS of the solution to make it a function.

But in this, the PDE solution contain some extra stuff at the end. Which  "Where { .....}"

So the only way for me, was to manually copy the initial part of the solution shown on the screen in order to use it later.

I could not find a way to program this part.

Here is an example


lap:=VectorCalculus:-Laplacian(u(r, z, t), cylindrical[r, theta,z]);
bc:=u(r,0,t)=0,u(r,H,t)=0, u(a,z,t)=0;
ic:=u(r,z,0) = f(r,z);
sol:=pdsolve([diff(u(r,z,t),t) = k*lap,bc,ic],u(r,z,t)) assuming a>0,k>0;

THis gives

Which I verified to be correct.

In case you are not able to get this solution (it needs Maple 2019.1 and Physics 368), here is the lprint



u(r,z,t) = `casesplit/ans`(Sum(-BesselJ(0,lambda[n]/a*r)*sin(z/H*Pi)*exp(-k*t*(
StruveH(0,lambda[n])/hypergeom([1/2],[1, 2],-lambda[n]^2),n = 1 .. infinity),{
And(lambda[n] = BesselJZeros(0,n),0 < lambda[n])})

Next to use it (plot., evaluate, etc...) changed the sum go to 15 terms (more than enough) and also replaced a->1,H->3,k->1/100 and  also replaced lambda[n] with BesselJ zeros as follows

sol:=subs({infinity=15,a=1,H=3,k=1/100,lambda[n]=BesselJZeros(0, n)},sol);

Before I use unapply, I had to extract the part of the solution up to where it says "where..." since I do not need the rest any more, since I allready replaced lambda[n] with BesselJZeros calls.

This I did by hand using copy/paste from the screen. Now I am able to finish the task:

solFiltered:=Sum(-BesselJ(0, BesselJZeros(0, n)*r)*sin(z*Pi/3)*
     exp(-t*(9*BesselJZeros(0, n)^2 + Pi^2)/900)*Pi*
     BesselJ(1, BesselJZeros(0, n))*
     StruveH(0, BesselJZeros(0, n))/(BesselJZeros(0, n)^2*
     hypergeom([1/2], [1, 2], -BesselJZeros(0, n)^2)), n = 1 .. 15):



Which prints -0.4107565091 which is the correct value. It matches my hand solution and also match numerical solution.

What would a better way to do the above than what I did? i.e. to obtain the solFitered above using code only? 

5 6 7 8 9 10 11 Last Page 7 of 1555