Items tagged with maple maple Tagged Items Feed

Let N be an integer. 

 

For each pair of integers (n,m) where 1<= n,m <= N, we have a variable f_{n,m}(t). 

 

Then for these we have a system of ODEs 

 

d/dt f_{n,m}(t) = \sum_{n', m'} f_m'n' * f_m''n'' * (m'n'' - m''n') 

 

where m''=m-m', n''=n=n', and the sum is simply over for all pairs (n',m'). 

 

I simply do not know how to put these set of equations into Maple in a nice way. 

 

I will really appreciate any help!

EDIT 2: Ok, here is what I am trying to do with Maple.

I have the following expression:

with

 

and

 (j times)

Now the above expression should be zero. I get a set of equations in orders of lambda. The H matrices are known. I only need to find the S matrices.

Anyways, the HOffDiag is the sum above and the GetAdvCommutator0 is this nested commutator. And I need this sum evaluated up to order n (n is a given input-number) in lambda. The rest is really not that performance hungry.

 

 

EDIT: Ok, it realy seems that this sum of commutators is something that takes Maple forever. I have written a new MWE. Is it possible to speed things up? Maybe using assumptions or so?

 

restart;with(Physics):with(LinearAlgebra): Setup(mathematicalnotation=true):Setup(noncommutativeprefix={M,H,S});

[noncommutativeprefix = {H, M, S}]

(1)

GetAdvCommutator0:=proc(power::integer,order::integer,M)
    if power <= 0 then return M fi:
    if power = 1 then

        return mtaylor(Commutator(M,add(lambda^l*S[l],l=1..order)),lambda, order+1) fi:
    
    return mtaylor(Commutator(GetAdvCommutator0(power-1,order,M),add(lambda^l*S[l],l=1..order)),lambda,order+1):
end proc:

HOffDiag:=n->eval(add(1/((2*j+1)!)*'GetAdvCommutator0'(2*j+1,n,H[0]),j=0..iquo(n-1,2)+1)+add(1/((2*j+1)!)*'GetAdvCommutator0'(2*j+1,n,lambda*H[1]),j=0..iquo(n-2,2)+1)+add(1/((2*j)!)*'GetAdvCommutator0'(2*j,n,lambda*H[2]),j=0..iquo(n-1,2)+1)):

HOffDiag(3); # still fast

lambda^3*Physics:-Commutator(H[0], S[3])+lambda^2*Physics:-Commutator(H[0], S[2])+lambda*Physics:-Commutator(H[0], S[1])+(1/6)*lambda^3*Physics:-Commutator(Physics:-Commutator(Physics:-Commutator(H[0], S[1]), S[1]), S[1])+lambda^2*Physics:-Commutator(H[1], S[1])+lambda^3*Physics:-Commutator(H[1], S[2])+lambda*H[2]+(1/2)*lambda^3*Physics:-Commutator(Physics:-Commutator(H[2], S[1]), S[1])

(2)

HOffDiag(6); # takes a very long time, I didn't even try entering higher numbers

Warning,  computation interrupted

 

 

 

SumOfCommutators.mw

 

Hi,

I know this question is really unspecific. However, since I am still new to Maple, and since you don't program with Maple as you would do with c++, I would appreciate some advise. I have written a program in Maple and I don't know if it works correctly. All I know is, it is pretty slow :(.

So if anyone of you could just have a short look at my attached worksheet and could tell me, if I at some point used an obvious "don't", I would greatly appreciate it.

 

Cheers

NOh

 

 

A Maple worksheet

NULL

Setup Maple

 

NULL

restart;with(Physics):with(LinearAlgebra):Setup(mathematicalnotation=true):Setup(noncommutativeprefix={MA,MB,H,S});

[noncommutativeprefix = {H, MA, MB, S}]

(1.1)

NULL

NULL

Input parameter

 

NULL

H0:=Matrix([[ 0 , 0 , 0 , 0 ],
            [ 0 , 0 , 0 , 0 ],
            [ 0 , 0 , U , 0 ],
            [ 0 , 0 , 0 , U ]]);

H0 := Matrix(4, 4, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = U, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = U})

(2.1)

H1:=Matrix([[ 0 , 0 , 0 , 0 ],
            [ 0 , 0 , 0 , 0 ],
            [ 0 , 0 , 0 , 0 ],
            [ 0 , 0 , 0 , 0 ]]);

H1 := Matrix(4, 4, {(1, 1) = 0, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0})

(2.2)

H2:=Matrix([[  0 , 0 , -t , -t ],
            [  0 , 0 ,  t ,  t ],
            [ -t , t ,  0 ,  0 ],
            [ -t , t ,  0 ,  0 ]]);

H2 := Matrix(4, 4, {(1, 1) = 0, (1, 2) = 0, (1, 3) = -t, (1, 4) = -t, (2, 1) = 0, (2, 2) = 0, (2, 3) = t, (2, 4) = t, (3, 1) = -t, (3, 2) = t, (3, 3) = 0, (3, 4) = 0, (4, 1) = -t, (4, 2) = t, (4, 3) = 0, (4, 4) = 0})

(2.3)

orderNumber:= 4 ;

4

(2.4)

NULL

 

 

 

Define all necessary functions

 

 

 

GetAdvCommutator0:=proc(power::integer,order::integer)
    local Comm:
    if power <= 0 then return H[0] fi:
    if power = 1 then return add(coeff(Commutator(H[0],add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order) fi:
    
    return add(coeff(Commutator(GetAdvCommutator0(power-1,order),add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order):
end proc:

GetAdvCommutator1:=proc(power::integer,order::integer)
    local Comm:
    if power <= 0 then return lambda*H[1] fi:
    if power = 1 then return add(coeff(Commutator(lambda*H[1],add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order) fi:
    
    return add(coeff(Commutator(GetAdvCommutator1(power-1,order),add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order):
end proc:

GetAdvCommutator2:=proc(power::integer,order::integer)
    local Comm:
    if power <= 0 then return lambda*H[2] fi:
    if power = 1 then return add(coeff(Commutator(lambda*H[2],add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order) fi:
    
    return add(coeff(Commutator(GetAdvCommutator2(power-1,order),add(lambda^l*S[l],l=1..order)),lambda,n)*lambda^n,n=0..order):
end proc:

 

HOffDiag:=n->eval(add(1/((2*j+1)!)*'GetAdvCommutator0'(2*j+1,n),j=0..iquo(n-1,2)+1)+add(1/((2*j+1)!)*'GetAdvCommutator1'(2*j+1,n),j=0..iquo(n-2,2)+1)+add(1/((2*j)!)*'GetAdvCommutator2'(2*j,n),j=0..iquo(n-1,2)+1)):

 

 

 

HOnDiag:=n->eval(add(1/((2*j)!)*'GetAdvCommutator0'(2*j,n),j=0..iquo(n,2)+1)+add(1/((2*j)!)*'GetAdvCommutator1'(2*j,n),j=0..iquo(n-1,2)+1)+add(1/((2*j+1)!)*'GetAdvCommutator2'(2*j+1,n),j=0..iquo(n-2,2)+1)):

 

computeHBlockDiag:=proc( n::posint,firstBlockWidth::posint, H0::Matrix, H1::Matrix, H2::Matrix )
    local expr, Orders, i, eq, j, eq2, orders,smatrices,rows::posint,evallist,m,l,cols,Hdiag,ff;
    
    
    expr:=HOffDiag(n);       # !!!!! this one is one of the slowest parts I think                                     
    Orders:=[$1..n];                                              
    for i from 1 to n do                                          
        eq:=add(coeff(expr,lambda,l)*lambda^l,l=0..i)=0;       
        for j from 1 to i-1 do
            eq:=eval(eq,Commutator(H[0],S[j])=Orders[j]);
        od;
        eq:=subs(Commutator(H[0],S[i])=MX,eq);
        eq2:=solve(eq,MX);
        Orders[i]:=eq2;
    od;

    
    rows,cols:=Dimension(H0);                                    
    smatrices:=[seq(H0,i=1..n)];
    for i from 1 to n do
        evallist:=[`*`=`.`,H[1]=H1,H[2]=H2];
        for j from 1 to i-1 do
            evallist:=[op(evallist),S[j]=smatrices[j]];        
        od;
        smatrices[i]:=eval(Orders[i],evallist);
        for m from 1 to firstBlockWidth do
            for l from firstBlockWidth+1 to rows do
                smatrices[i][m,l]:=smatrices[i][m,l]*1/(H0[m][m]-H0[l][l]);
                smatrices[i][l,m]:=smatrices[i][l,m]*1/(H0[m][m]-H0[l][l]);
            od;
        od;
    od;


    expr:=HOnDiag(n);            # !!!!! and this one of course (almost identical to the one above)                                       
    Hdiag:=eval(add(coeff(expr,lambda,l)*lambda^l,l=0..n),lambda=1);
    evallist:= [op(evallist), H[0]=H0,S[n]=smatrices[n]];
    Hdiag:=eval(Hdiag,evallist);


    
    return Hdiag;
end proc:

 

 

NULL

computeHBlockDiag(2,2,H0,H1,H2);

Matrix(4, 4, {(1, 1) = -2*t^2/U, (1, 2) = 2*t^2/U, (1, 3) = 0, (1, 4) = 0, (2, 1) = 2*t^2/U, (2, 2) = -2*t^2/U, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = U+2*t^2/U, (3, 4) = 2*t^2/U, (4, 1) = 0, (4, 2) = 0, (4, 3) = 2*t^2/U, (4, 4) = U+2*t^2/U})

(1)

Eigenvalues(%);

Vector(4, {(1) = 0, (2) = U, (3) = -4*t^2/U, (4) = (U^2+4*t^2)/U})

(2)

 

Testing

 

``

#Fast

computeHBlockDiag(2,2,H0,H1,H2);

Matrix(4, 4, {(1, 1) = -2*t^2/U, (1, 2) = 2*t^2/U, (1, 3) = 0, (1, 4) = 0, (2, 1) = 2*t^2/U, (2, 2) = -2*t^2/U, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = U+2*t^2/U, (3, 4) = 2*t^2/U, (4, 1) = 0, (4, 2) = 0, (4, 3) = 2*t^2/U, (4, 4) = U+2*t^2/U})

(4.1)

#Not so fast

computeHBlockDiag(4,2,H0,H1,H2);

Matrix(4, 4, {(1, 1) = -2*t^2/U-(8/3)*t^4/U^3, (1, 2) = 2*t^2/U+(8/3)*t^4/U^3, (1, 3) = 0, (1, 4) = 0, (2, 1) = 2*t^2/U+(8/3)*t^4/U^3, (2, 2) = -2*t^2/U-(8/3)*t^4/U^3, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = U+2*t^2/U+(8/3)*t^4/U^3, (3, 4) = 2*t^2/U+(8/3)*t^4/U^3, (4, 1) = 0, (4, 2) = 0, (4, 3) = 2*t^2/U+(8/3)*t^4/U^3, (4, 4) = U+2*t^2/U+(8/3)*t^4/U^3})

(4.2)

#Already pretty slow :(

computeHBlockDiag(6,2,H0,H1,H2);

Warning,  computation interrupted

 

 

``

 

Download MapleWorksheet.mw

Hi!

I am new to Maple and have a problem I've been struggling with all day.

I have a pendulum and need to find a equation of motion in the y-direction. Please find my code in the picture below.

I can see that my problem starts at Eqy where the differentiation deletes one of the right-hand-side parts because I don't have any function y(t), and Maple thinks y(t) a constant (?)
Can somebody please tell me what I'm doing wrong?

 

Thank you in advance!


I have Maple 14 on a macbook pro. I recently upgraded to the Yosemite operating system. 

 

I am trying to use the CurveFitting facility:

with(CurveFitting):

But I get nothing. This might be associated with Yosemite, or maple 14, or ????? Anyone have a guess?

Hello!

I'm trying to solve a differential equation of the form y.y"+y'+y= { 1 for 0<x<1 and 0 for else } with conditions: y(0)=0 and y'(0)=1.

I wrote this:

f(x):=heaviside(0)-heaviside(1);

Eq := y(x)*(diff(y(x), x, x))+diff(y(x), x)+y(x)-f(x);

ans := dsolve({Eq, y(0) = 0, (D(y))(0) = 1},numeric);

But it gives an error.

I also tried ODE tools>assistants>analyzer

It says: the ODE system does not contain derivatives of the unknown function heaviside.

 

It's the first time I use Maple and I don't know what to do. Need your help urgently. Thanks in advance.

 

Hi there,

Is there a way in which i can solve the following optimal control problem numerically with Maple?

 dH/dt=λ-µ H-(1-u1)β H V+δ I,

dI/dt=(1-u1)β H V-σ I,

‎dV/dt=(1-u2)k I-γ‎V,

dλ1/dt=-1+λ1µ+β‎‎V(1-u1)(λ1-λ2),‎

dλ2/dt=λ1δ+λ2σ-λ3(1-u2)k‎,‎

‎dλ3/dt=β H(λ1-λ2)(1-u1)‎‎+λ3γ.

where

u1=βHV(λ1-λ2)/A1,

u2=-λ3kI/A2,

σ = α + δ,

and

H(0)=1.7*10^8,    I(0)=0,    V(0)=400.

 

λ=5*10^5,    µ=0.003,     β=4*10^(-10),    α=0.043,    δ= 0.2                  k=6.24,       γ‎=0.65.

A1=900, A2=1000.

 

Answers and advice are very appreciated. 

Thank you all for reading.

Aylin

Hi all,

I am stuck with the following problem:

convert(cos(alpha), exp); works fine for me.

Once I have the trigonometric functions in a matrix, it does not work any more:

In the latter line, A keeps the trigonometric functions. Why is this the case? Is there any way to force maple to keep the complex exponentials instead of trigonometric functions?

 

I am using LinearAlgebra and VectorCalculus.

 

Best Regards

Wassja

According to kernelopts(version), I am using Maple 16.02, X86 64 LINUX, Nov 18 2012, Build ID 7888210 , having just updated

Maple 16.

I have a Maple worksheet with some graphs of 10^5 data points. When I export the worksheet to a pdf for inclusion in a LaTeX document (with pdfpages package, this recognizes page breaks), the file is around 100 Mb, much larger than I would like.

It seems that the file is large as a figure in the pdf is not just an image, the pdf seems to contain all of the information necessary to plot each data point individually.

Is there some way to encourage Maple 16 to treat figures as bitmaps (or something similarly much smaller than the original figures) upon exporting a worksheet to a pdf? I'll be happy for any suggestions.

NOTES:

1. This question was originally for Maple 16.00. Updating to 16.02a has not solved the problem.

2. I am suspicious that there is some bug in how Maple 16 exports figures made with "plot" to a pdf file.

When I try various methods of compressing the pdf that I've seen on the web, such as with pdftk 1.44, or ghostscript 8.70 or 9.07,  or pdf2ps followed by ps2pdf ,

error messages are returned. For example using pdftk:

pdftk input.pdf output.pdf

gives

"Done. Input errors, so no output created"

 

Is there any command in maple that can show us an assigned varibale how much bytes occupied on memory ?

a:=["just a string", 3.14 , 123 , x/y]

d:=array( 1 .. 2, 1 .. 2, [( 1, 1 ) = ("just a string"), ( 1, 2 ) = (3.14), ( 2, 1 ) = (123), ( 2, 2 ) = (x/y)  ] )

c:=a x^2 + b x + c

b := Matrix(2, 2, {(1, 1) = "just a string", (1, 2) = 3.14, (2, 1) = 123, (2, 2) = x/y})

b := Matrix(2, 2, {(1, 1) = "just a string", (1, 2) = 3.14, (2, 1) = 123, (2, 2) = x/y})

(1)

``


It should be great for benchmarking !

I have an integral that maple can not solve but I can solve it by hand. How can I add this to maple integration database?

f:=int(r^2*BesselJ(0,a*r)*BesselI(1,b*r),r)

Please see the file below.

Integral.mw

 

Many many thanks! :)

How do i use d'Alembert formula to solve,plot and animate with Maple software

So for the part of the erdos gallai theorem that says:


\sum^{k}_{i=1}d_i\leq k(k-1)+ \sum^n_{i=k+1} \min(d_i,k)

 

how could I translate this into maple? I'm assuming I'll need to use nested for...dos

Here was my search strategy to find the answer:

keyboard shortcut execute worksheet on http://www.mapleprimes.com/search/?term=keyboard%20shortcut%20execute%20worksheet

only found one thing http://www.mapleprimes.com/users/erik10/answers

Googled it found 

http://www.maplesoft.com/support/help/maple/view.aspx?path=worksheet%2Freference%2Fhotwin

http://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet/expressions/executeworksheet

http://scipp.ucsc.edu/~haber/webpage/maple_cheatsheet.pdf

Don't see a keyboard shortcut. 

What is the keyboard shortcut to execute entire worksheet? Is there a name for this action of executing the whole worksheet? 

 

What did you search and click to find the answer? 

I am Maple 15 student edition user and the packages is not loaded when I use the execute all command from the GUI. I have to manually press the enter key to have by package loaded before I use a function defined in the package. How can I work around this issue?

Thanks

P.S: You can see the Maple document attached to this post.

NumericalSimulation.mw

A := Matrix(3, 4, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 2, (2, 2) = 2, (2, 3) = 0, (2, 4) = 0, (3, 1) = 0, (3, 2) = 6, (3, 3) = 4, (3, 4) = 0});
print(`output redirected...`); # input placeholder
Matrix(%id = 4436610626)
RowSpace(A);
print(`output redirected...`); # input placeholder
RowSpace(Matrix(%id = 4436610626))

 Why is this failing to give the row space? I copied and pasted it from the tutorial on this and it seems to run in the tutorial but not when I copy and paste it outside the tutorial? 

tutorial http://www.maplesoft.com/support/help/maple/view.aspx?path=LinearAlgebra%2FRowSpace

See picture

http://i.imgur.com/eQtEJU4.png?1

 

In general what is the best way to share maple code with users on this forum ? The above copy and paste looks messy. 

 

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