Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dear all

I solve an optimization problem ( minimization or maximization) using lagrangeMultiplier theorem 

The objective function is f:=(x,y,z) =x*y+y*z;

The constraints are: x*y=1  and y^2+z^2=1;

Using a numerical method I get the follwing point 

x = 1.41421356249703, y = .707106781124551, z = .707106781248575

How can I confirm that this point is a minumum or maximum

Maybe I must use Hessian matrix or something else.

Which condition must be introduced to know the type ( maximum or minumum) this point.

Many thanks for your help

 

I have a system of equation as

Hi all

I have a system of equation:

sys := [x+y, 2*x+y^2];

How can I convert the previous system to this function using maple

F:=(x,y)->(x+y,2*x^2+y^2);

then how can I compute the gradient of F.

 

Many thanks.

 

 

Hi there,

I have an ode that I want to plot, I am trying to plot 2 different graphs on one graph and have tried using display but cannot seem to add a legend to it. Someone suggested adding a legend to each individual graph before combining them but I cannot find out how to add a legend to a DEplot. My code is as follows:

 

ode:=diff(u(t),t$2)-0.1*(1-64*u(t)^2)*diff(u(t),t$1)+16*u(t)=0

Q1:=v/4*sin(4*t)+epsilon*(1/8*(v-v^3)*t*sin(4*t)+v^3/128*(cos(4*t)-cos(12*t)))

A:=DEplot(ode,u(t),t=0..10, [[u(0)=0, D(u)(0)=v]], u=-0.5..0.5, linecolor=black, linestyle=dash, title="Numerical Solution"):

B:=plot(Q1, t=0..10, u=-0.5..0.5,color=blue, legend="Regular Perturbation Expansion"):

display([A,B],title="Comparing the regular perturbation expansion to the numerical solution")

 

Many thanks

I would like to convert a symbolic expression to text commands.  I recently used the expression palette to create a series summation; however, I was confused whether the sigma represented Sum vs sum.  I attempted to convert to string, but MAPLE attempts to evaluate the symbolic series prior to outputting the text commands.  Unfortunately, the evaluation of the series is computationally expensive & MAPLE will run out of memory.  I do not need MAPLE to evaluate the series.  How can it simply spell out the text commands that represent the symbolic form without resorting to evaluating the expression?


 

restart; T := M*tau; w := N*tau; M := Kappa*N; Ck := -2*(T*(4*tau^2*k^2*Pi^2*(4*tau-w)-w*T^2)*exp(-(1/2)*w/tau)*sin(w*Pi*k/T)+2*Pi*k*tau*(4*tau^2*k^2*Pi^2*(2*tau-w)-T^2*(2*tau+w))*exp(-(1/2)*w/tau)*cos(w*Pi*k/T)+4*Pi*k*tau^2*(T^2-(2*Pi*k*tau)^2))/(T^2+(2*Pi*k*tau)^2)^2

-2*(Kappa*N*tau*(4*tau^2*k^2*Pi^2*(4*tau-N*tau)-N^3*tau^3*Kappa^2)*exp(-(1/2)*N)*sin(Pi*k/Kappa)+2*Pi*k*tau*(4*tau^2*k^2*Pi^2*(2*tau-N*tau)-Kappa^2*N^2*tau^2*(2*tau+N*tau))*exp(-(1/2)*N)*cos(Pi*k/Kappa)+4*Pi*k*tau^2*(Kappa^2*N^2*tau^2-4*Pi^2*k^2*tau^2))/(Kappa^2*N^2*tau^2+4*Pi^2*k^2*tau^2)^2

(1)

sum(Ck*sin(2*Pi*k*x/T), k = 1 .. m)

``

``


 

Download convert_to_text_command.mw

I need to find the intersection points of two circles (x-7)^2+(y-2)^2=100 and (x-11)^2+(y-5)^2=75 using the modified Newton secant method. 

I have already done this by using these two equations to make one in terms of x. But, i am looking for suggestions on how to make a multiple variable version of the secant method.

Given a sequence for example: 8, 32,128,512,2048 and so on. Suppose we do not know it is 2^(2n +1). How to make Maple to find the principle?

Letter_Lrotate2D.mws

   I've asked a similar question before, and got the letters to rotate in 3D using the rotate command.  The resulting size in a 3D plot is relatively small..  The program gives a plotted letter L.  I wish to get some animation of it being rotated about the y-axis - but remaining in 2D.  ie looking at the letter it appears to be rotating.  To do thisI have multiplied the x-coords by the cosine of the angle of rotation.   

   In the for loop towards the end of the program there is a variable c1 which is incremented by one in the loop - yet it remains at 2, regardless of the angle increments.   Why is that?

  Again, any help or comments much appreciated.

 

Download test.mw
Udp: document attached.

Q__gr := Typesetting[delayDotProduct](Vector[row](8, {(1) = 0, (2) = 5, (3) = 10, (4) = 15, (5) = 20, (6) = 25, (7) = 30, (8) = 35}), Unit('m'^3/'day'), true)

Vector[row](%id = 18446746861178193550)

(1)

`η__gr` := Vector[row](8, {(1) = 0, (2) = 9.324, (3) = 17, (4) = 23.232, (5) = 27.192, (6) = 29.6, (7) = 29.516, (8) = 24.592})

Vector[row](%id = 18446746861214593262)

(2)

`pointsη` := [seq([Q__gr[i], `η__gr`[i]], i = 1 .. 8)]

[[0, 0], [5*Units:-Unit(m^3/d), 9.324], [10*Units:-Unit(m^3/d), 17], [15*Units:-Unit(m^3/d), 23.232], [20*Units:-Unit(m^3/d), 27.192], [25*Units:-Unit(m^3/d), 29.6], [30*Units:-Unit(m^3/d), 29.516], [35*Units:-Unit(m^3/d), 24.592]]

(3)

CurveFitting[PolynomialInterpolation](`pointsη`, q)

0.2348698413e-7*q^7/Units:-Unit(m^3/d)^7-0.2980622223e-5*q^6/Units:-Unit(m^3/d)^6+0.1482222222e-3*q^5/Units:-Unit(m^3/d)^5-0.3663955556e-2*q^4/Units:-Unit(m^3/d)^4+0.4666528890e-1*q^3/Units:-Unit(m^3/d)^3-.3165382223*q^2/Units:-Unit(m^3/d)^2+2.655161905*q/Units:-Unit(m^3/d)

(4)

eta := proc (q) options operator, arrow; 0.2348698413e-7*q^7/Units:-Unit(m^3/d)^7-0.2980622223e-5*q^6/Units:-Unit(m^3/d)^6+0.1482222222e-3*q^5/Units:-Unit(m^3/d)^5-0.3663955556e-2*q^4/Units:-Unit(m^3/d)^4+0.4666528890e-1*q^3/Units:-Unit(m^3/d)^3-.3165382223*q^2/Units:-Unit(m^3/d)^2+2.655161905*q/Units:-Unit(m^3/d) end proc

proc (q) options operator, arrow; 0.2348698413e-7*q^7/Units:-Unit(m^3/d)^7-0.2980622223e-5*q^6/Units:-Unit(m^3/d)^6+0.1482222222e-3*q^5/Units:-Unit(m^3/d)^5-0.3663955556e-2*q^4/Units:-Unit(m^3/d)^4+0.4666528890e-1*q^3/Units:-Unit(m^3/d)^3-.3165382223*q^2/Units:-Unit(m^3/d)^2+2.655161905*q/Units:-Unit(m^3/d) end proc

(5)

eta(12*Unit('m'^3/'day'))

.8415811058*Units:-Unit(m^3/d)^7/Units:-Unit(m^3/d)^7-8.900090268*Units:-Unit(m^3/d)^6/Units:-Unit(m^3/d)^6+36.88243199*Units:-Unit(m^3/d)^5/Units:-Unit(m^3/d)^5-75.97578241*Units:-Unit(m^3/d)^4/Units:-Unit(m^3/d)^4+80.63761922*Units:-Unit(m^3/d)^3/Units:-Unit(m^3/d)^3-45.58150401*Units:-Unit(m^3/d)^2/Units:-Unit(m^3/d)^2+31.86194286*Units:-Unit(m^3/d)/Units:-Unit(m^3/d)

(6)

simplify(19.76619849)

Error, (in Units:-Standard:-+) the units `m^21/s^7` and `m^18/s^6` have incompatible dimensions

 

``


 

Download test.mw

 

Hi!

I got a function (from CurveFitting), that produce a polynomial with the some units inside:

 

As i can see, it can be easy simplified, but i get:


 

Is where any trick to do it, without stripping units with convert(unit_free) or something?

Thank you!

 

Letter_L_rotate.mws

The attached program is of the letter L rotating.  about an axis which is the outer side of the 'upright' of the L.  I want to give the illusion that the letter L is rotating about a y-axis, where the x, y axes are in the plane of the screen, with the x-axis going from left to right.  The program at present 'works', in the sense that the letter L is rotating about an axis.  ...but it's not quite what I want.  My eventual aim is to plot the letters A and L side by side, AL, and as the letter L rotates the leg of the L would bump into the A,  so I want the A to rise in sync with movement of the letter L.   ...but that's a long way off!  For the moment I just want to know how to orientate the letter L, so that it is in its usual L state

   I think I have two options: either to change the coordinate positions of L, (long and tedious..) or quicker might be to change the axis of rotation.  Any suggestions on making the animation smoother would also be appreciated.

Thanks, David

 .

I wanted to use MAPLE to preform symbolic quantum computations. The role
of quantum operators and their tensor product is very important in simplying
the understating of such new calculus at least for the beginners. For instance,
(using "o" for the tensor product and "." for the scalar product, H being the Hadamard
operator on a qubit, I the identity operator, and CNOT the 2 qubit controled not
operator)
1) generating the Bells states |Bxy> two stages of operators are needed
     (CNOT) .  (H o  I)  . |x> o |y>

2) performing quantum teleportation of |psi>
     (H o I o I) . (CNOT o I ) . |psi>o |B00>
    followed by a measurements on the first two qubits for driving the application of
    quantum gates to the third qubit.

All these tensor products of operators can be easily written in MAPLE.

Here is a first version of the ExpandQop procedure that will be usefull the purpose of
expanding correctly the tensor product of two quantum operator expressed in Dirac notation.

I hope this is usefull.

LL 

 

######################################################################
# Author: Louis Lamarche                                             #
#         Institute of Research of Hydro-Quebec (IREQ)               #
#         Science des données et haute performance                   #
#         2018/02/20                                                 #
#                                                                    #
#         Function name: ExpandQop (x)                               #
#               Purpose: Compute the tensor product of two quantum   #
#                        operators in Dirac notations                #
#              Argument: x - a simple quantum operator               #
#   Future improvements: Manage all +, -, *, /, ^, mod  operations   #
#                        in the argument                             #
#               Version: 1.0                                         #
######################################################################
restart;

with(Physics):
interface(imaginaryunit=i):
Setup(mathematicalnotation=true);

[mathematicalnotation = true]

(1)

Setup(quantumoperators={A,B,C,Cn});
Setup(noncommutativeprefix={a,b});

[quantumoperators = {A, B, C, Cn}]

 

[noncommutativeprefix = {a, b}]

(2)

ExpandQop:=proc(x)
    local ret,j,lkb,cbk,rkb,no;
    ret:=1; lkb:=0; cbk:=0; rkb:=0; no:=nops(x);
    if (no > 3 ) then
        for j from 1 to no do
            if (j>1) then
                 if(lkb=0) then
                     if( type(op(j-1,x),Ket) and
                         type(op(j,x),Bra) ) then lkb:=j-1; fi;
                 else
                     if( type(op(j-1,x),Ket) and
                         type(op(j,x),Bra) ) then rkb:=j;   fi;
                 fi;
                 if( type(op(j-1,x),Bra) and type(op(j,x),Ket) )
                                             then cbk:=j;   fi;
            fi;
        end do;
        if ( (lkb < cbk) and (cbk<rkb) ) then
            for j from 1     to lkb   do ret := ret*op(j,x); end do;
            for j from cbk   to no    do ret := ret*op(j,x); end do;
            for j from lkb+1 to cbk-1 do ret := ret*op(j,x); end do;
        else
            ret:=x;
        fi;
    else
        ret:=x;
    fi;
    return ret;
end proc:

# Let A be an operator in a first Hilbert space of dimension n
#  using the associated orthonormal ket and bra vectors
#
#
kets1:=Ket(a1)*Ket(a2)*Ket(a3)*Ket(a4)*Ket(a5):
A:=kets1*Dagger(kets1);


# Let B be an operator in a second Hilbert (Ketspace of dimension m
#  using the associated orthonormal ket and bra vectors
#
#
kets2:=Ket(b1)*Ket(b2)*Ket(b3):
B:=kets2*Dagger(kets2);


# The tensor product of the two operators acts on a n+m third
# Hilbert space   unsing the appropriately ordered ket
# and bra  vectors of the two preceding spaces. The rule for
# building this operator in Dirac notation is as follows,
#
#


print("Maple do not compute the tensor product of operators,");
print("C=A*B gives:");
C:=A*B;

print("ExpandQop(C) gives the expected result:");
Cn:=ExpandQop(C);

Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

 

Physics:-`*`(Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

 

"Maple do not compute the tensor product of operators,"

 

"C=A*B gives:"

 

Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1))

 

"ExpandQop(C) gives the expected result:"

 

Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3), Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

(3)

kets3:=kets1*kets2;
bras3:=Dagger(kets3);
print("Matrix element computed with C appears curious");
'bras3.C. kets3'="...";
bras3.C.kets3;
print("Matrix element computed with Cn as expected");
'bras3.Cn.kets3'=bras3.Cn.kets3;

Physics:-`*`(Physics:-Ket(a1), Physics:-Ket(a2), Physics:-Ket(a3), Physics:-Ket(a4), Physics:-Ket(a5), Physics:-Ket(b1), Physics:-Ket(b2), Physics:-Ket(b3))

 

Physics:-`*`(Physics:-Bra(b3), Physics:-Bra(b2), Physics:-Bra(b1), Physics:-Bra(a5), Physics:-Bra(a4), Physics:-Bra(a3), Physics:-Bra(a2), Physics:-Bra(a1))

 

"Matrix element computed with C"

 

Physics:-`.`(bras3, C, kets3) = "..."

 

Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(a1))*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(a2))*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(a3))*Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(b1))*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(b2))*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(b3))*Physics:-Bracket(Physics:-Bra(a4), Physics:-Ket(a4))^2*Physics:-Bracket(Physics:-Bra(a5), Physics:-Ket(a5))^2*Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(a1))*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(a2))*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(a3))*Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(b1))*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(b2))*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(b3))

 

"Matrix element computed with Cn as expected"

 

Physics:-`.`(bras3, Cn, kets3) = Physics:-Bracket(Physics:-Bra(a1), Physics:-Ket(a1))^2*Physics:-Bracket(Physics:-Bra(a2), Physics:-Ket(a2))^2*Physics:-Bracket(Physics:-Bra(a3), Physics:-Ket(a3))^2*Physics:-Bracket(Physics:-Bra(a4), Physics:-Ket(a4))^2*Physics:-Bracket(Physics:-Bra(a5), Physics:-Ket(a5))^2*Physics:-Bracket(Physics:-Bra(b1), Physics:-Ket(b1))^2*Physics:-Bracket(Physics:-Bra(b2), Physics:-Ket(b2))^2*Physics:-Bracket(Physics:-Bra(b3), Physics:-Ket(b3))^2

(4)

 


 

Download ExpandQop.mw

 

 

In the fraction 3^665/2^x=y, where y is more than 1 and less than 2, I want to know the value of x. What input should I write, please?

  1. (k-2)*(k^2+5)*(k^3-k^2+7*k+8)/(6*k*(k^2-3*k+8))
  2. (k+2)*(k^2+5)*(k^3-5*k^2+13*k-8)/(6*k*(k^2-3*k+8))
  3. k^3+3*k^2+11*k-3
  4. k^2+2*k+9

Lesson_on_functions.mws

As the title says, a lesson on functions:  eg the -> operator, f(2), eval, evalf etc 

How to draw the following function containing an imaginary number
 

NULL

u := proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(x-t)+2*exp(-x+t))+(1/2)*(exp(x-t)-2*exp(-x+t))/(exp(x-t)+2*exp(-x+t)) end proc

proc (x, t) options operator, arrow; 1/2+I*sqrt(2)/(exp(x-t)+2*exp(-x+t))+(1/2)*(exp(x-t)-2*exp(-x+t))/(exp(x-t)+2*exp(-x+t)) end proc

 

``

 

 

 

``

 

 

 

 

 

 

``

 

 

``

NULL


 

Download plot33.mwDownload plot33.mw

I'm attempting to solve the complex-valued differential equation

restart:
assume(t::real):

pde := diff(A(t),t) - I * conjugate(A(t))*A(t)^2 = 0:
dsolve(pde);

However, it seems Maple attempts to solve it using separation of variables and gives

t-Intat(-I/conjugate(_a)/_a^2,_a = A(t))+_C1 = 0

Unless I'm mistaken, a complex integral such as this isn't even defined without a contour.

Working the integral out by hand, I know the solution to be

_C1*exp(I*abs(_C1)*t)

Is there a trick I'm missing to get Maple to find this solution? Or is this outside the scope of what Maple can handle on it's own?

Thanks!

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