Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

When I make the input 2*pi*440 the output is pi880.

How to come to the result 2764,6 radians?

Coding_Basic_Reproduction_Number_2.mw

Anybody know how to simplify the equation?

Hi,

Some ideas to plot ( animate) tangents at corner point or cusp point?

For examples : f(x)=sqrt(abs(x-1)) , g(x)=sqrt(abs(x^2-4))

Thanks

factor_problem.mw

I want to factor the following polynomial:

Teller := 2*i1^4*i2*i3+2*i1^4*i2*i4+2*i1^4*i2*i5+2*i1^4*i3*i4+2*i1^4*i3*i5+2*i1^4*i4*i5+4*i1^3*i2^2*i3+4*i1^3*i2^2*i4+4*i1^3*i2^2*i5+4*i1^3*i2*i3^2+6*i1^3*i2*i3*i4+6*i1^3*i2*i3*i5+4*i1^3*i2*i4^2+6*i1^3*i2*i4*i5+4*i1^3*i2*i5^2+4*i1^3*i3^2*i4+4*i1^3*i3^2*i5+4*i1^3*i3*i4^2+6*i1^3*i3*i4*i5+4*i1^3*i3*i5^2+4*i1^3*i4^2*i5+4*i1^3*i4*i5^2+2*i1^2*i2^3*i3+2*i1^2*i2^3*i4+2*i1^2*i2^3*i5+4*i1^2*i2^2*i3^2+6*i1^2*i2^2*i3*i4+6*i1^2*i2^2*i3*i5+4*i1^2*i2^2*i4^2+6*i1^2*i2^2*i4*i5+4*i1^2*i2^2*i5^2+2*i1^2*i2*i3^3+6*i1^2*i2*i3^2*i4+6*i1^2*i2*i3^2*i5+6*i1^2*i2*i3*i4^2+24*i1^2*i2*i3*i4*i5+6*i1^2*i2*i3*i5^2+2*i1^2*i2*i4^3+6*i1^2*i2*i4^2*i5+6*i1^2*i2*i4*i5^2+2*i1^2*i2*i5^3+2*i1^2*i3^3*i4+2*i1^2*i3^3*i5+4*i1^2*i3^2*i4^2+6*i1^2*i3^2*i4*i5+4*i1^2*i3^2*i5^2+2*i1^2*i3*i4^3+6*i1^2*i3*i4^2*i5+6*i1^2*i3*i4*i5^2+2*i1^2*i3*i5^3+2*i1^2*i4^3*i5+4*i1^2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*i1*i3*i5^2+i1*i4^3+3*i1*i4^2*i5+3*i1*i4*i5^2+i1*i5^3+4*i2^2*i3*i4+4*i2^2*i3*i5+4*i2^2*i4*i5+4*i2*i3^2*i4+4*i2*i3^2*i5+4*i2*i3*i4^2+4*i2*i3*i5^2+4*i2*i4^2*i5+4*i2*i4*i5^2+4*i3^2*i4*i5+4*i3*i4^2*i5+4*i3*i4*i5^2

What is the best strategy using Maple(latest version)? In a previous, less complicated example, the polynomial could be not be factored in a single expression, but I was succesfull to factor it in multiple factors.

kind regards,

Harry Garst


 

> 

restart

> 

with(PDEtools)

> 

with(plots)

> 

P__r := .71; lambda := 1.0; K__r := 1.0; S__r := .5; m := .5; M := sqrt(10.0); `ϰ` := .5; Omega := sqrt(5.0); Gr := 6.0; Gm := 5.0; S__c := .22

> 

PDE := {diff(phi(x, t), t) = (diff(phi(x, t), x, x))/S__c-K__r*phi(x, t)+S__r*(diff(theta(x, t), x, x)), diff(theta(x, t), t) = lambda*(diff(theta(x, t), x, x))/P__r, diff(u(x, t), t) = diff(u(x, t), x, x)-M^2*(u(x, t)-m*w(x, t))/(m^2+1)-u(x, t)/`ϰ`-2*Omega^2*w(x, t)+Gr*theta(x, t)+Gm*phi(x, t), diff(w(x, t), t) = diff(w(x, t), x, x)+M^2*(m*u(x, t)-w(x, t))/(m^2+1)-w(x, t)/`ϰ`+2*Omega^2*u(x, t)}

{diff(phi(x, t), t) = 4.545454545*(diff(diff(phi(x, t), x), x))-1.0*phi(x, t)+.5*(diff(diff(theta(x, t), x), x)), diff(theta(x, t), t) = 1.408450704*(diff(diff(theta(x, t), x), x)), diff(u(x, t), t) = diff(diff(u(x, t), x), x)-9.999999999*u(x, t)-5.999999996*w(x, t)+6.0*theta(x, t)+5.0*phi(x, t), diff(w(x, t), t) = diff(diff(w(x, t), x), x)+14.00000000*u(x, t)-9.999999999*w(x, t)}

(1)

``

> 

IBC := {phi(0, t) = 1, phi(9, t) = 0, phi(x, 0) = 0, theta(0, t) = 1, theta(9, t) = 0, theta(x, 0) = 0, u(0, t) = t, u(9, t) = 0, u(x, 0) = 0, w(0, t) = 0, w(9, t) = 0, w(x, 0) = 0}

> 

sol := pdsolve(PDE, IBC, numeric, spacestep = 0.1e-1)

_m2167514531200

(2)
> 

p1 := sol:-plot(t = .3, color = red); p2 := sol:-plot(t = .5, color = gold); p3 := sol:-plot(t = .7, color = purple); p4 := sol:-plot(t = 1., color = green); plots[display]({p1, p2, p3, p4})

 
> 

q1, q2, q3, q4 := seq(eval(u(x, t), sol:-value(t = t0, output = listprocedure)), t0 = [.3, .5, .7, 1]); plot([q1, q2, q3, q4], 0 .. 10, color = [red, gold, purple, green])

 
> 

p1 := sol:-plot(t = 1, S__c = .1, color = red); p2 := sol:-plot(t = 1, S__c = .2, color = gold); p3 := sol:-plot(t = 1, S__c = .3, color = purple); p4 := sol:-plot(t = 1, S__c = .4, color = green); plots[display]({p1, p2, p3, p4})

Error, (in plot/options2d) unexpected option: .22 = .1

 

Error, (in plot/options2d) unexpected option: .22 = .2

 

Error, (in plot/options2d) unexpected option: .22 = .3

 

Error, (in plot/options2d) unexpected option: .22 = .4

 

 
> 

q1, q2, q3, q4 := seq(eval(diff(u(0, t), t), sol:-value(t = t0, output = listprocedure)), t0 = [.3, .5, .7, 1]); plot([q1, q2, q3, q4], 0 .. 10, color = [red, gold, purple, green])

Error, (in plot) procedure expected, as range contains no plotting variable

 

``


 

Download pde_baru.mwpde_baru.mw

Dear Prof DRs ,Please see the attachments

how to PLOT PDE IBCS for different  Sc , Pr, Gr, Gm at fixed t? Also for Nusselt (theta prime)  ,skin friction (f double prime)?

sys*{A2+D2 = 0, B1*sin(192*K1)+D1 = 0, 3.383*B2*K1+C2 = 0, B1*K1^2*sin(192*K1)+11.444689*A2*K1^2*cos(568.344*K1)+11.444689*B2*K1^2*sin(568.344*K1) = 0, A2*cos(568.344*K1)+B2*sin(568.344*K1)+168*C2+D2 = 0, -3.383*A2*K1*sin(568.344*K1)+3.383*B2*K1*cos(568.344*K1)+C2-B1*K1*cos(192*K1) = 0};
     /                                                               
sys { A2 + D2 = 0, B1 sin(192 K1) + D1 = 0, 3.383 B2 K1 + C2 = 0, B1 
     \                                                               

    2                              2                
  K1  sin(192 K1) + 11.444689 A2 K1  cos(568.344 K1)

                    2                      
   + 11.444689 B2 K1  sin(568.344 K1) = 0, 

  A2 cos(568.344 K1) + B2 sin(568.344 K1) + 168 C2 + D2 = 0, 
-3.383 A2 K1 sin(568.344 K1) + 3.383 B2 K1 cos(568.344 K1) + C2

                          \ 
   - B1 K1 cos(192 K1) = 0 }
                          / 
fsolve(sys*{A2, B1, B2, C2, D1, D2});
Error, (in fsolve) number of equations, 1, does not match number of variables, 7

E_dislocated_bar.mws

I wish to make the letter E from a previous program of the letter F - which seemed to work perfectly.  I've added the base arm to the F - with it looking like the letter Fand trailing base.  Further comments in the program.  Tags are polygon, patchnogrid, LINE, animation  Help please. 

cos(440*2*pi*t)+cos(554*2*pi*t)+cos(659*2*pi*t)

How to turn the above row into complex exponential Fourier series?

Hello,

How to write the Newton's method and Bisection method in Maple of a function depending on a parameter ? The goal is to solve the equation F(y, eta) = 0 and find the root y(eta) using the Newton's method or Bisection method. An example is attached. 

Thank you

First time maple user here,

I have a set of equations, as follows

u_o = u-(diff(v(x), x)) . y-(diff(w(x), x)) . z

v__o = v-phi . z

w__o = w+phi . y

 

where u,v,w are all differentiable w.r.t. x,y,z. I want to evaluate the partial derivative of each of these three expressions w.r.t. x,y,z.

For example, epsilon = Diff(u__o,x) (this is supposed to be a partial derivative)

When I try epsilon = diff(uo, x), i get this epsilon = -(diff(v(x), x, x)) . y-(diff(w(x), x, x)) . z

which is evaluating u as a constant but not giving me Diff(u,x)

when I try using convert((D(uo))(x), diff), I get diff(u(x), x)-(diff(diff((v(x))(x), x), x)) . y(x)-(diff((v(x))(x), x)) . (diff(y(x), x))-(diff(diff((w(x))(x), x), x)) . z(x)-(diff((w(x))(x), x)) . (diff(z(x), x))

which doesn't know that Diff(y,x)=0

How can I evaluate these expressions appropriately?

Any help will be greatly appreciated!

 

Dear all,

 

I am saving a logplot as :

plotsetup(jpeg, plotoutput = "/Users/test.jpg", plotoptions = "quality=200,height=1100, width=1500"); display(logplot(x^2-3, x = 0 .. 100), legendstyle = [font = [bold, "TimesNewRoman", 30], location = right], thickness = 4, font = [bold, "TimesNewRoman", 30]); plotsetup("inline", plotoutput = "terminal", plotoptions = "quality=100,height=1000, width=1500")

and the output is the plot attached.

test.jpg

This is my problem: I do not want the y-axis tickmarks to be shown as .1 e2, .1e3, ...

I would like them to be 10^2, 10^3, ...

Please remember that I need them to be saved like this because the quality is much better than when you export the plot directly.

Can someone help me, please?

Hi!

Looking the Maple's help, I see that the command "isolve"  tries to solve an equations   over the integers. Then, given m>1 and t in the interval [0,1], How can used this command to find an integer j>=1 such that (j-1)/m<=t<j/m. That is, fin j such that t belongs to the interval [(j-1)/m,j/m].

 

Thanks in advance for your comments and help.

Hello,

I have to compare a lot of sample pairs with the TwoSampleTTest. I need only the pvalue for a cross table. It is possible to extract the pvalue of the TwoSampleTTest?

Many thanks!

This is an example, the program gave me functions _F as outputs and i want to see what F is.

This is an example.

Thanks.

This is an application of the previous posts
https://www.mapleprimes.com/posts/209057-Procedure-For-Expanding-Tensor-Product

I have a fourth version of the ExpandQop that will expand automaticaly the power of
quantum tensor product. This is just a minor change to the procedure.

Now here is an application for all this that will help understanding a little about
quantum computing. This is the classical concept of quantum teleportation.

You will need to run the above mentionned file and uncomment the save line in the file
before running the example.

LL
 

> 

######################################################################
# NOTICE                                                             #
# Author: Louis Lamarche                                             #
#         Institute of Research of Hydro-Quebec (IREQ)               #
#         Science des données et haute performance                   #
#         2018, March 7                                              #
#                                                                    #
# Function name: ExpandQop (x)                                       #
#       Purpose: Compute the tensor product of two quantum           #
#                operators in Dirac notations                        #
#      Argument: x: a quantum operator                               #
#  Improvements: Manage all +, -, *, /, ^, mod  operations           #
#                in the argument. Manages multiple tensor products   #
#                like A*B*C*F                                        #
#       Version: 3                                                   #
#                                                                    #
#  Copyrigth(c) Hydro-Quebec.                                        #
#        Note 1: Permission to use this softwate is granted if you   #
#                acknowledge its author and copyright                #
#        Note 2: Permission to copy this softwate is granted if you  #
#                leave this 21 lines notice intact. Thank you.       #
######################################################################
restart;

> 

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

[mathematicalnotation = true]

(1)
> 

Setup(unitaryoperators={I,U,X,Y,Z,H,HI,CNOT,CnotI});
Setup(noncommutativeprefix={q,beta,psi});

[unitaryoperators = {CNOT, CnotI, H, HI, I, U, X, Y, Z}]

 

[noncommutativeprefix = {beta, psi, q}]

(2)
> 

Setup(bracketrules= { %Bracket(%Bra(q0), %Ket(q0))=1,
                      %Bracket(%Bra(q1), %Ket(q1))=1,
                      %Bracket(%Bra(q1), %Ket(q0))=0,
                      %Bracket(%Bra(q0), %Ket(q1))=0
                    });

[bracketrules = {%Bracket(%Bra(q0), %Ket(q0)) = 1, %Bracket(%Bra(q0), %Ket(q1)) = 0, %Bracket(%Bra(q1), %Ket(q0)) = 0, %Bracket(%Bra(q1), %Ket(q1)) = 1}]

(3)
> 

####################################################################################
# Load the procedure and set the required global variables
#
read "ExpandQop.m": optp:=op(0,Ket(q0)*Ket(q1)): optpx:= op(0,(Ket(q0)+Ket(q1))^2):
#
####################################################################################

> 

#
# Pauli operators
#
print("Pauli gates");
I:=Ket(q0)*Bra(q0)+Ket(q1)*Bra(q1);        # = sigma[0]
X:=Ket(q1)*Bra(q0)+Ket(q0)*Bra(q1);        # = sigma[1] = sigma[x]
Y:=-i*Ket(q1)*Bra(q0)+i*Ket(q0)*Bra(q1);   # = sigma[2] = sigma[y]
Z:=Ket(q0)*Bra(q0)-Ket(q1)*Bra(q1);        # = sigma[3] = sigma[z]

"Pauli gates"

 

Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

 

Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))

 

-I*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))+I*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))

 

Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))-Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

(4)
> 

##############################
# Defining the Hadamard gate #
##############################
print("Hadamard gate");
H:= Ket(q0)*Bra(q0)/sqrt(2)+Ket(q0)*Bra(q1)/sqrt(2)+Ket(q1)*Bra(q0)/sqrt(2)-Ket(q1)*Bra(q1)/sqrt(2);

"Hadamard gate"

 

(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q0))+(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q0), Physics:-Bra(q1))+(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q0))-(1/2)*2^(1/2)*Physics:-`*`(Physics:-Ket(q1), Physics:-Bra(q1))

(5)
> 

# This is usefull to represent a 2 qubits system
# A more general approach is needed for a n qubit system.
DefineStates:=proc()
    Ket(q00):=Ket(q0)*Ket(q0);  Ket(q01):=Ket(q0)*Ket(q1);
    Ket(q10):=Ket(q1)*Ket(q0);  Ket(q11):=Ket(q1)*Ket(q1);
    Bra(q00):=Dagger(Ket(q00)); Bra(q01):=Dagger(Ket(q01));
    Bra(q10):=Dagger(Ket(q10)); Bra(q11):=Dagger(Ket(q11));
    return;
    end proc:
UndefineStates:=proc()
    Ket(q00):='Ket(q00)'; Ket(q01):='Ket(q01)';
    Ket(q10):='Ket(q10)'; Ket(q11):='Ket(q11)';
    Bra(q00):='Bra(q00)'; Bra(q01):='Bra(q01)';
    Bra(q10):='Bra(q10)'; Bra(q11):='Bra(q11)';
    return;
    end proc:

> 

####################################
# Defining the CNOT gate (2 qubits)
####################################
print("CNOT gate");
CNOT:=Ket(q00)*Bra(q00)+ Ket(q01)*Bra(q01)+ Ket(q11)*Bra(q10)+Ket(q10)*Bra(q11);
DefineStates();
'CNOT'=CNOT;

"CNOT gate"

 

Physics:-`*`(Physics:-Ket(q00), Physics:-Bra(q00))+Physics:-`*`(Physics:-Ket(q01), Physics:-Bra(q01))+Physics:-`*`(Physics:-Ket(q11), Physics:-Bra(q10))+Physics:-`*`(Physics:-Ket(q10), Physics:-Bra(q11))

 

CNOT = Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Bra(q0), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Bra(q1), Physics:-Bra(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Bra(q0), Physics:-Bra(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Bra(q1), Physics:-Bra(q1))

(6)
> 

###########################
# Defining the Bell states
###########################
Ket(beta,x,y)='CNOT.(((H.Ket(x)))*Ket(y))';
Ket(beta00):=CNOT.(Expand((H.Ket(q0)))*Ket(q0));
Ket(beta01):=CNOT.(Expand((H.Ket(q0)))*Ket(q1));
Ket(beta10):=CNOT.(Expand((H.Ket(q1)))*Ket(q0));
Ket(beta11):=CNOT.(Expand((H.Ket(q1)))*Ket(q1));

Physics:-Ket(beta, x, y) = Physics:-`.`(CNOT, Physics:-`*`(Physics:-`.`(H, Physics:-Ket(x)), Physics:-Ket(y)))

 

(1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1)))

 

(1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0)))

 

-(1/2)*2^(1/2)*(-Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0))+Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1)))

 

(1/2)*2^(1/2)*(Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1))-Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0)))

(7)
> 

##########################################################
# Quantum teleportation
# Reference: Quantum Computation and Quantum Information
#            10th Anniversary Edition
#            Michael A. Nielsen & Isaac L. Chuang
#            Cambridge University Press, Cambridge 2010
#            pp 25-28
##########################################################
print("State to be teleported");
Ket(psi) := a*Ket(q0)+b*Ket(q1);
print("Step 1: Compute the tensor product of the state to be teleported with ", 'Ket(beta00)');
Ket(psi[0])='Ket(psi)'*'Ket(beta00)';
Ket(psi[0]):=Expand(Ket(psi)*Ket(beta00));
print("This is a 3 qubits state");
#######
print("Step 2: Pass these 3 qubits through a  CNOT*I  operator");
'CnotI'='CNOT*I';
CnotI:=ExpandQop(Expand(CNOT*I)):
#
# To see what the CNOTI operator looks like
#
# print("CNOTI=");
# print(op(1,CNOTI)+op(2,CNOTI)+op(3,CNOTI)+op(4,CNOTI));
# print(op(5,CNOTI)+op(6,CNOTI)+op(7,CNOTI)+op(8,CNOTI));
'Ket(psi[1])'='CnotI.Ket(psi[0])';
Ket(psi[1]):=Expand(CnotI.Ket(psi[0]));
#######
print("Step 3: Pass these 3 qubits through an Haldamard*I  operator");
'HalI'='H*I';
HalI:=ExpandQop(Expand(H*I)):
#
# To see what the Haldamard*I operator looks like
#
# print("HalI=");
# print(op(1,HalI)+op(2,HalI)+op(3,HalI)+op(4,HalI));
# print(op(5,HalI)+op(6,HalI)+op(7,HalI)+op(8,HalI));
'Ket(psi[2])'='HalI.Ket(psi[1])';
Ket(psi[2]):=Expand(HalI.Ket(psi[1]));
 

"State to be teleported"

 

a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

 

"Step 1: Compute the tensor product of the state to be teleported with ", Physics:-Ket(beta00)

 

Physics:-Ket(psi[0]) = Physics:-`*`(Physics:-Ket(psi), Physics:-Ket(beta00))

 

(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1))

 

"This is a 3 qubits state"

 

"Step 2: Pass these 3 qubits through a  CNOT*I  operator"

 

CnotI = Physics:-`*`(CNOT, I)

 

Physics:-Ket(psi[1]) = Physics:-`.`(CnotI, Physics:-Ket(psi[0]))

 

(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*2^(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q0))+(1/2)*2^(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1))

 

"Step 3: Pass these 3 qubits through an Haldamard*I  operator"

 

HalI = Physics:-`*`(H, I)

 

Physics:-Ket(psi[2]) = Physics:-`.`(HalI, Physics:-Ket(psi[1]))

 

(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q0), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q0), Physics:-Ket(q1), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q0), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q1), Physics:-Ket(q1), Physics:-Ket(q0))

(8)
> 

UndefineStates();
print("Using contracted names for the first two qubits");
Ket(q00)*Bra(q0)*Bra(q0)='I';
Ket(q01)*Bra(q0)*Bra(q1)='I';
Ket(q10)*Bra(q1)*Bra(q0)='I';
Ket(q11)*Bra(q1)*Bra(q1)='I';
'Ket(psi[2])'=Ket(q00)*Bra(q0)*Bra(q0).Ket(psi[2])+
              Ket(q01)*Bra(q0)*Bra(q1).Ket(psi[2])+
              Ket(q10)*Bra(q1)*Bra(q0).Ket(psi[2])+
              Ket(q11)*Bra(q1)*Bra(q1).Ket(psi[2]);

"Using contracted names for the first two qubits"

 

Physics:-`*`(Physics:-Ket(q00), Physics:-Bra(q0), Physics:-Bra(q0)) = I

 

Physics:-`*`(Physics:-Ket(q01), Physics:-Bra(q0), Physics:-Bra(q1)) = I

 

Physics:-`*`(Physics:-Ket(q10), Physics:-Bra(q1), Physics:-Bra(q0)) = I

 

Physics:-`*`(Physics:-Ket(q11), Physics:-Bra(q1), Physics:-Bra(q1)) = I

 

Physics:-Ket(psi[2]) = (1/2)*a*Physics:-`*`(Physics:-Ket(q00), Physics:-Ket(q0))+(1/2)*b*Physics:-`*`(Physics:-Ket(q00), Physics:-Ket(q1))+(1/2)*a*Physics:-`*`(Physics:-Ket(q01), Physics:-Ket(q0))-(1/2)*b*Physics:-`*`(Physics:-Ket(q01), Physics:-Ket(q1))+(1/2)*a*Physics:-`*`(Physics:-Ket(q10), Physics:-Ket(q1))+(1/2)*b*Physics:-`*`(Physics:-Ket(q10), Physics:-Ket(q0))+(1/2)*a*Physics:-`*`(Physics:-Ket(q11), Physics:-Ket(q1))-(1/2)*b*Physics:-`*`(Physics:-Ket(q11), Physics:-Ket(q0))

(9)
> 

print("Rewriting this result by hand");
'Ket(psi[2])'=(Ket(q00)*(a*Ket(q0)+b*Ket(q1))+
               Ket(q01)*(a*Ket(q0)-b*Ket(q1))+
               Ket(q10)*(a*Ket(q1)+b*Ket(q0))+
               Ket(q11)*(a*Ket(q1)-b*Ket(q0)))/2;

"Rewriting this result by hand"

 

Physics:-Ket(psi[2]) = (1/2)*Physics:-`*`(Physics:-Ket(q00), a*Physics:-Ket(q0)+b*Physics:-Ket(q1))+(1/2)*Physics:-`*`(Physics:-Ket(q01), a*Physics:-Ket(q0)-b*Physics:-Ket(q1))+(1/2)*Physics:-`*`(Physics:-Ket(q10), a*Physics:-Ket(q1)+b*Physics:-Ket(q0))+(1/2)*Physics:-`*`(Physics:-Ket(q11), a*Physics:-Ket(q1)-b*Physics:-Ket(q0))

(10)
> 

DefineStates();
print("If Alice measures 00 Bob does noting");
''I'.   '2*Bra(q00).Ket(psi[2])'' =  I.   2*Bra(q00).Ket(psi[2]);
print("If Alice measures 01 Bob applies the X gate");
''X'.   '2*Bra(q01).Ket(psi[2])'' =  X.   2*Bra(q01).Ket(psi[2]);
print("If Alice measures 10 Bob applies the Z gate");
''Z'.   '2*Bra(q10).Ket(psi[2])'' =  Z.   2*Bra(q10).Ket(psi[2]);
print("If Alice measures 11 Bob applies the X gate and then the Z gate");
''Z'.'X'. '2*Bra(q11).Ket(psi[2])'' =  Z.X. 2*Bra(q11).Ket(psi[2]);

"If Alice measures 00 Bob does noting"

 

Physics:-`.`('I', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q00)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

 

"If Alice measures 01 Bob applies the X gate"

 

Physics:-`.`('X', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q01)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

 

"If Alice measures 10 Bob applies the Z gate"

 

Physics:-`.`('Z', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q10)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

 

"If Alice measures 11 Bob applies the X gate and then the Z gate"

 

Physics:-`.`('Z', 'X', 'Physics:-`.`(Physics:-`*`(2, Physics:-Bra(q11)), Physics:-Ket(psi[2]))') = a*Physics:-Ket(q0)+b*Physics:-Ket(q1)

(11)
> 

 


 

Download QuantumTeleportation.mw

 

 

First 886 887 888 889 890 891 892 Last Page 888 of 2263