[{"url":"cheatsheets/","title":"Cheatsheets","tags":["welcome"],"text":"CheatsheetsGetting Started with Julia - live.Fastrack to Julia cheatsheet.MATLAB-Julia-Python comparative cheatsheet by QuantEcon groupPlots.jl cheatsheetTrainingMatSCIThinking ahead and creating reusable code (generic constraints).NET 2026How to Code in Quantum Machine Learning for Medical ApplicationsChemicalQDeviceMaterials Project SeminarsSpringer TrainingTools::: \n::: Development Tools & Languages Essential resources, frameworks, and languages for modern development.\n:::::: \n::: \nMDN Web Docs::: \nMDN Web Docs Comprehensive resource for web standards, HTML, CSS, and JavaScript\ndocumentation.\n:::\n:::::: \nW3Schools::: \nW3Schools Tutorials and references for web development languages and frameworks.\n:::\n:::::: \nIT Tools::: \nIT Tools Handy online tools for developers: encoders, decoders, formatters, and\nmore.\n:::\n:::::: \nReact::: \nReact A JavaScript library for building user interfaces, maintained by Meta.\n:::\n:::::: \nCodeSandbox::: \nCodeSandbox Online code editor and prototyping tool for rapid web development.\n:::\n:::::: \nGoLang::: \nGoLang Open-source programming language designed for simplicity and\nreliability.\n:::\n:::::: \nFastAPI::: \nFastAPI Modern, fast (high-performance) web framework for building APIs with\nPython 3.7+.\n:::\n:::::: \nAngular::: \nAngular Web application framework for building scalable single-page\napplications.\n:::\n:::::: \nKotlin::: \nKotlin Modern programming language targeting JVM, Android, JavaScript, and\nNative.\n:::\n:::::: \nRust::: \nRust A language empowering everyone to build reliable and efficient software.\n:::\n:::::: \nCargo::: \nCargo Rust’s package manager and build system for managing dependencies and\nprojects.\n:::\n:::::: \nRuby::: \nRuby Dynamic, open source programming language with a focus on simplicity and\nproductivity.\n:::\n:::::: \nPerl::: \nPerl Highly capable, feature-rich programming language with over 30 years of\ndevelopment.\n:::\n:::::: \nScala::: \nScala A hybrid functional and object-oriented programming language for the\nJVM.\n:::\n:::::: \nSwift::: \nSwift Powerful and intuitive programming language for macOS, iOS, watchOS, and\ntvOS.\n:::\n:::::: \nPython::: \nPython Official Python programming language site for downloads, docs, and\nresources.\n:::\n:::::: \nJupyter Notebooks::: \nJupyter Notebooks Interactive computing environment for creating and sharing code,\nequations, and visualizations.\n:::\n:::::: \nHugging Face CLI::: \nHugging Face CLI Command-line interface for managing models and datasets on Hugging Face\nHub.\n:::\n:::::: \nTensorFlow::: \nTensorFlow Open-source platform for machine learning and deep learning by Google.\n:::\n:::\n:::\n:::"},{"url":".","title":"index","tags":["homepage"],"text":""},{"url":"installation/","title":"Software installation","tags":["welcome"],"text":"First-time setup: Install Julia & PlutoText and pictures version:Step 1: Install Julia 1.8.2Go to https://julialang.org/downloads and download the current stable release, Julia 1.8.2, using the correct version for your operating system (Linux x86, Mac, Windows, etc).Step 2: Run JuliaAfter installing, make sure that you can run Julia. On some systems, this means searching for the “Julia 1.8.2” program installed on your computer; in others, it means running the command julia in a terminal. Make sure that you can execute 1 + 1:Make sure that you are able to launch Julia and calculate 1+1 before proceeding!Step 3: Install PlutoNext we will install the Pluto, the notebook environment that we will be using during the course. Pluto is a Julia programming environment designed for interactivity and quick experiments.Open the Julia REPL. This is the command-line interface to Julia, similar to the previous screenshot.Here you type Julia commands, and when you press ENTER, it runs, and you see the result.To install Pluto, we want to run a package manager command. To switch from Julia mode to Pkg mode, type ] (closing square bracket) at the julia> prompt:\njulia> ]\n\n(@v1.8) pkg>\nThe line turns blue and the prompt changes to pkg>, telling you that you are now in package manager mode. This mode allows you to do operations on packages (also called libraries).To install Pluto, run the following (case sensitive) command to add (install) the package to your system by downloading it from the internet.\nYou should only need to do this once for each installation of Julia:\n(@v1.8) pkg> add Pluto\nThis might take a couple of minutes, so you can go get yourself a cup of tea!You can now close the terminal.Step 4: Use a modern browser: Mozilla Firefox or Google ChromeWe need a modern browser to view Pluto notebooks with. Firefox and Chrome work best.Second time: Running Pluto & opening a notebookRepeat the following steps whenever you want to work on a project or homework assignment.Step 1: Start PlutoStart the Julia REPL, like you did during the setup. In the REPL, type:julia> using Pluto\n\njulia> Pluto.run()\nThe terminal tells us to go to http://localhost:1234/ (or a similar URL). Let’s open Firefox or Chrome and type that into the address bar.If you’re curious about what a Pluto notebook looks like, have a look at the Featured Notebooks. These notebooks are useful for learning some basics of Julia programming.If you want to hear the story behind Pluto, have a look a the JuliaCon presentation.If nothing happens in the browser the first time, close Julia and try again. And please let us know!Step 2a: Opening a notebook from the webThis is the main menu - here you can create new notebooks, or open existing ones. Our homework assignments will always be based on a template notebook, available in this GitHub repository. To start from a template notebook on the web, you can paste the URL into the blue box and press ENTER.For example, homework 0 is available here. Go to this page, and on the top right, click on the button that says “Edit or run this notebook”. From these instructions, copy the notebook link, and paste it into the box. Press ENTER, and select OK in the confirmation box.The first thing we will want to do is to save the notebook somewhere on our own computer; see below.Step 2b: Opening an existing notebook fileWhen you launch Pluto for the second time, your recent notebooks will appear in the main menu. You can click on them to continue where you left off.If you want to run a local notebook file that you have not opened before, then you need to enter its full path into the blue box in the main menu. More on finding full paths in step 3.Step 3: Saving a notebookWe first need a folder to save our homework in. Open your file explorer and create one.Next, we need to know the absolute path of that folder. Here’s how you do that in Windows, MacOS and Ubuntu.For example, you might have:C:\\Users\\fons\\Documents\\18S191_assignments\\ on Windows/Users/fons/Documents/18S191_assignments/ on MacOS/home/fons/Documents/18S191_assignments/ on UbuntuNow that we know the absolute path, go back to your Pluto notebook, and at the top of the page, click on “Save notebook…”.This is where you type the new path+filename for your notebook:Click Choose.Step 4: Sharing a notebookAfter working on your notebook (your code is autosaved when you run it), you will find your notebook file in the folder we created in step 3. This the file that you can share with others, or submit as your homework assignment to Canvas.\nconst run = f => f();\nrun(async () => {\nconst versions = await (await fetch(`https://julialang-s3.julialang.org/bin/versions.json`)).json()\nconst sortby = v => v.split(\"-\")[0].split(\".\").map(parseFloat).reduce((a,b) => a*10000 + b)\nconst version_names = Object.keys(versions).sort((a,b) => sortby(a) - sortby(b)).reverse()\nconst stable = version_names.find(v => versions[v].stable)\nconsole.log({stable})\nconst pkg_stable = /\\d+\\.\\d+/.exec(stable)[0]\ndocument.querySelectorAll(\"auto-julia-version\").forEach(el => {\n    console.log(el)\n    el.innerText = el.getAttribute(\"short\") == null ? stable : pkg_stable\n})\n});"},{"url":"logistics/","title":"Class logistics","tags":["welcome"],"text":"main a img {\n    width: 5rem;\n    margin: 1rem;\n}\nCourse logisticsDescribe here the logistics of your class.SitesAzure QuantumJupyter HubMLJ: Machine Learning Framework for JuliaTextbooks:The following textbooks provide resource material for this course:Quantum Mechanics for EngineersIntroduction to Computation and Programming Using Python: With Application to Understanding Data Guttag, John. 2nd ed. MIT Press, 2016. ISBN: 9780262529624."},{"url":"search/","title":"Search results","tags":[],"text":"window.init_search();SearchResults\nLoading..."},{"url":"assets/scripts/get_highlights/","title":"get_highlights","tags":[],"text":"if isempty get metadata \"homepage\" , \"highlights\", nothing else highlights data metadata \"homepage\" \"highlights\" htl \"\"\" div class \"highlights jumbotron\" div class \"carousel container\" div class \"carousel wrapper\" div class \"carousel track\" htl \"\"\" section class \"carousel slide\" div class \"content\" h2 x \"name\" h2 p x \"text\" p div div class \"preview\" img src \" x \"img\" \" div section \"\"\" for x in highlights data div div button class \"carousel btn prev\" aria label \"Previous slide\" & 10094 button button class \"carousel btn next\" aria label \"Next slide\" & 10095 button div class \"carousel dots\" htl \"\"\" button class \"dot i 1 ? \"active\" \"\" \" data slide \" i 1 \" aria label \"Go to slide i \" button \"\"\" for i in 1 length highlights data div div div \"\"\" end"},{"url":"assets/scripts/get_references/","title":"get_references","tags":[],"text":"if isempty get metadata \"homepage\" , \"references\", nothing else references let image get x, \"img\", nothing class \"no decoration\" desc get x, \"description\", get x, \"text\", \"\" title desc | string image nothing || isempty image ? nothing htl \"\"\" a title title class class href x \"url\" target \" blank\" h3 x \"name\" h3 img src image a \"\"\" end for x in metadata \"homepage\" \"references\" htl \"\"\" div class \"wide subjectscontainer\" h1 References h1 div class \"subjects\" references div div \"\"\" end "},{"url":"assets/scripts/get_subjects/","title":"get_subjects","tags":[],"text":"let sections metadata \"sidebar\" sections htl \"\"\" let input other page.input output other page.output name get output.frontmatter, \"title\", basename input.relative path desc get output.frontmatter, \"description\", nothing tags get output.frontmatter, \"tags\", String image get output.frontmatter, \"image\", nothing class \"no decoration\", \"tag replace x, \" \" \" \" \" for x in tags ..., image nothing || isempty image ? nothing htl \"\"\" a title desc class class href root url \" \" other page.url h3 name h3 img src image a \"\"\" end for other page in get collections, section id, pages , .pages \"\"\" for section id, section name in sections isempty sections ? nothing htl \"\"\" div class \"wide subjectscontainer\" h1 Subjects h1 div class \"subjects\" sections div div \"\"\" end"},{"url":"homework/hw1/","title":"sample homework","tags":["module2","track_julia","track_material","homeworks","pluto","PlutoTeachingTools"],"text":" A Pluto.jl notebook v0.19.25 frontmatter homework number \"1\" order \"2.5\" title \"sample homework\" tags \"module2\", \"track julia\", \"track material\", \"homeworks\", \"pluto\", \"PlutoTeachingTools\" layout \"layout.jlhtml\" description \"sample howework\" using Markdown using InteractiveUtils using PlutoTeachingTools, PlutoUI md\"\"\" Sample Homework This notebook showcases some of the features of `PlutoTeachingTools.jl` https github.com JuliaPluto PlutoTeachingTools.jl and how to use these to write homework assignment in Pluto. \"\"\" tip md\"\"\"For a deeper tour of `PlutoTeachingTools.jl`, check their documentation https juliapluto.github.io PlutoTeachingTools.jl example.html \"\"\" md\"\"\" Useful functionalities `PlutoTeachingTools.jl` has some functions like `correct`, `still missing`, here a few demoes \"\"\" correct still missing keep working keep working md\"you can also give custom text to the boxes\" hint md\"this is a hint, hover the box to unblur the text\" md\"\"\" Exercise 1 a simple exercise Replace missing with the value `1`. \"\"\" x missing if ismissing x still missing elseif x 1 && x isa Int correct elseif x 1 && x isa Int b1 almost md\"\"\"Your variable has the right value, but it's not quite the right answer. Read carefully the instructions\"\"\" b2 hint md\"\"\"What type should the value of x be?\"\"\" md\"\"\" b1 b2 \"\"\" else keep working md\"\"\"That is not the right answer Keep trying \"\"\" end md\"\"\" here is a short demo of how it looks like when the student tries to solve the exercise \"\"\" Resource \"https user images.githubusercontent.com 49938764 249749643 8cc12de3 2b50 4182 b95d 686c2c18332c.mov\", width 500, autoplay \"\", loop \"\" md\"\"\" Exercise 2 Write a function called `myfun` that takes as input an integer and returns its square. Define a variable called `y` and assign `myfun 3 ` to it. \"\"\" let if isdefined myfun func not defined myfun else test values 1, 2, 3, 4, 5 msg1 correct for t in test values if myfun t t^2 msg1 keep working md\"Test failed for input t, expected t^2 , but got myfun t \" break end end msg1 end end if isdefined y var not defined y elseif y 9 correct else keep working md\"Evaluated expression y y is incorrect.\" end md\"\"\" and here is a quick demo of the exercise in action \"\"\" Resource \"https user images.githubusercontent.com 49938764 249748007 d0b2d773 6b21 49d4 89db ad737af510fe.mov\", width 500, autoplay \"\", loop \"\" "},{"url":"parent1/mod1_add_material/add_markdown/","title":"Add markdown files","tags":["parent1_mod1","track_material","markdown","frontmatter"],"text":"Add markdown filesIf your lecture does not need to run code or use interactivity. You can write it as a markdown file.As an extra twist, you can evaluate julia code inside a $ symbol. For example,$(1 + 1)\nwill become2Add Front-matterFor each file, markdown or pluto, you will need to add a front-matter, which specifies the page metadata. For markdown files, the front-matter is specified at the top of the file between three dashes ---. For example, the front-matter of this file is---\ntitle: \"Add markdown file\"\norder: 1\nchapter: 1\nsection: 1\nlayout: \"md.jlmd\"\ntags: [\"parent1_mod1\", \"track_material\", \"markdown\", \"frontmatter\"]\n---\nYou will need to specify the following attributestitle: title of the pageorder: the position of the page in the module on the sidebar. Hint!: You can also use fractional numbers, e.g. 1.5. This can be handy for homeworks, so you can include the homework between the first and second lesson without messing up lessons counting.layout: set to \"md.jlmd\", unless you are using some custom layoutchapter and section (optional): used to number the page. If for example chapter=1 and section=2, the page will be displayed as 1.2 on the sidebar and page header.image (optional): link to summarizing image to display in the subjects section on the homepage. If left empty, the page wont be included in the subjects section. If no page has an image field in the front-matter, the subjects section is not displayed.description (optional): short description of the notebookyoutube_id (optional): youtube id of the video associated with the page. If included, the page header will embed the youtube video.homework_number: needed only for homeworks, the number of the homeworktags: list of keywords for the page. It should at least include the module name, as defined in _data/sidebar.jl to include the page in the sidebar. You can also associate pages to a given track by adding the track id, prefixed with track_ to the tags. For example, if you want to include the page in the julia track, add track_julia in the tags list.Markdown 101If you are not familiar with markdown, you can see for example here. Here is a quick and dirty cheatsheetUse # for headers, for example# Header\n## Subheader\n### Sub-sub-header\nYou can create links with the syntax[text](adddress)\nFor example the link to the mardown tutorial above was typed as[here](https://www.markdowntutorial.com/)\nYou can insert pictures with the syntax![optional alternative text](link-to-picture)\nfor example![](https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-logo-color.png)\nwill give"},{"url":"parent1/mod1_add_material/add_pluto/","title":"Add Pluto notebooks","tags":["parent1_mod1","track_julia","track_material","Pluto","PlutoUI"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 1 section 2 order 2 image \"https raw.githubusercontent.com fonsp Pluto.jl 580ab811f13d565cc81ebfa70ed36c84b125f55d demo plutodemo.gif\" title \"Add Pluto notebooks\" tags \"parent1 mod1\", \"track julia\", \"track material\", \"Pluto\", \"PlutoUI\" layout \"layout.jlhtml\" using Markdown using InteractiveUtils using PlutoTeachingTools, PlutoUI TableOfContents md\"\"\" Add Pluto notebooks Pluto.jl https plutojl.org is a revolutionary text editor for reactive and interactive programming. To start creating a Pluto notebook, open a terminal and launch Julia, then do ```julia using Pluto Pluto.run ``` This will launch a Pluto session, where you can write your notebook. To add the front matter, you can use Plut FrontmatterGUI, as the following short video clip shows. danger md\"For pluto notebooks, you will need to set layout to layout.jlhtml\" \"\"\" html\"\"\" video controls \"controls\" width \"800\" height \"600\" name \"Video Name\" source src \"https user images.githubusercontent.com 6933510 207080363 b912d591 f6f6 4522 a6fe 701e5ab04f0b.mov\" video \"\"\" md\"\"\" Pluto 101 Pluto is a notebook for Julia It is reactive , lightweight and has powerful interactivity tools . This will allow you to make your lesson material more engaging for students. Here are a few highlights of Pluto. tip md\" To learn more, check out Pluto featured notebooks https featured.plutojl.org , the JuliaCon video at the beginning of this notebook, or the presentations at PlutoCon 2021 https www.youtube.com playlist?list PLP8iPy9hna6T5sNOTeGdiqygHe 09geEW .\" Writing code in Pluto In Pluto code is written in cells, to add some code, simply create a new cell and type in. Each cell should contain 1 julia expression function definition, if statement, variable assignment, etc. . ```julia if rand 0.5 \"hi\" else \"there\" end ``` or ```julia a 1 ``` or ```julia function f return rand ^ 2 end ``` However , multiple expressions in the same cell are not allowed, for example ```julia a 1 b 2 a b ``` cannot be written in the same cell. You have two alternatives 1. Split it into multiple cells recommended to make reactivity better . 2. Wrap your staments inside a `begin ... end` or `let ... end` block. The difference is that the latter introduces a local scope, hence variables defined inside `let` are not visibles from outside. Reactivity Pluto is reactive This means that if you define a variable `a` in a cell, when you edit the variable value, all cells depending on that variable are automatically re evaluated. A few notes 1. As mentioned above, better to have a single variable assignment per cell, this will make the dependency graph slimmer and reactivity smoother. 2. Code modifying a given variable should be in the same cell, i.e. you cannot have two cells modifying the same variable. Here is a summarizing demo \"\"\" Resource \"https raw.githubusercontent.com fonsp Pluto.jl 580ab811f13d565cc81ebfa70ed36c84b125f55d demo plutodemo.gif\", width 350 md\"\"\" Built in environment Pluto is designed with reproducibility in mind To use packages registered in the Julia general registry, just type `using MyPackage` in some cells, as done at the beginning of this notebook. Pluto will automatically download the package The `Project.toml` and `Manifest.toml` what Julia uses to record all libraries, their versions and dependencies are stored inside the notebook, making it fully batteries included Resource \"https user images.githubusercontent.com 6933510 134823403 fbb79d7f dd3e 4712 b5d5 b48ad0770f13.gif\", width 400 \"\"\" md\"\"\" Interactivity Pluto has great support to make your notebooks interactive It allows you to associate variables with sliders and buttons that you can use to interactively change the result of the code. https user images.githubusercontent.com 6933510 136196607 16207911 53be 4abb b90e d46c946e6aaf.gif The easiest way to harness the power of Pluto interactivity is to use PlutoUI.jl https github.com juliapluto PlutoUI.jl , which is showcased in the next lecture https juliapluto.github.io mod2 add material plutoui showcase . \"\"\" "},{"url":"parent1/mod1_add_material/plutoui_showcase/","title":"PlutoUI showcase","tags":["parent1_mod1","track_julia","track_material","Pluto","PlutoUI","interactivity"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter \"1\" image \"https user images.githubusercontent.com 6933510 174067690 50c8128d 748b 4f50 8a76 2ce18166642b.png\" order \"3\" section \"3\" title \"PlutoUI showcase\" tags \"parent1 mod1\", \"track julia\", \"track material\", \"Pluto\", \"PlutoUI\", \"interactivity\" layout \"layout.jlhtml\" using Markdown using InteractiveUtils This Pluto notebook uses bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of bind gives bound variables a default value instead of an error . macro bind def, element quote local iv try Base.loaded modules Base.PkgId Base.UUID \"6e696c72 6542 2067 7265 42206c756150\" , \"AbstractPlutoDingetjes\" .Bonds.initial value catch b missing end local el esc element global esc def Core.applicable Base.get, el ? Base.get el iv el el end end using PlutoUI md\"\"\" PlutoUI.jl Pluto notebooks can use ` bind` to add interactivity to your notebook. It's a simple concept it uses the same reactivity that you have when editing code, except now you use sliders and buttons, instead of editing code. This notebook showcases some features of `PlutoUI.jl` , which allows you to easily add interactivity to your notebooks. This notebook is from Pluto featured notebooks https featured.plutojl.org , make sure to also check the others to learn more cool Pluto tricks \"\"\" md\"\"\" To use it in other notebooks Simply import the `PlutoUI` package, and Pluto's built in package manager takes care of the rest \"\"\" TableOfContents This is all you need to get a nice table of content md\"\"\" Basics \"\"\" md\" Slider\" bind x Slider 5 15 x md\"The first argument is a `Vector` or range. You can set the default value using a keyword argument \" bind y Slider 20 0.1 30, default 25 y md\"\"\" Scrubbable `Scrubbable` makes a number interactive, you can click and drag its value left or right. Try it in the text below \"\"\" md\"\"\" If Alice has bind a Scrubbable 20 apples, and she gives bind b Scrubbable 3 apples to Bob... \"\"\" md\"\"\" ...then Alice has a b apples left. \"\"\" md\"\"\" Use the Live Docs to learn more about `Scrubbable` \"\"\" md\" NumberField A `NumberField` can be used just like a `Slider`, it just looks different \" bind x different NumberField 0 100, default 20 md\" CheckBox\" bind z CheckBox z md\"Default value \" bind having fun CheckBox default true having fun having fun ? md\"🎈🎈\" md\"☕\" md\" TextField\" bind s TextField s md\"With a default value \" bind sentence TextField default \"te dansen omdat men leeft\" sentence md\"You can also create a multi line text box \" bind poem TextField 30, 3 , \"Je opent en sluit je armen,\\nMaar houdt niets vast.\\nHet is net zwemmen\" poem by Sanne de Kroon split poem, \"\\n\" md\" Select\" bind vegetable Select \"potato\", \"carrot\" vegetable bind favourite function Select sin, cos, tan, sqrt favourite function 2 md\"Instead of an array of values, you can also give an array of pairs , where the first item is the bound value, and the second item is displayed. \" bind fruit Select \"apple\" \"🍎\", \"melon\" \"🍉\" fruit md\"\"\" MultiSelect This widget allows the user to select multiple element by holding `Ctrl` `Cmd` while clicking a more items. \"\"\" bind vegetable basket MultiSelect \"potato\", \"carrot\", \"boerenkool\" vegetable basket md\"Just like `Select`, you can also give an array of pairs.\" md\"\"\" MultiCheckBox This widget allows the user to select multiple elements using checkboxes. \"\"\" bind fruit basket MultiCheckBox \"apple\", \"blueberry\", \"mango\" fruit basket md\"\"\" You can use `MultiSelect` and `MultiCheckBox` with any vector of objects, not just strings \"\"\" bind my functions MultiCheckBox sin, cos, tan f π for f in my functions md\"Just like `Select`, you can also give an array of pairs. See the Live Docs for `MultiCheckBox` for all the customization options \" md\" Button\" bind clicked Button \"Hello world\" clicked md\"\"\" Button as reactive trigger In the example above, any cell that references `clicked` will re evaluate when you click the button. This means that you can a button as a reactive trigger , by referencing its value in another cell. \"\"\" bind go Button \"Recompute\" let go md\"I am rand 1 15 years old \" end md\" FilePicker\" bind important document FilePicker important document md\"The file picker is useful if you want to show off your notebook on a dataset or image uploaded by the reader . It will work anywhere you don't access files using their path. The caveat is that large files might take a long time to get processed everything needs to pass through the browser. If you are using large datasets, a better option is to use `Select` to let the reader pick a filename. You can then read the file using `Base.read filename, type `\" md\" Extras\" md\" Clock\" bind t Clock t md\"You can set the interval `5.0` seconds , and disable the UI `true` \" bind t slow Clock 5.0, true t slow md\"You can use a `Clock` to drive an animation Or use it to repeat the same command at an interval just like with `Button`, you can reference a bound reactive variable without actually using it \" md\" DownloadButton\" md\"\"\" The download button is not an input element that you can ` bind` to, it's an output that you can use to get processed data from your notebook easily. The second argument is the output filename . \"\"\" DownloadButton poem, \"poem.txt\" DownloadButton 0x01, 0x02, 0x03 , \"secret data.bin\" md\"\"\" High level inputs \"\"\" md\"\"\" Confirm Normally, when you move a `Slider` ref or type in a `TextField` ref , all intermediate values are sent back to ` bind`. By wrapping an input element in `confirm`, you get a button to manually control when the value is sent , intermediate updates are hidden from Pluto. \"\"\" bind distance confirm Slider 1 100 distance md\"\"\" `confirm` can be wrapper around any input element to create a new one, including inputs from other packages, or inputs that you have made yourself \"\"\" md\"\"\" Combine This next high level component is a bit tricky, but very powerful Using `combine`, you can create a single input out of multiple existing ones In the example below, we create a new input, `wind speed input` . Notice that the list of wind directions is dynamic if you add a new direction, a 5th slider will appear \"\"\" import PlutoUI combine function wind speed input directions Vector return combine do Child inputs md\"\"\" name Child name, Slider 1 100 \"\"\" for name in directions md\"\"\" Wind speeds inputs \"\"\" end end bind speeds wind speed input \"North\", \"East\", \"South\", \"West\" speeds speeds.North md\"\"\" Use the Live Docs to learn more about `combine` and to see additional examples. 🙋 `combine` is very useful in combination with HypertextLiteral.jl https github.com MechanicalRabbit HypertextLiteral.jl , which you can learn using our JavaScript sample notebook. \"\"\" md\"\"\" Loading resources Notebooks use data from different places. For example, you use `Base.read` https docs.julialang.org en v1 base io network ~ text read filename%3A%3AAbstractString%2C%20String to access local data files inside your Julia code, and `Downloads.jl` https github.com JuliaLang Downloads.jl for remote data interwebs . `PlutoUI` helps you communicate with the person reading the notebook To get remote media URL inside your Markdown text , use `PlutoUI.Resource`. To get local media file inside your Markdown text , use `PlutoUI.LocalResource`. With media , we mean images , video and audio. We strongly recommend that you use remote media inside Pluto notebooks If your notebook uses local images, then those images will not show when someone else opens your notebook, unless they have the same images on their computer, at the exact same location. More on this later. \"\"\" md\"\"\" Resource If you just want to show images inside Markdown , you can use the built in syntax without `PlutoUI` ``` md\"Here is a dog https fonsp.com img doggoSmall.jpg \" ``` `PlutoUI.Resource` has some extra features specify image dimensions and spacing support for videos support for audio\"\"\" dog url \"https upload.wikimedia.org wikipedia commons thumb 1 15 Welsh Springer Spaniel.jpg 640px Welsh Springer Spaniel.jpg\" Resource dog url, width x x different t rex url \"https upload.wikimedia.org wikipedia commons transcoded 6 62 Meow.ogg Meow.ogg.mp3\" flower url \"https upload.wikimedia.org wikipedia commons 4 41 Sunflower Flower Opening Time Lapse.ogv\" md\"\"\"Hello I am a dog Resource dog url \"\"\" md\"\"\"And I sound like this Resource t rex url \"\"\" md\"\"\"This is my flower friend Resource flower url, width 200 \"\"\" md\" Attributes You can pass additional HTML attributes to `Resource`, these will be added to the element. For example \" md\"\"\" Resource dog url, width 20 Resource dog url, width 50 Resource dog url, width 100 Resource dog url, width 100, style \"filter grayscale 100% border 3px solid black \" \"\"\" Resource flower url, width 200, autoplay \"\", loop \"\" md\" YouTube, Vimeo, etc. If you use `Resource` for video, the URL has to point to a video file like `.mp4` or `.mov` . Popular video sites don't give you that link, instead, you can use their embed codes . You can find these inside the video player, by right clicking or using the menu buttons. You then use that inside an HTML block ``` html\\\"\\\"\\\" ~ paste embed code here ~ \\\"\\\"\\\" ``` You might need to change the `width` to `100%` to make it fit.\" html\"\"\" div style \"padding 56.25% 0 0 0 position relative \" iframe src \"https player.vimeo.com video 438210156\" style \"position absolute top 0 left 0 width 100% height 100% \" frameborder \"0\" allow \"autoplay fullscreen\" allowfullscreen iframe div script src \"https player.vimeo.com api player.js\" script \"\"\" md\" LocalResource not recommended The examples above use `Resource` to make media from a URL available inside Markdown. To use local files , simply replace `Resource` with `LocalResource` , and use a file path instead of a URL.\" html\" span style 'font family cursive color purple ' I really hope that this works span \" md\"\"\"Hello I am a dog LocalResource \"C \\\\Users\\\\fons\\\\Pictures\\\\hannes.jpg\" \"\"\" md\"\"\" html\" span style 'font family cursive color purple ' OOPS span \" , it didn't html\" br \" Here are two tips for getting local images to work correctly 1. Go to imgur.com https imgur.com and drag&drop the image to the page. Right click on the image, and select \"Copy image location\". You can now use the image like so ```PlutoUI.Resource \"https i.imgur.com SAzsMMA.jpg\" ``` 2. If your notebook is part of a git repository, place the image in the repository and use a relative path ```PlutoUI.LocalResource \".. images cat.jpg\" ``` \"\"\" md\" Why does it have to be so difficult? Pluto only stores code in the notebook file, not images. This minimal file format is very valuable, but it means that images need to be addressed , not stored. Addressing local files is fragile if someone else opens the notebook, or if you move the notebook to a different folder, that image file needs to be available at exactly the same path. This is difficult to do correctly, and if it works for you, it is hard to tell if it will work for someone else. Putting images online might be a hassle, but once it works, it will work everywhere The stateless nature of URLs means that the images will work regardless of how the notebook file is accessed, while keeping a minimal file format.\" md\" PlutoUI without Pluto Huh? Did you know that you can run Pluto notebooks without Pluto ? If your notebook is called `wow.jl`, then ```sh julia wow.jl ``` will run the notebook just fine. When you use ` bind`, your notebook can still run without Pluto Sort of. Normally, all bound variables are assigned the value `missing` when you run it elsewhere. However, the `PlutoUI` types have all been configured to assign a more sensible default value. For example, if your notebook contains ```julia bind x Slider 10 20 ``` and you run it without Pluto, then this statement simply assigns `x 10`. \" md\"`Pluto` and `PlutoUI` work independently of each other In fact, you could write a package with fun input elements, or add ` bind`able values to existing packages.\" md\" Appendix\" space html\" br br br \" space space space space space "},{"url":"parent1/mod2_quantum_gates/lesson_2_1_single_qubit_gates/","title":"Single-Qubit Gates: Pauli Gates","tags":["parent1_mod2","quantum_gates","single_qubit","pauli"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 2 section 1 order 1 image \"https raw.githubusercontent.com JuliaQuantumComputing QuantumTutorials.jl main assets pauli gates.png\" title \"Single Qubit Gates Pauli Gates\" tags \"parent1 mod2\", \"quantum gates\", \"single qubit\", \"pauli\" layout \"layout.jlhtml\" description \"Learn about Pauli X, Y, Z gates and their properties\" using Markdown using InteractiveUtils using PlutoUI, LinearAlgebra, Plots TableOfContents md\"\"\" Single Qubit Gates Pauli Gates Overview Single qubit gates are fundamental building blocks of quantum circuits. The Pauli gates X, Y, Z are among the most important and frequently used gates in quantum computing. Learning Objectives Understand the Pauli matrices and their properties Learn how Pauli gates act on quantum states Visualize gate operations on the Bloch sphere Implement Pauli gates and verify their properties \"\"\" md\"\"\" The Pauli Matrices The four Pauli matrices form a basis for all 2×2 Hermitian matrices Identity Gate I I \\begin pmatrix 1 & 0 \\\\ 0 & 1 \\end pmatrix Pauli X Gate NOT gate X \\begin pmatrix 0 & 1 \\\\ 1 & 0 \\end pmatrix Pauli Y Gate Y \\begin pmatrix 0 & i \\\\ i & 0 \\end pmatrix Pauli Z Gate Z \\begin pmatrix 1 & 0 \\\\ 0 & 1 \\end pmatrix \"\"\" md\"\"\" Properties of Pauli Gates All Pauli matrices share important properties 1. Hermitian σ† σ self adjoint 2. Unitary σ†σ I invertible 3. Involutory σ² I applying twice returns to original state 4. Eigenvalues 1 and 1 5. Anticommutation σᵢ, σⱼ 2δᵢⱼI for i ≠ j \"\"\" md\"\"\" Julia Implementation Let's define and verify the Pauli matrices \"\"\" begin Define Pauli matrices I gate 1 0 0 1 X gate 0 1 1 0 Y gate 0 im im 0 Z gate 1 0 0 1 Verify Hermitian property \"Pauli matrices are Hermitian σ† σ \" end begin hermitian check Dict \"X is Hermitian\" X gate ≈ X gate', \"Y is Hermitian\" Y gate ≈ Y gate', \"Z is Hermitian\" Z gate ≈ Z gate' md\"\"\" hermitian check \"\"\" end begin Verify Unitary property σ†σ I unitary check Dict \"X is Unitary\" X gate' X gate ≈ I gate, \"Y is Unitary\" Y gate' Y gate ≈ I gate, \"Z is Unitary\" Z gate' Z gate ≈ I gate md\"\"\" Unitary property σ†σ I unitary check \"\"\" end begin Verify Involutory property σ² I involutory check Dict \"X² I\" X gate^2 ≈ I gate, \"Y² I\" Y gate^2 ≈ I gate, \"Z² I\" Z gate^2 ≈ I gate md\"\"\" Involutory property σ² I involutory check \"\"\" end md\"\"\" Action on Computational Basis States Let's see how Pauli gates act on the computational basis states |0⟩ and |1⟩ \"\"\" begin Basis states ket 0 1 0 ket 1 0 1 Apply gates actions Dict \"X|0⟩\" X gate ket 0, \"X|1⟩\" X gate ket 1, \"Z|0⟩\" Z gate ket 0, \"Z|1⟩\" Z gate ket 1, \"Y|0⟩\" Y gate ket 0, \"Y|1⟩\" Y gate ket 1 Display results for gate action, result in actions println \" gate action result\" end md\"✓ Pauli gates flip transform basis states\" end "},{"url":"parent1/mod2_quantum_gates/lesson_2_2_hadamard_phase_gates/","title":"Hadamard and Phase Gates","tags":["parent1_mod2","quantum_gates","single_qubit","hadamard","phase"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 2 section 2 order 2 image \"https raw.githubusercontent.com JuliaQuantumComputing QuantumTutorials.jl main assets hadamard gates.png\" title \"Hadamard and Phase Gates\" tags \"parent1 mod2\", \"quantum gates\", \"single qubit\", \"hadamard\", \"phase\" layout \"layout.jlhtml\" description \"Master the Hadamard gate and phase gates\" using Markdown using InteractiveUtils using PlutoUI, LinearAlgebra, Plots TableOfContents md\"\"\" Hadamard and Phase Gates Overview The Hadamard gate and phase gates are essential for creating superposition and arbitrary rotations. Together with the Pauli gates, they form the basis for quantum programming. Learning Objectives Understand the Hadamard gate and superposition Learn phase gates S, T gates Apply gates to create quantum states Visualize operations on the Bloch sphere \"\"\" md\"\"\" The Hadamard Gate The Hadamard gate creates equal superposition from basis states H \\frac 1 \\sqrt 2 \\begin pmatrix 1 & 1 \\\\ 1 & 1 \\end pmatrix Key Properties H² I applying twice returns to original H†H I unitary Hermitian H† H \"\"\" begin Define Hadamard gate H 1 sqrt 2 1 1 1 1 Verify properties properties Dict \"H² I\" H^2 ≈ I, \"H is Hermitian\" H ≈ H', \"H is unitary\" H' H ≈ I for prop, result in properties println \" prop result\" end md\"Hadamard gate verified ✓\" end md\"\"\" Creating Superposition Applying the Hadamard gate to basis states creates equal superposition H|0⟩ | ⟩ \\frac 1 \\sqrt 2 |0⟩ |1⟩ H|1⟩ | ⟩ \\frac 1 \\sqrt 2 |0⟩ |1⟩ These are eigenstates of the X gate \"\"\" begin ket 0 1 0 ket 1 0 1 Apply Hadamard plus state H ket 0 | ⟩ minus state H ket 1 | ⟩ md\"\"\" Superposition states H|0⟩ plus state H|1⟩ minus state Both states have equal probability amplitudes 1 √2 ≈ 1 sqrt 2 \"\"\" end md\"\"\" Phase Gates Phase Gate S S \\begin pmatrix 1 & 0 \\\\ 0 & i \\end pmatrix Applies phase of π 2 to |1⟩ state S⁴ I period 4 T Gate T \\begin pmatrix 1 & 0 \\\\ 0 & e^ i\\pi 4 \\end pmatrix Applies phase of π 4 to |1⟩ state T⁸ I period 8 General Phase Gate P \\theta \\begin pmatrix 1 & 0 \\\\ 0 & e^ i\\theta \\end pmatrix Applies arbitrary phase θ to the |1⟩ state. \"\"\" begin Define phase gates S gate 1 0 0 im Phase of π 2 T gate 1 0 0 exp im π 4 Phase of π 4 Define general phase gate function phase gate θ return 1 0 0 exp im θ end Verify S⁴ I and T⁸ I verify S S gate^4 ≈ I verify T T gate^8 ≈ I md\"\"\" Phase Gate Verification S⁴ I verify S T⁸ I verify T \"\"\" end md\"\"\" Important Gate Combinations Z S² The Z gate can be expressed as two S gates Z S^2 \\begin pmatrix 1 & 0 \\\\ 0 & 1 \\end pmatrix \"\"\" begin Z gate 1 0 0 1 Z from S S gate^2 md\"\"\" Verification Z from definition Z gate S² Z from S Are they equal? Z gate ≈ Z from S \"\"\" end md\"\"\" Rotation Gates Any single qubit gate can be expressed as a rotation on the Bloch sphere R x \\theta e^ i\\theta X 2 \\begin pmatrix \\cos \\theta 2 & i\\sin \\theta 2 \\\\ i\\sin \\theta 2 & \\cos \\theta 2 \\end pmatrix R y \\theta e^ i\\theta Y 2 \\begin pmatrix \\cos \\theta 2 & \\sin \\theta 2 \\\\ \\sin \\theta 2 & \\cos \\theta 2 \\end pmatrix R z \\theta e^ i\\theta Z 2 \\begin pmatrix e^ i\\theta 2 & 0 \\\\ 0 & e^ i\\theta 2 \\end pmatrix \"\"\" "},{"url":"parent1/mod2_quantum_gates/lesson_2_3_multiqubit_gates/","title":"Multi-Qubit Gates: CNOT & Toffoli","tags":["parent1_mod2","quantum_gates","multi_qubit","entanglement"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 2 section 3 order 3 image \"https raw.githubusercontent.com JuliaQuantumComputing QuantumTutorials.jl main assets cnot gates.png\" title \"Multi Qubit Gates CNOT & Toffoli\" tags \"parent1 mod2\", \"quantum gates\", \"multi qubit\", \"entanglement\" layout \"layout.jlhtml\" description \"Learn about controlled gates and entanglement\" using Markdown using InteractiveUtils using PlutoUI, LinearAlgebra, Plots TableOfContents md\"\"\" Multi Qubit Gates CNOT & Toffoli Overview Multi qubit gates operate on multiple qubits and can create entanglement. The CNOT controlled NOT gate and Toffoli gate are the most important controlled gates in quantum computing. Learning Objectives Understand controlled quantum gates Master CNOT gate behavior and applications Learn the Toffoli gate CCX Create Bell states and entangled pairs \"\"\" md\"\"\" The CNOT Gate The CNOT Controlled NOT gate operates on 2 qubits Control qubit determines if operation happens Target qubit the operation applied to it The matrix representation control 0, target 1 \\text CNOT \\begin pmatrix 1 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 1 \\\\ 0 & 0 & 1 & 0 \\end pmatrix Action If control 1, flip target. Otherwise, do nothing. | Control | Target | Control' | Target' | | | | | | | 0 | 0 | 0 | 0 | | 0 | 1 | 0 | 1 | | 1 | 0 | 1 | 1 | | 1 | 1 | 1 | 0 | \"\"\" begin Define CNOT gate CNOT 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 Verify properties I2 Matrix 1.0I, 2, 2 I4 Matrix 1.0I, 4, 4 properties Dict \"CNOT² I\" CNOT^2 ≈ I4, \"CNOT is unitary\" CNOT' CNOT ≈ I4, \"CNOT determinant 1\" det CNOT ≈ 1.0 for prop, result in properties println \" prop result\" end md\"CNOT gate verified ✓\" end md\"\"\" Creating Entanglement with CNOT A famous use of CNOT is creating Bell states maximally entangled states Starting with |00⟩ 1. Apply H to first qubit → |0⟩ |1⟩ √2 ⊗ |0⟩ 2. Apply CNOT → |00⟩ |11⟩ √2 This is the Bell state Φ⁺ \"\"\" begin Define basis states ket 00 1, 0, 0, 0 |00⟩ ket 11 0, 0, 0, 1 |11⟩ Hadamard on first qubit H₁ ⊗ I₂ H1 I2 kron 1 1 1 1 . sqrt 2 , I2 Apply transformations intermediate H1 I2 ket 00 bell state CNOT intermediate md\"\"\" Creating Bell state Φ⁺ Initial state |00⟩ ket 00' After H⊗I round. intermediate, digits 4 ' After CNOT round. bell state, digits 4 ' This is maximally entangled \"\"\" end md\"\"\" Other Bell States The four Bell states form a complete orthonormal basis |\\Phi^ ⟩ \\frac 1 \\sqrt 2 |00⟩ |11⟩ |\\Phi^ ⟩ \\frac 1 \\sqrt 2 |00⟩ |11⟩ |\\Psi^ ⟩ \\frac 1 \\sqrt 2 |01⟩ |10⟩ |\\Psi^ ⟩ \\frac 1 \\sqrt 2 |01⟩ |10⟩ Bell states are fundamental to quantum teleportation and cryptography. \"\"\" md\"\"\" The Toffoli Gate CCX The Toffoli gate is a 3 qubit gate with two controls and one target Action If BOTH controls are 1, flip the target. The 8×8 matrix \\text Toffoli \\begin pmatrix 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\end pmatrix The Toffoli gate is reversible and universal for classical computing \"\"\" begin Define Toffoli CCX gate Toffoli 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 I8 Matrix 1.0I, 8, 8 Verify properties toffoli props Dict \"Toffoli² I\" Toffoli^2 ≈ I8, \"Toffoli is unitary\" Toffoli' Toffoli ≈ I8, \"Toffoli determinant 1\" det Toffoli ≈ 1.0 for prop, result in toffoli props println \" prop result\" end md\"Toffoli gate verified ✓\" end md\"\"\" Controlled U Gates Any single qubit gate U can be \"controlled\" \\text C U \\begin pmatrix I & 0 \\\\ 0 & U \\end pmatrix This applies U to the target only if control is |1⟩. Common examples CNOT C X controlled X CZ Controlled Z gate CS Controlled S gate \"\"\" "},{"url":"parent1/mod2_quantum_gates/lesson_2_4_universal_gate_sets/","title":"Universal Gate Sets","tags":["parent1_mod2","quantum_gates","universality","completeness"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 2 section 4 order 4 image \"https raw.githubusercontent.com JuliaQuantumComputing QuantumTutorials.jl main assets universal gates.png\" title \"Universal Gate Sets\" tags \"parent1 mod2\", \"quantum gates\", \"universality\", \"completeness\" layout \"layout.jlhtml\" description \"Understand quantum gate universality and completeness\" using Markdown using InteractiveUtils using PlutoUI, LinearAlgebra, Plots TableOfContents md\"\"\" Universal Gate Sets Overview A universal gate set is a collection of gates that can approximate any unitary operation to arbitrary precision. Understanding universality is key to knowing what quantum computers can do. Learning Objectives Understand gate universality and completeness Learn the Solovay Kitaev theorem Identify common universal gate sets Approximate arbitrary rotations \"\"\" md\"\"\" What is Gate Universality? A set of quantum gates is universal if 1. Any unitary operation on n qubits can be approximated 2. The approximation can be arbitrarily accurate 3. The gates in the set generate a dense subset of U 2ⁿ Key theorem Solovay Kitaev Theorem Any unitary gate U can be approximated using gates from a finite universal set G₁, G₂, ... with overhead \\text Depth O \\log^c 1 \\epsilon where ε is the desired accuracy and c ≈ 2 4. \"\"\" md\"\"\" Common Universal Gate Sets Set 1 H, T, CNOT Components Hadamard H Creates superposition T gate Phase rotation π 4 CNOT Creates entanglement Why universal H and T can approximate arbitrary single qubit rotations CNOT can entangle disentangle qubits Together can build any n qubit unitary Tradeoff T gate is hard to implement physically requires magic state distillation \"\"\" begin Define the universal set H, T, CNOT H 1 sqrt 2 1 1 1 1 T 1 0 0 exp im π 4 I2 Matrix 1.0I, 2, 2 I4 Matrix 1.0I, 4, 4 CNOT 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 md\"\"\" Universal Gate Set 1 H, T, CNOT This is the most commonly used set in quantum computing. \"\"\" end md\"\"\" Set 2 H, S, CNOT Components Hadamard H Superposition S gate Phase rotation π 2 CNOT Entanglement Limitation Not universal, but can approximate easily by using arbitrary rotation gates. Set 3 H, Toffoli Components Hadamard H Single qubit superposition Toffoli CCX 3 qubit gate Property Universal for quantum computing though less practical than H, T, CNOT Set 4 Any continuous 1 qubit rotations, CNOT Components Arbitrary Rₓ θ , Rᵧ θ , Rz θ rotations CNOT for multi qubit operations Property Inherently universal minimal approximation needed \"\"\" md\"\"\" Why These Gates? Necessity of Single Qubit Rotations Single qubit gates must be able to reach all points on the Bloch sphere. Any single qubit unitary can be written as U e^ i\\alpha \\begin pmatrix e^ i\\beta 2 \\cos \\gamma 2 & e^ i\\delta i\\beta 2 \\sin \\gamma 2 \\\\ e^ i\\delta i\\beta 2 \\sin \\gamma 2 & e^ i\\beta 2 \\cos \\gamma 2 \\end pmatrix This is a 3 parameter rotation the Bloch sphere is 3D . Necessity of Entanglement Multi qubit gates are essential for Creating entanglement CNOT, CZ Implementing quantum algorithms Achieving exponential speedup \"\"\" md\"\"\" Approximating Arbitrary Gates Example Approximating Rx π 8 using H, T One useful combination is \\text Rx \\pi 8 \\approx \\frac 1 \\sqrt 2 T H T^ \\dagger H This shows how to build rotations from discrete gates. The Solovay Kitaev Algorithm Algorithm to compile arbitrary gates into universal set 1. Start with target unitary U 2. Find good approximation in universal set 3. Recursively approximate the remainder 4. Depth grows as O log^c 1 ε This ensures quantum computers can simulate any unitary operation \"\"\" md\"\"\" Practical Considerations Physical Implementation Different quantum hardware supports different gate sets | Platform | Native Gates | Universal Set | | | | | | Superconducting | CX, RX, RZ | RX, RZ, CX | | Ion Trap | XX, RZ global | RX, RZ, XX | | Atomic | Ry, CZ | RY, CZ | | Photonic | Linear opt., nonlinear | Single qubit, 2 qubit | Decomposition Most high level languages Qiskit, Cirq automatically 1. Take user circuit with any gates 2. Decompose into hardware native universal set 3. Optimize the resulting circuit 4. Submit to hardware \"\"\" begin Example Decompose a gate into universal set Target gate arbitrary rotation Ry π 3 target angle π 3 Ry target cos target angle 2 sin target angle 2 sin target angle 2 cos target angle 2 Approximate using rotations Ry π 3 ≈ Rz α Ry β Rz γ for appropriate α, β, γ md\"\"\" Gate Decomposition Example Target Rᵧ π 3 Can be decomposed as product of single qubit rotations. \"\"\" end "},{"url":"parent1/mod2_quantum_gates/lesson_2_5_gate_decomposition/","title":"Gate Decomposition & Practice","tags":["parent1_mod2","quantum_gates","decomposition","exercises","projects"],"text":" A Pluto.jl notebook v0.19.25 frontmatter chapter 2 section 5 order 5 image \"https raw.githubusercontent.com JuliaQuantumComputing QuantumTutorials.jl main assets gate decomposition.png\" title \"Gate Decomposition & Practice\" tags \"parent1 mod2\", \"quantum gates\", \"decomposition\", \"exercises\", \"projects\" layout \"layout.jlhtml\" description \"Exercises and projects on gate decomposition\" using Markdown using InteractiveUtils using PlutoUI, LinearAlgebra, Plots TableOfContents md\"\"\" Gate Decomposition & Practice Exercises Overview This lesson consolidates knowledge about quantum gates through decomposition and practical exercises. You'll learn how to break down complex gates into simpler components. Learning Objectives Decompose complex gates into fundamental gates Compute equivalent gate representations Optimize circuit depth Solve real world gate problems \"\"\" md\"\"\" Gate Decomposition Fundamentals What is Gate Decomposition? Express a complex gate U as a product of simpler gates U G 1 G 2 \\cdots G n Goals 1. Use only gates native to hardware 2. Minimize circuit depth number of gates 3. Reduce two qubit gate count most expensive 4. Preserve numerical accuracy \"\"\" md\"\"\" Single Qubit Decompositions Euler Angle Decomposition Any single qubit unitary U can be written as U e^ i\\alpha R z \\beta R y \\gamma R z \\delta This is the ZYZ decomposition . Algorithm to find angles 1. Compute U a, b , c, d 2. α arg a arg d 3. β 2 arccos |a| 4. γ arg c arg a π 2 5. δ arg d arg a \"\"\" begin Function to extract Euler angles from a single qubit unitary function euler angles zyz U Extract angles from ZYZ decomposition a U 1,1 b U 1,2 c U 2,1 d U 2,2 alpha atan imag a , real a atan imag d , real d beta 2 acos abs a gamma atan imag c , real c atan imag a , real a π 2 delta atan imag d , real d atan imag a , real a return alpha, beta, gamma, delta end Example decompose Hadamard gate H 1 sqrt 2 1 1 1 1 alpha, beta, gamma, delta euler angles zyz H md\"\"\" Example Hadamard Decomposition Parameters radians, π multiples α round alpha π, digits 3 π β round beta π, digits 3 π γ round gamma π, digits 3 π δ round delta π, digits 3 π \"\"\" end md\"\"\" Verify Decomposition Let's verify we can reconstruct the original gate from angles R z \\delta R y \\gamma R z \\beta R y \\alpha This should equal the original matrix up to global phase . \"\"\" begin Define rotation matrices function Rz θ return exp im θ 2 0 0 exp im θ 2 end function Ry θ return cos θ 2 sin θ 2 sin θ 2 cos θ 2 end Reconstruct Hadamard from angles H reconstructed exp im alpha Rz delta Ry gamma Rz beta md\"\"\" Original Hadamard H Reconstructed round. H reconstructed, digits 6 Match? H ≈ H reconstructed \"\"\" end md\"\"\" Multi Qubit Decompositions CX Decomposition The CNOT gate can be decomposed as \\text CX I \\otimes H \\text CZ I \\otimes H where CZ is Controlled Z. This shows how to convert between different controlled gates. \"\"\" begin Define 2 qubit identity and Hadamard I2 1 0 0 1 H 1 sqrt 2 1 1 1 1 I ⊗ H I H kron I2, H CZ gate CZ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 CNOT gate CNOT original 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 Verify CNOT I⊗H CZ I⊗H CNOT from CZ I H CZ I H md\"\"\" CNOT from CZ Decomposition Original CNOT CNOT original Reconstructed I⊗H CZ I⊗H round. CNOT from CZ, digits 6 Verified? CNOT original ≈ CNOT from CZ \"\"\" end md\"\"\" Practice Problems Problem 1 Pauli Decompositions Decompose the following gates using Pauli matrices 1. X gate Express X as a product of other gates 2. Y gate Y iXZ verify this 3. Z gate Z S² verify this Problem 2 Superposition Circuits Create the state | ⟩ |0⟩ |1⟩ √2 using Only H gate H|0⟩ Using X and H H X H |0⟩ Find other equivalent sequences Problem 3 Bell State Creation Create each of the four Bell states and show their decompositions |Φ⁺⟩ |00⟩ |11⟩ √2 |Φ⁻⟩ |00⟩ |11⟩ √2 |Ψ⁺⟩ |01⟩ |10⟩ √2 |Ψ⁻⟩ |01⟩ |10⟩ √2 Find the gate sequences for each. Problem 4 Minimize Depth For the following gate sequence, find an equivalent shorter sequence H S H S H Hint Remember that S² Z and HZH X \"\"\" "},{"url":"parent1/mod2_quantum_gates/module_overview/","title":"Module 2: Quantum Gates","tags":["parent1_mod2","quantum_gates","introduction"],"text":"Module 2: Quantum GatesWelcome to Quantum Gates!In this module, you’ll master the fundamental building blocks of quantum circuits. Just as classical computers are built from logic gates (AND, OR, NOT), quantum computers are built from quantum gates.What You’ll LearnLesson 2.1: Single-Qubit Gates (Pauli Gates)Understand the Pauli matrices (X, Y, Z)Learn their mathematical propertiesSee how they transform quantum statesExplore eigenvalues and eigenvectorsLesson 2.2: Hadamard and Phase GatesMaster superposition with the Hadamard gateLearn phase gates (S, T) and their importanceUnderstand rotation gates on the Bloch sphereCreate arbitrary single-qubit statesLesson 2.3: Multi-Qubit Gates (CNOT & Toffoli)Explore controlled gates and their applicationsCreate entangled states (Bell states)Understand the CNOT (controlled-NOT) gateLearn the universal Toffoli gateLesson 2.4: Universal Gate SetsUnderstand what makes gates “universal”Learn the Solovay-Kitaev theoremCompare common universal setsSee how hardware implements universal gatesLesson 2.5: Gate Decomposition & PracticeBreak complex gates into simpler componentsMaster Euler angle decompositionsSolve comprehensive exercisesOptimize quantum circuitsModule Learning PathStart: Classical vs Quantum Computing\n  ↓\nLearn: Single-qubit Pauli gates (X, Y, Z)\n  ↓\nExplore: Hadamard and phase gates\n  ↓\nDiscover: Multi-qubit entanglement (CNOT, Toffoli)\n  ↓\nUnderstand: Universal gate sets and completeness\n  ↓\nPractice: Gate decomposition and optimization\n  ↓\nNext: Build quantum circuits (Module 3)\nKey ConceptsQuantum Gates are Unitary MatricesPreserve probability: U†U = IReversible operationsCan be measured and verifiedSingle-Qubit vs Multi-QubitSingle-qubit: Rotate state on Bloch sphereMulti-qubit: Create entanglement, scale complexityUniversality MattersNot all gates are universally compatibleHardware has native gate setsDecomposition is crucial for real devicesPrerequisitesBefore starting this module, you should be comfortable with:✓ Quantum superposition and entanglement (Module 1)✓ Linear algebra (matrices, eigenvalues)✓ Complex numbers✓ Julia basics or willingness to learnHow to Use This ModuleFor Each Lesson:Read the Theory: Understand the conceptsRun the Code: Execute Julia examples in PlutoExplore Interactively: Use sliders and visualizationsComplete Exercises: Practice with coding problemsExtend It: Modify code and experimentTime CommitmentTotal module time: 8-12 hoursPer lesson: 1.5-2.5 hoursSelf-paced: Go at your own speedCommon ApplicationsWhere Are Quantum Gates Used?Quantum AlgorithmsGrover’s search: Uses Hadamard and phase gatesShor’s algorithm: Uses many controlled gatesVQE: Uses parameterized rotation gatesQuantum HardwareIBM Quantum: Native {Rx, Rz, CX} gatesIon Traps: Native {Ry, XX} gatesPhotonic: Single-qubit + 2-qubit gatesError CorrectionStabilizer codes use controlled Pauli gatesSyndrome extraction uses CNOTResourcesTextbooksNielsen & Chuang, Quantum Computation and Quantum Information (Chapter 2)Preskill, Quantum Computing NISQ era and beyond (Lecture notes)Online ToolsIBM Quantum Composer - Interactive circuit builderQiskit - Python quantum computing frameworkCirq - Google’s quantum frameworkVideos3Blue1Brown Quantum ComputingIBM Quantum LearningModule 2 GoalsBy the end of this module, you will be able to:✓ Identify and apply common quantum gates✓ Create superposition and entangled states✓ Understand gate universality and completeness✓ Decompose complex gates into simple gates✓ Optimize circuits for different hardware✓ Write quantum circuits in JuliaLet’s Begin!Ready to dive in? Start with Lesson 2.1: Single-Qubit Gates and work your way through the module. Each lesson builds on previous concepts.Happy learning! 🎓"},{"url":"parent2/mod3_placeholder/","title":"Module 3: Placeholder","tags":["parent2_mod1","placeholder","coming_soon"],"text":"Module 3: PlaceholderThis module is currently under development. Content coming soon!What’s ComingMore advanced quantum computing topics and applications will be added here."},{"url":"parent2/mod4_coming_soon/","title":"Module 4: Coming Soon","tags":["parent2_mod2","placeholder","coming_soon"],"text":"Module 4: Coming SoonThis module is planned for a future update. Stay tuned!Coming FeaturesAdvanced topics and research frontiers in quantum computing will be featured here."}]