Maple 2015 Questions and Posts

These are Posts and Questions associated with the product, Maple 2015

Hi, 

Why does the use of  global  at the top level of a worksheet is no longer accepted in the most recent versions of Maple (it still was in Maple 2015), but only within procedures?

TIA

Hi 

How to add a legend to Statistics:-Histogram?

This could be particularly useful to compare histograms, for instance in

S := Statistics:-Sample(Normal(0, 1), 1000):
T := Statistics:-Sample(Normal(1, 1), 1000):

plots:-display(
  Statistics:-Histogram(S, color=gold, transparency=0.3, legend="N(0,1)"),
  Statistics:-Histogram(T, transparency=0.3, legend="N(1,1)")
);

But doing this generates the error Error, (in Statistics:-Histogram) display does not accept the legend option

And yes indeed, even this command

h := Statistics:-Histogram(S, legend="N(0,1)")

already produces the same error.

After having examined the structure of h and using a way Carl Love gave here How to change the colour inn Statistics:-Sunflower?  I finally obtained the expected plot.
 

HS := Statistics:-Histogram(S, color=gold, transparency=0.3):
HT := Statistics:-Histogram(T, transparency=0.3):

hs := evalindets([op(HS)], specfunc(COLOUR), c-> (c, LEGEND("N(0,1)")) ):
ht := evalindets([op(HT)], specfunc(COLOUR), c-> (c, LEGEND("N(1,1)")) ):

PLOT(op(hs), op(ht))



But this rather long a way to proceed (Note: it seems that the overrideoption  that acer suggested in this prevous thread doesn't "work" here?)
Do you have any idea if there is a simpler solution?

TIA

Dear Users!
Hope everyone fine here. I have a vector V and want a new vector after transformation like

V := Vector(5, {(1) = 2, (2) = 3, (3) = -1, (4) = 9, (5) = 7});

after square transformation of V I got a new vector W like bellow

W := Vector(5, {(1) = 4, (2) = 9, (3) = 1, (4) = 81, (5) = 49});

and similarly sin transformation of V give the following matrix as

U := Vector(5, {(1) = sin(2), (2) = sin(3), (3) = sin(-1), (4) = sin(9), (5) = sin(7)});
Please help me to get vectors W and U.

Dear Users!
Hope everyone fine here. I tried (as given bellow) to find the solution of nonlinear system of PDEs via FDM. To solve system of nonlinear equations I used newton raphson method and for higher value of like Mx > 8 the matrix G and G1 (mentioned as red) take alot of time. Can anyone help me to reduce the computational time? Becuase I have to evealuate the solution for Mx = 50.


restart; Digits := 30; with(LinearAlgebra);
T := 1; L := 3; N := 30; Mx := 5; `Δx` := L/(1.*Mx); `Δt` := T/(1.*N);
for i from 0 while i <= Mx do
u[i, 0] := 0.; u[i, -1] := u[i, 1]; tau[i, 0] := 0.; theta[i, 0] := 0.; theta[i, -1] := theta[i, 1]
end do;
for n from 0 while n <= N do u[0, n] := 0.; u[Mx, n] := 0.; theta[0, n] := 1.; theta[Mx, n] := 0.
end do;
for n from 0 while n <= N-1 do
print("Simulation in proccess at time-level n", n+1);
for i while i <= Mx-1 do
Ru[i, n] := simplify((u[i+1, n+1]-u[i+1, n])/`&Delta;t`+(u[i+1, n+1]-2*u[i+1, n]+u[i+1, n-1])/`&Delta;t`^2-(u[i+1, n+1]-2*u[i, n+1]+u[i-1, n+1])/`&Delta;x`^2+25.*(u[i+1, n+1]+(u[i+1, n+1]-u[i+1, n])/`&Delta;t`)-1.5*(theta[i, n]+(theta[i, n+1]-theta[i, n])/`&Delta;t`));
`R&theta;`[i, n] := simplify((theta[i+1, n+1]-theta[i+1, n])/`&Delta;t`+(theta[i+1, n+1]-2*theta[i+1, n]+theta[i+1, n-1])/`&Delta;t`^2-(theta[i+1, n+1]-2*theta[i, n+1]+theta[i-1, n+1])/((15.)*`&Delta;x`^2)-((u[i, n+1]-u[i-1, n+1])/`&Delta;x`)^2/(3.)) end do;
for i while i <= Mx-1 do
`R&tau;`[i, n] := simplify(tau[i+1, n+1]+(tau[i+1, n+1]-tau[i+1, n])/`&Delta;t`-1.5^(-1/4)*(u[i+1, n+1]-u[i, n+1])/`&Delta;x`)
end do;
Sys := `<,>`(seq(Ru[i, n], i = 1 .. Mx-1), seq(`R&tau;`[i, n], i = 1 .. Mx-1), seq(`R&theta;`[i, n], i = 1 .. Mx-1));
V := `<,>`(seq(u[i, n+1], i = 1 .. Mx-1), seq(theta[i, n+1], i = 1 .. Mx-1), seq(tau[i, n+1], i = 2 .. Mx));
G := Matrix(3*(Mx-1), proc (i, j) options operator, arrow; diff(Sys[i], V[j]) end proc); G1 := MatrixInverse(G);
X[n, 0] := Vector(1 .. 3*(Mx-1), 1);
for k1 from 0 to r do
X[n, k1+1] := eval(V-G1 . Sys, Equate(V, X[n, k1]))
end do;
Sol[n] := Equate(V, X[n, r+1]); assign(op(Sol[n]));
if n > 0 then
U := eval(`<,>`(seq(u[i1, n+1], i1 = 1 .. Mx)-seq(u[i1, n], i1 = 1 .. Mx))); Noru[n+1] := Norm(%, 2); print("L[&infin;] norm of &tau;(x,y,t) at time level = ", %);
Theta := eval(`<,>`(seq(theta[i1, n+1], i1 = 0 .. Mx)-seq(theta[i1, n], i1 = 0 .. Mx))); `Nor&theta;`[n+1] := Norm(%, 2); print("L[&infin;] norm of &theta;(x,y,t) at time level = ", %) else print("n < 0")
end if end do

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

Dear Users!

I want to find the solution of the solution of PDEs as given bellow:

restart;
PDE1 := diff(u(y, t), t)+diff(u(y, t), t, t) = diff(u(y, t), y, y)-u(y, t);
PDE2 := v(y, t)+diff(tau(y, t), t) = diff(u(y, t), y);
ICandBC := {tau(y, 0) = 0, u(0, t) = 0, u(3, t) = 0, u(y, 0) = 0, (D[2](u))(y, 0) = 0};
pds := pdsolve({PDE1, PDE2}, ICandBC, numeric);

But got the following error

Error, (in pdsolve/numeric/process_PDEs) number of dependent variables and number of PDE must be the same
Kindly help me to fix this error. I shall be very thankful. 

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

Hi, 

I have always asked myself this question: why do the colon after the proc(...) statement generate an error if the following statement is local or global?
(the third example is here to show that no error occurs if local is omitted... the warning is of course obvious)

restart:
interface(version);
Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895

f := proc(x) local y: y:=x+1 end proc:

g := proc(x): local y: y:=x+1 end proc:
Error, unexpected `local` declaration in procedure body

h := proc(x): y:=x+1 end proc:
Warning, `y` is implicitly declared local to procedure `h`

TIA

I just got a "new" graphics card, NVIDIA GT630, and was wondering whether the CUDA capabilities are accessible. But no luck:

CUDA:-Enable();

Error, (in CUDA:-Enable) CUDA not supported on the current system (see CUDA,supported_hardware for more information)

The CUDA help page with the example, when run, just shows a host of error messages.

I have OS X 10.11.6, the above mentioned GT630 card with claimed 384 CUDA cores and 2 GB of VRAM; NVIDIA WebDriver 346.03.15f16 for the card (i.e. latest for this OS) and NVIDIA CUDA driver 8.0.90 (again, latest for this OS as far as I can tell). My Maple is 2015.2. All this running on a MacPro 4,1.

I am not having great illusions about the performance I should get (this is not a state-of-the-art card today), but it seems to me this combination should be working with Maple 2015 and not throw an error, shouldn't it? Checking the system extensions: CUDA.kext is loaded and its dependencies are satisfied, so I don't see any problem there.

Am I missing something?

M.D.

Hi, 
The result below surprises me.
Why does  rgf_findrecur return a result instead of saying that there is no homogeneous linear recurrence of order 1?

interface(version)

Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895


genfunc:-rgf_findrecur(1, [1, 2, 3, 4], t, n);
                       t(n) = 2 t(n - 1)

PS: maybe this was a problem in Maple 2015, if it has been corrected since just let me know

Why do I get this wrong result when I try to solve formally this ode (note that acer has already obtained its implicit form here implicit)

restart:
interface(version)
Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895

edo := diff(y(x), x, x) = 1/y(x) - x*diff(y(x), x)/y(x)^2;
ic  := y(0)=1, D(y)(0)=0:

dsolve({edo, ic}, y(x));
eval(edo, %)
                                        / d      \
                                      x |--- y(x)|
               d  / d      \    1       \ dx     /
              --- |--- y(x)| = ---- - ------------
               dx \ dx     /   y(x)          2    
                                         y(x)     
                    
                            y(x) = 1

                             0 = 1


Thanks in advance

Recently I came back on the general problem of drawing the syntactic graph of a mathematical expression.
Probably some of you have already done this as students for it is a classic when you learn recursive procedures, chained lists or graphs.

I wasn't interested in doing this with Maple, because Maple had already done  a part of the job thanks to the procedure ToInert.
More of this, the package GraphTheory seemed to possess all the required features to obtain quickly this syntactic graph.
Nevertheless it took me a lot of time to fix (almost all) the problems.
The issues are mainly of two orders:

  1. ToInert is very verbose: a necessary feature when you want to have a non ambiguous syntax of an expression, but partly useless for simple visualization.
    Here is an example
    ToInert(f(x))
    _Inert_FUNCTION(_Inert_NAME("f"), _Inert_EXPSEQ(_Inert_NAME("x")))

     

  2. GraphTheory 
    Once the inert form of the expression is known, it is necessary to put it in a form that can be manipulated by the procedures of the GraphTheory package.
    More precisely one needs to transform this inert form into a set of lists [a, b], where a and b are two neighboring vertices of the syntactic graph and [a, b] the directed arc from a to b.
    As the syntactic graph is a tree, this implies using edges {a, b} instead of arcs [a, b].
    The problem is that some operators are commutative while others are not: for the latter this means that the edges and vertices on the syntactic graph must appear in an order that respects the non-commutativity.
    Here his a toy example where I manually buid the syntactic graphs of a/b and b/a: the two graphs are identical and this comes from the fact that edges in Graph( edges )  must be a set, thus an ordered structure whose order doesn't care about non-commutativity.

    restart:
    with(GraphTheory):
    # The first is aimed to represent the expression a/b
    # while the second is aimed to represent the expression b/a
    Gdiv := Graph({{"/", "a"}, {"/", "b"}}):
    g1 := DrawGraph(Gdiv, style=tree, root="/", title=a/b):
    
    Gdiv := Graph({{"/", "b"}, {"/", "a"}}):
    g2 :=DrawGraph(Gdiv, style=tree, root="/", title=b/a):
    
    plots:-display(<g1 | g2>)
    

    Download ab_ba.mw

     

After several attempts, I decided to discard the GraphTheory package, that is to deprive myself of all the interesting features one needs to manipulate a graph.

The result is given on the attached file (... and the content of the worksheet can't be loaded as usual).

Download Syntactic_Graph.mw

Here is an example


Twelve test cases are given, all the corresponding syntactic graphs are correct, but one of them (test case iexpr=1) seems incorrect because the right child of a parent P is located to the right of the left child of a parent P', even though P' is to the right of P.
This could be corrected by modifying the way the posiitons are computed in procedure Place.


PS : It doesn't seem that Maple has a built-in procedure to construct the syntactic graph of a mathematical expression.
But maybe I'm wrong?


 

 

Hi,

It seems that it's not possible to change the tickmarks on axis 2 of a sparsematrixplot.
Mire of this, trying to change them seems to suppress them...
Perhaps this was a problem in Maple 2015 which has since been corrected?
By any chance, would you have a trick to correct this?

TIA
 

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

M := LinearAlgebra:-RandomMatrix(20,density=0.25,generator=0 .. 1);

M := Vector(4, {(1) = ` 20 x 20 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

(2)

plots:-sparsematrixplot(
   M, matrixview
);

 

plots:-sparsematrixplot(
   M, matrixview
  ,axis[1]=[tickmarks=[seq(i=i-1, i in [seq](1..20, 5))]]
  ,axis[2]=[tickmarks=[seq(j=j-1, j in [seq](1..20, 5))]]
);

 

plots:-sparsematrixplot(
   M, matrixview
  ,axis[2]=[tickmarks=[seq(i=i-1, i in [seq](1..20, 5))]]
);

 

 


 

Download sparsematrixplot.mw

Hi, 

Working with Legendre Polynomials (LegendreP) I observed that solve doesn't find the correct number of zeros.
More precisely, for N > 17, solve(LegendreP(N, x)) finds less zeros than N.

I wrote a procedure based on a theorem about the intertwined location of the zeros of orthogonal polynomial of successive degrees. So this problem is not blocking, but I would like to understand while solve(LegendreP(N, x)) doesn't always do the job.

Thanks in advance.
 

restart:

Z := n -> op~(2, { allvalues(solve(LegendreP(n,x))) } );

proc (n) options operator, arrow; `~`[op](2, {allvalues(solve(LegendreP(n, x)))}) end proc

(1)

Digits:=10:
Z(17):
numelems(%);

17

(2)

Z(18):
numelems(%);

16

(3)

Digits:=15:
Z(18):
numelems(%);

16

(4)

Digits:=20:
Z(18):
numelems(%);

15

(5)

Zf := n -> op~(2, { allvalues(solve(evalf(LegendreP(n,x)))) } );
Z(18):
numelems(%);

proc (n) options operator, arrow; `~`[op](2, {allvalues(solve(evalf(LegendreP(n, x))))}) end proc

 

15

(6)

# Let z[N][i] the ith zero of any orthogonal polynomial P(N,x) of degree N.
#
# It is known that each open interval(z[N][i], z[N][i+1]) contains
# exactly a unique zero of the of P(N+1,x).

Z17 := [ -1, Z(17)[], 1]:
Z18 := NULL:
for n from 1 to 18 do
  Z18 := Z18, fsolve(LegendreP(18,x),  x=Z17[n]..Z17[n+1]);
end do:
numelems({Z18})

18

(7)

# A procedure to compute zeros of LegendreP up to degree N


zeros := proc(N)
  local zeros_table, Z, n, p, z:
  zeros_table := table([0=[]]):
  Z := [-1, 1]:
  for n from 1 to N do
    z := NULL:
    for p from 1 to n do
      z := z, fsolve(LegendreP(n,x),  x=Z[p]..Z[p+1]);
    end do;
    zeros_table[n] := [z]:
    Z := [-1, z, 1]
  end do;
  return zeros_table
end proc:


 

Download LegendreP_zeros.mw

I used dsolve to solve the Initial value problems numericaly.
When I set the parameter range=1..5*10^4 , it works and cost only about 200s cpu time.
But if I set range=1..2*10^5, it stop running ( cpu time stop) when the mserver memory reach about 1.5 G. (the memory record in the bottom-right of maple interface is about 700M .)

What is the reason please?  

Hi, 

Using InertfForm, I found this strange result: 

e := (A+B)*(A+C);

ife  := InertForm:-Parse(convert(e, string));
InertForm:-Display(ife);

(A+B)*(A+C)

 

`%*`(`%+`(A, B), `%+`(A, C))

 

`%*`(`%+`(A, B), `%+`(A, C))

(1)

 

Download Precedence.mw

Why doesn't Display(..) return (A+B)*(A+C) ?

 

Hi, 

I often need to draw several curves on the same figure and the question of which colors to choose to distinguish them is crucial. 
In particular when these curves depend on a parameter I would like to color them by using a "regular" change of color.
The trick I use is this one
 

# here I want to plot N=10 different curves

N := 10:

# step 1: generate a list of colours using colorscheme
# (I was hoping for 10 levels of colors but I got 19)

plot(x, x=0..1, colorscheme=["Gold", "Blue"], numpoints=N):
MyColors := op([1,2, 2], %);
M := numelems(MyColors[..,1]);

# step 2: do the plots of interest, for instance

plots:-display(
  seq(
    plot(m*x^2, x=0..1, color=ColorTools:-Color([entries(MyColors[round(m/N*M)], nolist)])), 
    m=1..N
  )
);

My question is: How can we make that MyColors be a matrix whose the number of rows equal N (this to avoid the round(m/N*M) operation)?
(I will accept any other strategy)

Thanks in advance

First 7 8 9 10 11 12 13 Last Page 9 of 72