Single Qubit Gates - Qiskit
文章推薦指數: 80 %
The Pauli Gates · Digression: The X, Y & Z-Bases · The Hadamard Gate · Digression: Measuring in Different Bases · The P-gate · The I, S and T-gates · The General U- ... Documentation Community Learn Overview LearnQuantumComputationusingQiskit LearnQuantumComputationusingQiskit WhatisQuantum? 0. Prerequisites 0.1 SettingUpYourEnvironment 0.2 PythonandJupyterNotebooks 1. QuantumStatesandQubits 1.1 Introduction 1.2 TheAtomsofComputation 1.3 RepresentingQubitStates 1.4 SingleQubitGates 1.5 TheCaseforQuantum 2. MultipleQubitsandEntanglement 2.1 Introduction 2.2 MultipleQubitsandEntangledStates 2.3 PhaseKickback 2.4 MoreCircuitIdentities 2.5 ProvingUniversality 2.6 ClassicalComputationonaQuantumComputer 3. QuantumProtocolsandQuantumAlgorithms 3.1 DefiningQuantumCircuits 3.2 Deutsch-JozsaAlgorithm 3.3 Bernstein-VaziraniAlgorithm 3.4 Simon'sAlgorithm 3.5 QuantumFourierTransform 3.6 QuantumPhaseEstimation 3.7 Shor'sAlgorithm 3.8 Grover'sAlgorithm 3.9 QuantumCounting 3.10 QuantumWalkSearchAlgorithm 3.11 QuantumTeleportation 3.12 SuperdenseCoding 3.13 QuantumKeyDistribution 4. QuantumAlgorithmsforApplications 4.1 AppliedQuantumAlgorithms 4.1.1 SolvingLinearSystemsofEquationsusingHHL 4.1.2 SimulatingMoleculesusingVQE 4.1.3 SolvingcombinatorialoptimizationproblemsusingQAOA 4.1.4 SolvingSatisfiabilityProblemsusingGrover'sAlgorithm 4.1.5 Hybridquantum-classicalNeuralNetworkswithPyTorchandQiskit 4.2 ImplementationsofRecentQuantumAlgorithms 4.2.1 VariationalQuantumLinearSolver 4.2.2 QuantumImageProcessing-FRQIandNEQRImageRepresentations 4.2.3 QuantumEdgeDetection-QHEDAlgorithmonSmallandLargeImages 4.2.4 SolvingtheTravellingSalesmanProblemusingPhaseEstimation 5. InvestigatingQuantumHardwareUsingQuantumCircuits 5.1 IntroductiontoQuantumErrorCorrectionusingRepetitionCodes 5.2 MeasurementErrorMitigation 5.3 RandomizedBenchmarking 5.4 MeasuringQuantumVolume 5.5 TheDensityMatrix&MixedStates 6. InvestigatingQuantumHardwareUsingMicrowavePulses 6.1 CalibratingQubitswithQiskitPulse 6.2 AccessingHigherEnergyStates 6.3 IntroductiontoTransmonPhysics 6.4 CircuitQuantumElectrodynamics 6.5 ExploringtheJaynes-CummingsHamiltonianwithQiskitPulse 6.6 MeasuringtheQubitac-StarkShift 6.7 HamiltonianTomography 7. QuantumComputingLabs Lab1.QuantumCircuits Lab2.QuantumMeasurement Lab3.AccuracyofQuantumPhaseEstimation Lab4.IterativeQuantumPhaseEstimation Lab5.ScalableShor’sAlgorithm Lab6.Grover'ssearchwithanunknownnumberofsolutions Lab7.QuantumSimulationasaSearchAlgorithm Lab8.QuantumErrorCorrection 8. Appendix 8.1 LinearAlgebra 8.2 Qiskit 9. Games&Demos HelloQiskitGame EstimatingPiUsingQuantumPhaseEstimationAlgorithm LocalRealityandtheCHSHInequality QuantumCoinGame VariationalQuantumRegression InteractivityIndex English Japanese OnThisPage OpeninIBMQuantumLab DownloadasJupyterNotebook ContributeonGithub Trythenewtextbookbeta ThenewQiskitTextbookbetaisnowavailable. Tryitoutnow SingleQubitGates Intheprevioussectionwelookedatallthepossiblestatesaqubitcouldbein.Wesawthatqubitscouldberepresentedby2Dvectors,andthattheirstatesarelimitedtotheform: $$|q\rangle=\cos{\tfrac{\theta}{2}}|0\rangle+e^{i\phi}\sin{\tfrac{\theta}{2}}|1\rangle$$Where$\theta$and$\phi$arerealnumbers.Inthissectionwewillcovergates,theoperationsthatchangeaqubitbetweenthesestates.Duetothenumberofgatesandthesimilaritiesbetweenthem,thischapterisatriskofbecomingalist.Tocounterthis,wehaveincludedafewdigressionstointroduceimportantideasatappropriateplacesthroughoutthechapter. Contents ThePauliGates 1.1TheX-Gate 1.2TheY&Z-Gates Digression:TheX,Y&Z-Bases TheHadamardGate Digression:MeasuringinDifferentBases TheP-gate TheI,SandT-gates 6.1TheI-Gate 6.2TheS-Gate 6.3TheT_Gate TheGeneralU-gate InTheAtomsofComputationwecameacrosssomegatesandusedthemtoperformaclassicalcomputation.Animportantfeatureofquantumcircuitsisthat,betweeninitialisingthequbitsandmeasuringthem,theoperations(gates)arealwaysreversible!Thesereversiblegatescanberepresentedasmatrices,andasrotationsaroundtheBlochsphere. fromqiskitimportQuantumCircuit,assemble,Aer frommathimportpi,sqrt fromqiskit.visualizationimportplot_bloch_multivector,plot_histogram sim=Aer.get_backend('aer_simulator') 1.ThePauliGatesYoushouldbefamiliarwiththePaulimatricesfromthelinearalgebrasection.Ifanyofthemathshereisnewtoyou,youshouldusethelinearalgebrasectiontobringyourselfuptospeed.WewillseeherethatthePaulimatricescanrepresentsomeverycommonlyusedquantumgates. 1.1TheX-GateTheX-gateisrepresentedbythePauli-Xmatrix: $$X=\begin{bmatrix}0&1\\1&0\end{bmatrix}=|0\rangle\langle1|+|1\rangle\langle0|$$Toseetheeffectagatehasonaqubit,wesimplymultiplythequbit’sstatevectorbythegate.WecanseethattheX-gateswitchestheamplitudesofthestates$|0\rangle$and$|1\rangle$: $$X|0\rangle=\begin{bmatrix}0&1\\1&0\end{bmatrix}\begin{bmatrix}1\\0\end{bmatrix}=\begin{bmatrix}0\\1\end{bmatrix}=|1\rangle$$ Reminder:MultiplyingVectorsbyMatrices(Clickheretoexpand) Matrixmultiplicationisageneralisationoftheinnerproductwesawinthelastchapter.Inthespecificcaseofmultiplyingavectorbyamatrix(asseenabove),wealwaysgetavectorback: $$M|v\rangle=\begin{bmatrix}a&b\\c&d\\\end{bmatrix}\begin{bmatrix}v_0\\v_1\\\end{bmatrix} =\begin{bmatrix}a\cdotv_0+b\cdotv_1\\c\cdotv_0+d\cdotv_1\end{bmatrix}$$ Inquantumcomputing,wecanwriteourmatricesintermsofbasisvectors: $$X=|0\rangle\langle1|+|1\rangle\langle0|$$ Thiscansometimesbeclearerthanusingaboxmatrixaswecanseewhatdifferentmultiplicationswillresultin: $$ \begin{aligned} X|1\rangle&=(|0\rangle\langle1|+|1\rangle\langle0|)|1\rangle\\ &=|0\rangle\langle1|1\rangle+|1\rangle\langle0|1\rangle\\ &=|0\rangle\times1+|1\rangle\times0\\ &=|0\rangle \end{aligned} $$ Infact,whenweseeaketandabramultipliedlikethis: $$|a\rangle\langleb|$$ thisiscalledtheouterproduct,whichfollowstherule: $$ |a\rangle\langleb|= \begin{bmatrix} a_0b_0^*&a_0b_1^*&\dots&a_0b_n^*\\ a_1b_0^*&\ddots&&\vdots\\ \vdots&&\ddots&\vdots\\ a_nb_0^*&\dots&\dots&a_nb_n^*\\ \end{bmatrix} $$ where$*$denotesthecomplexconjugation.WecanseethisdoesindeedresultintheX-matrixasseenabove: $$ |0\rangle\langle1|+|1\rangle\langle0|= \begin{bmatrix}0&1\\0&0\\\end{bmatrix}+ \begin{bmatrix}0&0\\1&0\\\end{bmatrix}= \begin{bmatrix}0&1\\1&0\\\end{bmatrix}=X $$ InQiskit,wecancreateashortcircuittoverifythis: #Let'sdoanX-gateona|0>qubit qc=QuantumCircuit(1) qc.x(0) qc.draw() Let'sseetheresultoftheabovecircuit.Note:Hereweuseplot_bloch_multivector()whichtakesaqubit'sstatevectorinsteadoftheBlochvector. #Let'sseetheresult qc.save_statevector() qobj=assemble(qc) state=sim.run(qobj).result().get_statevector() plot_bloch_multivector(state) Wecanindeedseethestateofthequbitis$|1\rangle$asexpected.Wecanthinkofthisasarotationby$\pi$radiansaroundthex-axisoftheBlochsphere.TheX-gateisalsooftencalledaNOT-gate,referringtoitsclassicalanalogue. 1.2TheY&Z-gatesSimilarlytotheX-gate,theY&ZPaulimatricesalsoactastheY&Z-gatesinourquantumcircuits: $$Y=\begin{bmatrix}0&-i\\i&0\end{bmatrix}\quad\quad\quad\quadZ=\begin{bmatrix}1&0\\0&-1\end{bmatrix}$$$$Y=-i|0\rangle\langle1|+i|1\rangle\langle0|\quad\quadZ=|0\rangle\langle0|-|1\rangle\langle1|$$And,unsurprisingly,theyalsorespectivelyperformrotationsby$\pi$aroundtheyandz-axisoftheBlochsphere. Belowisawidgetthatdisplaysaqubit’sstateontheBlochsphere,pressingoneofthebuttonswillperformthegateonthequbit: #Runthecodeinthiscelltoseethewidget fromqiskit_textbook.widgetsimportgate_demo gate_demo(gates='pauli') InQiskit,wecanapplytheYandZ-gatestoourcircuitusing: qc.y(0)#DoY-gateonqubit0 qc.z(0)#DoZ-gateonqubit0 qc.draw() 2.Digression:TheX,Y&Z-Bases Reminder:EigenvectorsofMatrices(Clickheretoexpand) Wehaveseenthatmultiplyingavectorbyamatrixresultsinavector: $$ M|v\rangle=|v'\rangle\leftarrow\text{newvector} $$ Ifwechosetherightvectorsandmatrices,wecanfindacaseinwhichthismatrixmultiplicationisthesameasdoingamultiplicationbyascalar: $$ M|v\rangle=\lambda|v\rangle $$ (Above,$M$isamatrix,and$\lambda$isascalar).Foramatrix$M$,anyvectorthathasthispropertyiscalledaneigenvectorof$M$.Forexample,theeigenvectorsoftheZ-matrixarethestates$|0\rangle$and$|1\rangle$: $$ \begin{aligned} Z|0\rangle&=|0\rangle\\ Z|1\rangle&=-|1\rangle \end{aligned} $$ Sinceweusevectorstodescribethestateofourqubits,weoftencallthesevectorseigenstatesinthiscontext.Eigenvectorsareveryimportantinquantumcomputing,anditisimportantyouhaveasolidgraspofthem. YoumayalsonoticethattheZ-gateappearstohavenoeffectonourqubitwhenitisineitherofthesetwostates.Thisisbecausethestates$|0\rangle$and$|1\rangle$arethetwoeigenstatesoftheZ-gate.Infact,thecomputationalbasis(thebasisformedbythestates$|0\rangle$and$|1\rangle$)isoftencalledtheZ-basis.Thisisnottheonlybasiswecanuse,apopularbasisistheX-basis,formedbytheeigenstatesoftheX-gate.Wecallthesetwovectors$|+\rangle$and$|-\rangle$: $$|+\rangle=\tfrac{1}{\sqrt{2}}(|0\rangle+|1\rangle)=\tfrac{1}{\sqrt{2}}\begin{bmatrix}1\\1\end{bmatrix}$$$$|-\rangle=\tfrac{1}{\sqrt{2}}(|0\rangle-|1\rangle)=\tfrac{1}{\sqrt{2}}\begin{bmatrix}1\\-1\end{bmatrix}$$AnotherlesscommonlyusedbasisisthatformedbytheeigenstatesoftheY-gate.Thesearecalled: $$|\circlearrowleft\rangle,\quad|\circlearrowright\rangle$$Weleaveitasanexercisetocalculatethese.Thereareinfactaninfinitenumberofbases;toformone,wesimplyneedtwoorthogonalvectors.TheeigenvectorsofbothHermitianandunitarymatricesformabasisforthevectorspace.Duetothisproperty,wecanbesurethattheeigenstatesoftheX-gateandtheY-gateindeedformabasisfor1-qubitstates(readmoreaboutthisinthelinearalgebrapageintheappendix) QuickExercises Verifythat$|+\rangle$and$|-\rangle$areinfacteigenstatesoftheX-gate. Whateigenvaluesdotheyhave? FindtheeigenstatesoftheY-gate,andtheirco-ordinatesontheBlochsphere. UsingonlythePauli-gatesitisimpossibletomoveourinitializedqubittoanystateotherthan$|0\rangle$or$|1\rangle$,i.e.wecannotachievesuperposition.Thismeanswecanseenobehaviourdifferenttothatofaclassicalbit.Tocreatemoreinterestingstateswewillneedmoregates! 3.TheHadamardGateTheHadamardgate(H-gate)isafundamentalquantumgate.ItallowsustomoveawayfromthepolesoftheBlochsphereandcreateasuperpositionof$|0\rangle$and$|1\rangle$.Ithasthematrix: $$H=\tfrac{1}{\sqrt{2}}\begin{bmatrix}1&1\\1&-1\end{bmatrix}$$Wecanseethatthisperformsthetransformationsbelow: $$H|0\rangle=|+\rangle$$$$H|1\rangle=|-\rangle$$ThiscanbethoughtofasarotationaroundtheBlochvector[1,0,1](thelinebetweenthex&z-axis),orastransformingthestateofthequbitbetweentheXandZbases. Youcanplayaroundwiththesegatesusingthewidgetbelow: #Runthecodeinthiscelltoseethewidget fromqiskit_textbook.widgetsimportgate_demo gate_demo(gates='pauli+h') QuickExercise WritetheH-gateastheouterproductsofvectors$|0\rangle$,$|1\rangle$,$|+\rangle$and$|-\rangle$. Showthatapplyingthesequenceofgates:HZH,toanyqubitstateisequivalenttoapplyinganX-gate. FindacombinationofX,ZandH-gatesthatisequivalenttoaY-gate(ignoringglobalphase). 4.Digression:MeasuringinDifferentBasesWehaveseenthattheZ-axisisnotintrinsicallyspecial,andthatthereareinfinitelymanyotherbases.Similarlywithmeasurement,wedon’talwayshavetomeasureinthecomputationalbasis(theZ-basis),wecanmeasureourqubitsinanybasis. Asanexample,let’strymeasuringintheX-basis.Wecancalculatetheprobabilityofmeasuringeither$|+\rangle$or$|-\rangle$: $$p(|+\rangle)=|\langle+|q\rangle|^2,\quadp(|-\rangle)=|\langle-|q\rangle|^2$$Andaftermeasurement,thesuperpositionisdestroyed.SinceQiskitonlyallowsmeasuringintheZ-basis,wemustcreateourownusingHadamardgates: #CreatetheX-measurementfunction: defx_measurement(qc,qubit,cbit): """Measure'qubit'intheX-basis,andstoretheresultin'cbit'""" qc.h(qubit) qc.measure(qubit,cbit) returnqc initial_state=[1/sqrt(2),-1/sqrt(2)] #Initializeourqubitandmeasureit qc=QuantumCircuit(1,1) qc.initialize(initial_state,0) x_measurement(qc,0,0)#measurequbit0toclassicalbit0 qc.draw() Inthequickexercisesabove,wesawyoucouldcreateanX-gatebysandwichingourZ-gatebetweentwoH-gates: $$X=HZH$$StartingintheZ-basis,theH-gateswitchesourqubittotheX-basis,theZ-gateperformsaNOTintheX-basis,andthefinalH-gatereturnsourqubittotheZ-basis.WecanverifythisalwaysbehaveslikeanX-gatebymultiplyingthematrices: $$ HZH= \tfrac{1}{\sqrt{2}}\begin{bmatrix}1&1\\1&-1\end{bmatrix} \begin{bmatrix}1&0\\0&-1\end{bmatrix} \tfrac{1}{\sqrt{2}}\begin{bmatrix}1&1\\1&-1\end{bmatrix} = \begin{bmatrix}0&1\\1&0\end{bmatrix} =X $$Followingthesamelogic,wehavecreatedanX-measurementbytransformingfromtheX-basistotheZ-basisbeforeourmeasurement.Sincetheprocessofmeasuringcanhavedifferenteffectsdependingonthesystem(e.g.somesystemsalwaysreturnthequbitto$|0\rangle$aftermeasurement,whereasothersmayleaveitasthemeasuredstate),thestateofthequbitpost-measurementisundefinedandwemustresetitifwewanttouseitagain. ThereisanotherwaytoseewhytheHadamardgateindeedtakesusfromtheZ-basistotheX-basis.SupposethequbitwewanttomeasureintheX-basisisinthe(normalized)state$a|0\rangle+b|1\rangle$.TomeasureitinX-basis,wefirstexpressthestateasalinearcombinationof$|+\rangle$and$|-\rangle$.Usingtherelations$|0\rangle=\frac{|+\rangle+|-\rangle}{\sqrt{2}}$and$|1\rangle=\frac{|+\rangle-|-\rangle}{\sqrt{2}}$,thestatebecomes$\frac{a+b}{\sqrt{2}}|+\rangle+\frac{a-b}{\sqrt{2}}|-\rangle$.ObservethattheprobabilityamplitudesinX-basiscanbeobtainedbyapplyingaHadamardmatrixonthestatevectorexpressedinZ-basis. Let’snowseetheresults: qobj=assemble(qc)#AssemblecircuitintoaQobjthatcanberun counts=sim.run(qobj).result().get_counts()#Dothesimulation,returningthestatevector plot_histogram(counts)#Displaytheoutputonmeasurementofstatevector Weinitializedourqubitinthestate$|-\rangle$,butwecanseethat,afterthemeasurement,wehavecollapsedourqubittothestate$|1\rangle$.Ifyourunthecellagain,youwillseethesameresult,sincealongtheX-basis,thestate$|-\rangle$isabasisstateandmeasuringitalongXwillalwaysyieldthesameresult. QuickExercises Ifweinitializeourqubitinthestate$|+\rangle$,whatistheprobabilityofmeasuringitinstate$|-\rangle$? UseQiskittodisplaytheprobabilityofmeasuringa$|0\rangle$qubitinthestates$|+\rangle$and$|-\rangle$(Hint:youmightwanttouse.get_counts()andplot_histogram()). TrytocreateafunctionthatmeasuresintheY-basis. MeasuringindifferentbasesallowsustoseeHeisenberg’sfamousuncertaintyprincipleinaction.HavingcertaintyofmeasuringastateintheZ-basisremovesallcertaintyofmeasuringaspecificstateintheX-basis,andviceversa.Acommonmisconceptionisthattheuncertaintyisduetothelimitsinourequipment,butherewecanseetheuncertaintyisactuallypartofthenatureofthequbit. Forexample,ifweputourqubitinthestate$|0\rangle$,ourmeasurementintheZ-basisiscertaintobe$|0\rangle$,butourmeasurementintheX-basisiscompletelyrandom!Similarly,ifweputourqubitinthestate$|-\rangle$,ourmeasurementintheX-basisiscertaintobe$|-\rangle$,butnowanymeasurementintheZ-basiswillbecompletelyrandom. Moregenerally:Whateverstateourquantumsystemisin,thereisalwaysameasurementthathasadeterministicoutcome. TheintroductionoftheH-gatehasallowedustoexploresomeinterestingphenomena,butwearestillverylimitedinourquantumoperations.Letusnowintroduceanewtypeofgate: 5.TheP-gateTheP-gate(phasegate)isparametrised,thatis,itneedsanumber($\phi$)totellitexactlywhattodo.TheP-gateperformsarotationof$\phi$aroundtheZ-axisdirection.Ithasthematrixform: $$ P(\phi)=\begin{bmatrix}1&0\\0&e^{i\phi}\end{bmatrix} $$Where$\phi$isarealnumber. YoucanusethewidgetbelowtoplayaroundwiththeP-gate,specify$\phi$usingtheslider: #Runthecodeinthiscelltoseethewidget fromqiskit_textbook.widgetsimportgate_demo gate_demo(gates='pauli+h+p') InQiskit,wespecifyaP-gateusingp(phi,qubit): qc=QuantumCircuit(1) qc.p(pi/4,0) qc.draw() YoumaynoticethattheZ-gateisaspecialcaseoftheP-gate,with$\phi=\pi$.Infacttherearethreemorecommonlyreferencedgateswewillmentioninthischapter,allofwhicharespecialcasesoftheP-gate: 6.TheI,SandT-gates6.1TheI-gateFirstcomestheI-gate(aka‘Id-gate’or‘Identitygate’).Thisissimplyagatethatdoesnothing.Itsmatrixistheidentitymatrix: $$ I=\begin{bmatrix}1&0\\0&1\end{bmatrix} $$Applyingtheidentitygateanywhereinyourcircuitshouldhavenoeffectonthequbitstate,soit’sinterestingthisisevenconsideredagate.Therearetwomainreasonsbehindthis,oneisthatitisoftenusedincalculations,forexample:provingtheX-gateisitsowninverse: $$I=XX$$Thesecond,isthatitisoftenusefulwhenconsideringrealhardwaretospecifya‘do-nothing’or‘none’operation. QuickExercise WhataretheeigenstatesoftheI-gate? 6.2TheS-gatesThenextgatetomentionistheS-gate(sometimesknownasthe$\sqrt{Z}$-gate),thisisaP-gatewith$\phi=\pi/2$.Itdoesaquarter-turnaroundtheBlochsphere.Itisimportanttonotethatunlikeeverygateintroducedinthischaptersofar,theS-gateisnotitsowninverse!Asaresult,youwilloftenseetheS†-gate,(also“S-dagger”,“Sdg”or$\sqrt{Z}^\dagger$-gate).TheS†-gateisclearlyanP-gatewith$\phi=-\pi/2$: $$S=\begin{bmatrix}1&0\\0&e^{\frac{i\pi}{2}}\end{bmatrix},\quadS^\dagger=\begin{bmatrix}1&0\\0&e^{-\frac{i\pi}{2}}\end{bmatrix}$$Thename"$\sqrt{Z}$-gate"isduetothefactthattwosuccessivelyappliedS-gateshasthesameeffectasoneZ-gate: $$SS|q\rangle=Z|q\rangle$$Thisnotationiscommonthroughoutquantumcomputing. ToaddanS-gateinQiskit: qc=QuantumCircuit(1) qc.s(0)#ApplyS-gatetoqubit0 qc.sdg(0)#ApplySdg-gatetoqubit0 qc.draw() 6.3TheT-gateTheT-gateisaverycommonlyusedgate,itisanP-gatewith$\phi=\pi/4$: $$T=\begin{bmatrix}1&0\\0&e^{\frac{i\pi}{4}}\end{bmatrix},\quadT^\dagger=\begin{bmatrix}1&0\\0&e^{-\frac{i\pi}{4}}\end{bmatrix}$$AswiththeS-gate,theT-gateissometimesalsoknownasthe$\sqrt[4]{Z}$-gate. InQiskit: qc=QuantumCircuit(1) qc.t(0)#ApplyT-gatetoqubit0 qc.tdg(0)#ApplyTdg-gatetoqubit0 qc.draw() Youcanusethewidgetbelowtoplayaroundwithallthegatesintroducedinthischaptersofar: #Runthecodeinthiscelltoseethewidget fromqiskit_textbook.widgetsimportgate_demo gate_demo() 7.TheU-gateAswesawearlier,theI,Z,S&T-gateswereallspecialcasesofthemoregeneralP-gate.Inthesameway,theU-gateisthemostgeneralofallsingle-qubitquantumgates.Itisaparametrisedgateoftheform: $$ U(\theta,\phi,\lambda)=\begin{bmatrix}\cos(\frac{\theta}{2})&-e^{i\lambda}\sin(\frac{\theta}{2})\\ e^{i\phi}\sin(\frac{\theta}{2})&e^{i(\phi+\lambda)}\cos(\frac{\theta}{2}) \end{bmatrix} $$Everygateinthischaptercouldbespecifiedas$U(\theta,\phi,\lambda)$,butitisunusualtoseethisinacircuitdiagram,possiblyduetothedifficultyinreadingthis. Asanexample,weseesomespecificcasesoftheU-gateinwhichitisequivalenttotheH-gateandP-gaterespectively. $$ \begin{aligned} U(\tfrac{\pi}{2},0,\pi)=\tfrac{1}{\sqrt{2}}\begin{bmatrix}1&1\\ 1&-1 \end{bmatrix}=H &\quad& U(0,0,\lambda)=\begin{bmatrix}1&0\\ 0&e^{i\lambda}\\ \end{bmatrix}=P \end{aligned} $$ #Let'shaveU-gatetransforma|0>to|+>state qc=QuantumCircuit(1) qc.u(pi/2,0,pi,0) qc.draw() #Let'sseetheresult qc.save_statevector() qobj=assemble(qc) state=sim.run(qobj).result().get_statevector() plot_bloch_multivector(state) Itshouldbeobviousfromthisthatthereareaninfinitenumberofpossiblegates,andthatthisalsoincludesRxandRy-gates,althoughtheyarenotmentionedhere.ItmustalsobenotedthatthereisnothingspecialabouttheZ-basis,exceptthatithasbeenselectedasthestandardcomputationalbasis.QiskitalsoprovidestheXequivalentoftheSandSdg-gatei.e.theSX-gateandSXdg-gaterespectively.Thesegatesdoaquarter-turnwithrespecttotheX-axisaroundtheBlocksphereandareaspecialcaseoftheRx-gate. BeforerunningonrealIBMquantumhardware,allsingle-qubitoperationsarecompileddownto$I$,$X$,$SX$and$R_{z}$.Forthisreasontheyaresometimescalledthephysicalgates. 8.AdditionalresourcesYoucanfindacommunity-createdcheat-sheetwithsomeofthecommonquantumgates,andtheirpropertieshere. importqiskit.tools.jupyter %qiskit_version_table VersionInformationQiskitSoftwareVersionQiskit0.27.0Terra0.17.4Aer0.8.2Ignis0.6.0Aqua0.9.2IBMQProvider0.14.0SysteminformationPython3.8.10|packagedbyconda-forge|(default,May112021,07:01:05) [GCC9.3.0]OSLinuxCPUs8Memory(Gb)31.40896224975586TueJul1302:37:132021UTC 〈RepresentingQubitStates TheCaseforQuantum〉
延伸文章資訊
- 16 Geometric representation of the z-basis and x-basis. The ...
Download scientific diagram | 6 Geometric representation of the z-basis and x-basis. The state of...
- 2Quantum computational universality of hypergraph states with ...
In this paper, we propose a universal hypergraph state that only needs Pauli-X and Z basis measur...
- 3basis sets
其中,N為歸一化常數,xb、yb、zb分別是原子核到電子的方向向量上x、y、z方向的 ... 內殼層(inner shell)1s:每個原子軌域(AO)以一個基底函數(basis functio...
- 4Quantum logic gate - Wikipedia
Quantum gates are unitary operators, and are described as unitary matrices relative to some basis...
- 5Qubit basis states - Quantum Inspire
Single-qubit computational basis states ... The two orthogonal z-basis states of a qubit are defi...