Maple 2018 Questions and Posts

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

How to let sqrt(5*x+5+y) become sqrt(5*(x+1)+y) automatically?

Hi!

I have a rather long Maple code and want it to be executed multiple times with a parameter changed each time.

Surely this can be done with the loop structure, but it seems the whole loop structure must be contained into one single execution group, which makes it to be a little inconvenient, since the code is too long.

 

So is there any alternative way to realize this utility?

 

Best regard and thanks!

I'm attempting to find the eigenvectors of a matrix without using the eigenvector function.

The matrix in question is a covariance matrix:

XCov:=Matrix([[4048/5, -817/5, -122/5], [-817/5, 921/10, -1999/10], [-122/5, -1999/10, 8341/10]]);

I've already found the eigenvalues by solving for lambda:

 det := Determinant(XCov-lambda*IdentityMatrix(3));
  lambda := solve(det=0.0, lambda);

(Yes I'm reusing the eigenvalue variable for the set of eigenvalues once they've been found­čśĆ)

Anyway, I've now set up the first eigenvector I want to find as:
e1 := Vector([e11,e12,e13]);


Now, the equation to find this first eigenvector is XCov . e1 = lambda[1] . e1
I first tried putting whats on the left in a variable called eigscale(what the vector is translated to by the matrix):

eigscale := Multiply(XCov,e1);
Which returns a vector:
eigscale = [(4048/5)*e11-(817/5)*e12-(122/5)*e13,
                  -(817/5)*e11+(921/10)*e12-(1999/10)*e13,
                  -(122/5)*e11-(1999/10)*e12+(8341/10)*e13]

Each component of this vector must equate to the corresponding component in the right vector:

lambda[1]*e1 = [7.943520930*e11, 7.943520930*e12, 7.943520930*e13]

At first I tried setting these vectors equal to each other and using a solve but of course it didnt like the equations being in a vector format. So I then seperated out each equation and gave the solve function a system of equations as it expects:

solve(eigscale[1] = lambda[1]*e1[1], eigscale[2] = lambda[1]*e1[2], eigscale[3] = lambda[1]*e1[3], [e11,e12,e13]);

But again, solve fails to solve them. The reason this time(I believe) is because it can't find an exact value for e11, e12 & e13.
When solving for an eigenvector we get
e11 = e11,
e12 = Ae11,
e13 = Be11 + Ce12

I was wondering if there was a way to do a partial solve to find the components in terms of each other?

Failing that, I'm aware I can do it manually through row operations but I believe that would require changing the format so that each equation is a component of a single vector:
eigsolve := Vector([eigscale[1] = lambda[1]*e1[1], eigscale[2] = lambda[1]*e1[2], eigscale[3] = lambda[1]*e1[3]]);

Since row operations cannot be performed on a equation of vectors (again, I believe).

Help appreciated!

Hello Everyone,

 

I have been working on a multi variable expression. I would like to have the intervals where the function is monotonically increasing. I am trying to study any available method for multivariable expressions.

I came across various papers and sites which are explicitly mentioned single variable equations. finding out the critical points and studying the sign of the first derivative. Same cannot be applied for the multi variable expression.

 https://www.math24.net/monotonic-functions/

above link explain for single variable functions. I would be grateful if someone could explain me a method or idea  which helps me out in solving for multivariable functions

 

Thanks a lot in advance

Hi,

I try to define the action of projectors of two discrete basis onto a general state. This works as expected when I define the projector by myself. However, when using the "Projector" command, I get a not fully simplified result; see below. It seems like there is a confusion with dot/tensor product.  Can somoeone help?

Best,

Henrik


 

restart; with(Physics)

Setup(hilbertspaces = {{A, alpha}, {B, beta}}, quantumbasisdimension = {A = 1 .. N[a], B = 1 .. N[b]}, quantumdiscretebasis = {A, B, alpha, beta}, bracketrules = {%Bracket(Bra(A, i), Ket(Psi)) = Ket(beta, i), %Bracket(Bra(A, i), Ket(alpha, j)) = C[i, j], %Bracket(Bra(B, i), Ket(Psi)) = Ket(alpha, i), %Bracket(Bra(B, j), Ket(beta, i)) = C[i, j]})

[bracketrules = {%Bracket(%Bra(A, i), %Ket(Psi)) = Physics:-Ket(beta, i), %Bracket(%Bra(A, i), %Ket(alpha, j)) = C[i, j], %Bracket(%Bra(B, i), %Ket(Psi)) = Physics:-Ket(alpha, i), %Bracket(%Bra(B, j), %Ket(beta, i)) = C[i, j]}, disjointedspaces = {{A, alpha}, {B, beta}}, quantumbasisdimension = {A = 1 .. N[a], B = 1 .. N[b]}, quantumdiscretebasis = {A, B, alpha, beta}]

(1)

``

proj := Sum(Sum(Ket(A, i).Bra(A, i).Ket(B, j).Bra(B, j), i = 1 .. N[a]), j = 1 .. N[b])

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j), Physics:-Bra(A, i), Physics:-Bra(B, j)), i = 1 .. N[a]), j = 1 .. N[b])

(2)

proj2 := Projector(Ket(A, i)).Projector(Ket(B, i))

Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, i), Physics:-Bra(B, i)), i = 1 .. N[b]))

(3)

proj.Ket(Psi)

Sum(Sum(C[i, j]*Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j)), i = 1 .. N[a]), j = 1 .. N[b])

(4)

NULL

proj2.Ket(Psi)

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i__1), Physics:-Bra(A, i__1), Physics:-Ket(alpha, i), Physics:-Ket(B, i)), i = 1 .. N[b]), i__1 = 1 .. N[a])

(5)

proj-proj2

Sum(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Ket(B, j), Physics:-Bra(A, i), Physics:-Bra(B, j)), i = 1 .. N[a]), j = 1 .. N[b])-Physics:-`*`(Sum(Physics:-`*`(Physics:-Ket(A, i), Physics:-Bra(A, i)), i = 1 .. N[a]), Sum(Physics:-`*`(Physics:-Ket(B, i), Physics:-Bra(B, i)), i = 1 .. N[b]))

(6)

``


 

Download projector_2d_space.mw

 

Two lines that look the same, produce different results. The first lines gives an error message, but the next line that looks the same, does not.

copying and pasting both lines in Notepad reveals the difference:

Determinant*(R1 . B+R2 . B+R3 . B+R4 . A)

Determinant(R1 . B+R2 . B+R3 . B+R4 . A)

It seems that there is a hidden character (the asterisk) in the first line that produces the error.

In the worksheet itself you cannot see the asterisk, but using the arrow keys you can notice that there is another character.

It's hard to debug your code if there are hidden characters.

``

restart; with(LinearAlgebra)

kernelopts(version)*interface(version)

`Maple 2018.2, X86 64 WINDOWS, Nov 16 2018, Build ID 1362973`*`Standard Worksheet Interface, Maple 2018.2, Windows 10, November 16 2018 Build ID 1362973`

(1)

A := Matrix(4, 4, symbol = a, shape = symmetric)

B := Matrix(4, 4, symbol = b, shape = symmetric)

R1 := Matrix(4, 4); R1[1, 1] := 1; R2 := Matrix(4, 4); R2[2, 2] := 1; R3 := Matrix(4, 4); R3[3, 3] := 1; R4 := Matrix(4, 4); R4[4, 4] := 1

Determinant*(R1.B+R2.B+R3.B+R4.A)

Error, (in LinearAlgebra:-Multiply) invalid arguments

 

Determinant(R1.B+R2.B+R3.B+R4.A)

-a[1, 4]*b[1, 2]*b[2, 3]*b[3, 4]+a[1, 4]*b[1, 2]*b[2, 4]*b[3, 3]+a[1, 4]*b[1, 3]*b[2, 2]*b[3, 4]-a[1, 4]*b[1, 3]*b[2, 3]*b[2, 4]-a[1, 4]*b[1, 4]*b[2, 2]*b[3, 3]+a[1, 4]*b[1, 4]*b[2, 3]^2+a[2, 4]*b[1, 1]*b[2, 3]*b[3, 4]-a[2, 4]*b[1, 1]*b[2, 4]*b[3, 3]-a[2, 4]*b[1, 2]*b[1, 3]*b[3, 4]+a[2, 4]*b[1, 2]*b[1, 4]*b[3, 3]+a[2, 4]*b[1, 3]^2*b[2, 4]-a[2, 4]*b[1, 3]*b[1, 4]*b[2, 3]-a[3, 4]*b[1, 1]*b[2, 2]*b[3, 4]+a[3, 4]*b[1, 1]*b[2, 3]*b[2, 4]+a[3, 4]*b[1, 2]^2*b[3, 4]-a[3, 4]*b[1, 2]*b[1, 3]*b[2, 4]-a[3, 4]*b[1, 2]*b[1, 4]*b[2, 3]+a[3, 4]*b[1, 3]*b[1, 4]*b[2, 2]+a[4, 4]*b[1, 1]*b[2, 2]*b[3, 3]-a[4, 4]*b[1, 1]*b[2, 3]^2-a[4, 4]*b[1, 2]^2*b[3, 3]+2*a[4, 4]*b[1, 2]*b[1, 3]*b[2, 3]-a[4, 4]*b[1, 3]^2*b[2, 2]

(2)

``


 

Download weird.mw

If I have an expression like this

f:=ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2))

maple has trouble to simplify the argument.

In particular is it possible to apply expand() only to the denominator?

This is meant in general, so if I have many terms with expressions like this (possibly of products with other functions in each term), I want this simplification to be done termwise for the arguments of the functions.

Expanding the fraction doesn't work as in frontend(expand, [f]).

This is not a problem per se, but more to understand the background.

restart;

f := polylog(2, -x);

int(f/(x+1), x);

convert(f, dilog);

int(%/(x+1), x)

 

The integration of the polylog maple is not capable of doing, but after converting to dilog it finds an anti derivative.

That leads to the question, why is dilog as a separate to polylog(2,*) implemented anyway? Why couldn't it all be done with the more general polylog function?

 

I'm also wondering why maple has difficulties to integrate

int(dilog(x+1)/(x+a),x)

for general a.

How would I go about getting true or false returned on these propositions?
I have tried just about every eval and various syntax methods, but nothing has worked so far.

I know most can easilly be done by hand/thinking, but I'm sure Maple should have a way to do this as well.

∀n∈Z:2n>n+2   ,   ∃n∈Z:2|(3n+1)    ,   ∃k∈Z:∀n∈Z:n=kn   ,   ∃k∈Z:∀n∈Z:2|(n+k)   ,   ∀n∈Z:∀k∈Z:(n>k∨k≥n)

Using Maple 2018.2.1, I'm receiving a lost kernel message when importing the attached data file with ImportMatrix. I traced the issue to a "*" symbol at the end of the file but would have expected this to cause an error message (if any error at all) instead of the connection to the kernel to be lost. Is this a bug or am I misunderstanding the usage of ImportMatrix?

test.mw

test2.txt

Hello, to all,
On my computer I have installed Windows 7 Professional, Maple 2018.2.1 and
Physics:-Version()[2];
 2019, January 5, 13:32 hours, version in the MapleCloud: 276,

    version installed in this computer: 276
When I try to compute some examples from your poste "PDE_and_BC_during_2018.mw", I get an error in Example 8:
Example 8: This problem represents the temperature distribution in a thin circular plate whose lateral surfaces are insulated (Articolo example 6.9.2):
pde__8 := diff(u(r, theta, t), t) = (diff(u(r, theta, t), r)+r*(diff(u(r, theta, t), r, r))+(diff(u(r, theta, t), theta, theta))/r)/(25*r);
                                       /                    
                                       |                    
                                       |                    
                                       |                    
              d                    1   |/ d                \
   pde__8 := --- u(r, theta, t) = ---- ||--- u(r, theta, t)|
              dt                  25 r |\ dr               /
                                       \                    

                                      2                  \
                                     d                   |
                                  -------- u(r, theta, t)|
          /  2                \          2               |
          | d                 |    dtheta                |
      + r |---- u(r, theta, t)| + -----------------------|
          |   2               |              r           |
          \ dr                /                          /
iv__8 := D[1]*u(1, theta, t) = 0, u(r, 0, t) = 0, u(r, Pi, t) = 0, u(r, theta, 0) = (r-(1/3)*r^3)*sin(theta);
   iv__8 := D[1] u(1, theta, t) = 0, u(r, 0, t) = 0,

                                       /    1  3\           
     u(r, Pi, t) = 0, u(r, theta, 0) = |r - - r | sin(theta)
                                       \    3   /           
pdsolve([pde__8, iv__8], u(r, theta, t), HINT = boundedseries(r = [0]));
Error, (in dsolve) cannot determine if this expression is true or false: not 0 <= -Pi

or I get no answer as in Example 10:
Example 10: A Laplace PDE with one homogeneous and three non-homogeneous conditions:
pde__10 := diff(u(x, y), x, x)+diff(u(x, y), y, y) = 0;
                    /  2         \   /  2         \    
                    | d          |   | d          |    
         pde__10 := |---- u(x, y)| + |---- u(x, y)| = 0
                    |   2        |   |   2        |    
                    \ dx         /   \ dy         /    
iv__10 := u(0, y) = 0, u(Pi, y) = sinh(Pi)*cos(y), u(x, 0) = sin(x), u(x, Pi) = -sinh(x);
      iv__10 := u(0, y) = 0, u(Pi, y) = sinh(Pi) cos(y),

        u(x, 0) = sin(x), u(x, Pi) = -sinh(x)
pdsolve([pde__10, iv__10]);

There are also no answer as in Examle 10 in the Examples 15, 18, 19
Can you give me a hint,  what could be wrong?
With kind regards
Wolfgang Gellien

 

So I was trying to create a shorthand for creating a plot of multiple arrows, with the arrow colour dependent on the magnitude of the vector.
I currently have a set of vectors, v, I want to display, and v[4] is the largest.

I know this could be done by creating an arrow plot for each vector seperately and then by combining them using display:
arrow1 := arrow( v[1], width=0.15,length=20,color=ColorTools:-Color( (norm(v[1])/norm(v[4]))*[0,0,1] ) );
arrow2 := arrow( v[2], width=0.15,length=20,color=ColorTools:-Color( (norm(v[2])/norm(v[4]))*[0,0,1] ) );
...
print(plots:-display([arrow1, arrow2, ...]));


But I was wondering if it could be done in a fashion similar to this:
arrows := arrow([seq(v[i], i=1..4)],width=0.15,length=20,color=ColorTools:-Color((norm(v[i])/norm(v[4]))*[0,0,1]));
print(arrows);



(btw: it works fine replacing the last i with 1, which draws all arrows nearly black, or with 4, which as you guessed, draws all arrows blue...)

Help appreciated!

I found a case where pdetest fails when called after another call to pdetest. I am using Physics version 272 from the clould. Using Maple 2018.2.1 on windows 10

restart;
u:='u';x:='x';t:='t';
pde := diff(u(x, t), t) + diff(u(x, t),x) =0;
sol:=pdsolve(pde,u(x,t));
pdetest(sol,pde);
    #0  OK
   
#restart;
u:='u';x:='x';t:='t';
pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bc:=u(0,t)=0;
ic:=u(x,0)=sin(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming x>0;
pdetest(sol,pde);
   
     #sol := u(x, t) = -sin(-x+t)*Heaviside(-t+x)   #OK
     
     #-Dirac(-t+x)*sin(x)*cos(t)+Dirac(-t+x)*cos(x)*sin(t)+
      Dirac(-x+t)*sin(x)*cos(t)-Dirac(-x+t)*cos(x)*sin(t)   #WRONG should be 0
 

 

If I run the above again, but with restart call in between active, so that all is cleared, then pdetest gives 0 as expected on the second pde, with the same solution

 

restart;
u:='u';x:='x';t:='t';
pde := diff(u(x, t), t) + diff(u(x, t),x) =0;
sol:=pdsolve(pde,u(x,t));
pdetest(sol,pde);
   #0   #OK
   
restart;
u:='u';x:='x';t:='t';
pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bc:=u(0,t)=0;
ic:=u(x,0)=sin(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming x>0;
pdetest(sol,pde);
   
   #0   #OK !! 

can any one explain why this happens?  Is this a bug? It seems like pdetest caching problem. it remembers something from the last call and this affects the result it gives for the next call.

any work around?

Hello everybody.

This is my question. I tried to evaluate a list of polynomial over a list of values. Something like this:

eval([a*x, b*x], x = [p, q, t])

to get something like this:

[[a*p, a*q, a*t], [b*p, b*q, b*t]]

I know this method: eval~(a*x,x=~[p,q,t])  though this works for one polynomial over a list of values. Not precisely, what I am looking for.

I figured out a method that worked defining functions and with ‘apply’ and ‘map’. Here an example:

m:=t->3*2^t:

n:=t->(t+4)^2:

map(apply~,[m,n],[1,2,3]);

[[6, 12, 24], [25, 72, 147]]

However, how can I get this result using the ‘eval’ function.

Thank you all in advanced for any contribution.

Might be a beginners trap...

How can I evaluate a constant expression or an expression/formula that contains several scientific constants without "Constantin'g' them out like in sample 2)??

1) Example:

Rb := (1/4)*alpha/(Pi*R[infinity])

'real' value of (Rb)??

1) This example works:

evalf(1-Constant(m[e])/Constant(m[p])) -- but it's awful with respect to the simple demand to just divide two known constants..

4 5 6 7 8 9 10 Last Page 6 of 31
´╗┐