<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Javen Liang on Medium]]></title>
        <description><![CDATA[Stories by Javen Liang on Medium]]></description>
        <link>https://medium.com/@javenliang?source=rss-24e20460a3f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*C_zecg5BUICcfJwC.</url>
            <title>Stories by Javen Liang on Medium</title>
            <link>https://medium.com/@javenliang?source=rss-24e20460a3f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 14:26:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@javenliang/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Try to Explain Quantum Computing and Q# to Non-Physicists 3: Operations and Functions]]></title>
            <link>https://medium.com/@javenliang/try-to-explain-quantum-computing-and-q-to-non-physicists-3-operations-and-functions-1fa8eb738f5e?source=rss-24e20460a3f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fa8eb738f5e</guid>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Javen Liang]]></dc:creator>
            <pubDate>Mon, 02 Apr 2018 04:58:35 GMT</pubDate>
            <atom:updated>2018-04-02T04:58:35.626Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the last part of a three blog posts series of my attempt to explain Quantum Computing and Q# to my software development classmates who have no physics background. The goal of the series is to provide a very high level introduction to my classmates without delving too much into the underlying theories and mathematics. No knowledge of matrix required and hopefully nobody gets confused.</p><h3>Callable Types</h3><p>In my last blog post, I explained the Q# type model including the primitive types, array, tuple and user-defined types. However, there is one category I have not included, and that is the <em>callables</em>. Unlike other programming languages, which usually have one type of callable unit (method, procedure, function or etc.), Q# has two different callables — Operation and Function. The difference between operation and function is that operations are quantum subroutines containing quantum algorithm, while functions only contain classical codes. Qubits can only be allocated and processed within operations, but not functions.</p><p>All callables have the same basic signature, which is ( input =&gt; output ) or ( input -&gt; output ). The first one with =&gt; is used for operations and the second one with -&gt; is for functions. All callables have a single value for input and a single value as output. Multiple input/output values and no input/output are both accomplished with tuple. In the case of multiple input/output values, the input/output is a tuple of other types. Meanwhile, no input/output will have empty tuple, ( ), as input/output.</p><h3>Primitive Operations and Functions</h3><p>The Primitive namespace include some of the most basic and fundamental functions and operations in Q#, thus most Q# programs will have open Microsoft.Quantum.Primitive; following the initial namespace declaration.</p><h3>Single Qubit Operation</h3><p>Once a qubit is created in Q#, it can only be interacted directly with quantum operation we call quantum gates. Following are some examples of such operations.</p><h3>M</h3><p>M operation is the operation of measuring the state of a Qubit, and has the signature of ( Qubit =&gt; Result ). It will take a Qubit as input and return a output of type Result with a value of either One or Zero.</p><h3>Reset</h3><p>Reset operation, as the name suggests, is the operation to measure and reset the state of a Qubit, and has the signature of ( Qubit =&gt; ( ) ). It will take a Qubit as input, measure it and ensure it is in the state of Zero (if not, flip it to Zero). It is often used to reset the state of a Qubit for it to be safely released.</p><h3>I</h3><p>I operation is the identity operation for a Qubit and has the signature of ( Qubit =&gt; ( ) ). It is equivalent to identity operations in Mathematics such as a + 0, and a * 1, which resulting in no changes to the target. Thus the I operation will not cause any changes to the state of the Qubit it operate on.</p><h3>X</h3><p>X operation is also called Pauli-X gate or NOT gate and has the signature of ( Qubit =&gt; ( ) ). While in the last blog post I avoided to further introduce the Pauli types because of the significant background knowledge required, Pauli-X gate is relatively easy to understand because it simply flip the state of an input Qubit from Zero to One or One to Zero, hence the name NOT gate.</p><h3>H</h3><p>H operation is also known as Hadamard gate, named after mathematician Jacques Hadamard. It applies the Hadamard transformation to a Qubit and has the signature of ( Qubit =&gt; ( ) ). What Hadamard gate does is that it changes the state of a Qubit from being 100% Zero or 100% One, to a state where a measurement having equal probabilities of being Zero or One. Hence the Hadamard gate create a superposition, an important property for a Qubit. Applying two Hadamard gate back to back will return the Qubit to its original state.</p><h3>Multi-Qubit Operation</h3><p>There are also many operations in the Primitive namespace working with more than one Qubit at a time. Following are some examples.</p><h3>ResetAll</h3><p>As the name implied, ResetAll operation is the operation of applying multiple Reset at the same time, and it has the signature of ( Qubit[ ] =&gt; ( ) ). ResetAll operation takes an Array of Qubit as input, and applies Reset operation to every single Qubit within the Array. Just like Reset, it can be used to reset the states of a series of Qubit so that they can be safely released.</p><h3>MultiX</h3><p>Similar to ResetAll applying multiple Reset at the same time, MultiX operation is the operation of applying multiple X operation, and it has the signature of ( Qubit[ ] =&gt; ( ) ). MultiX operation takes an Array of Qubit as input, and applies X operation to every single Qubit within the Array.</p><h3>CNOT</h3><p>CNOT operation is also call controlled-NOT gate, and it has the signature of ( ( Qubit, Qubit ) =&gt; ( ) ). CNOT operation takes a pair of Qubit as input. The first Qubit is the control, while the second Qubit is the target. The state of the target will only be flipped into opposite state (NOT) if the control is measured to return the state of One, hence the name of controlled-NOT gate. CNOT is a very important operation as it is used to create many different quantum operations such as establishing quantum entanglement.</p><h3>CCNOT</h3><p>CCNOT operation is also called doubly controlled not, controlled-controlled-not, or Toffoli gate, and has the signature of ( ( Qubit, Qubit, Qubit ) =&gt; ( ) ). Similar to CNOT operation, CCNOT operations take in multiple Qubit and separate them as control and target. For CCNOT, the first two inputs are control, and the third is target. Only when both controls return One, will the target’s state be flipped (NOT).</p><h3>SWAP</h3><p>SWAP operation takes two Qubit as input and has the signature of ( ( Qubit, Qubit ) =&gt; ( ) ). As the name suggest, it swaps the states of the two Qubit.</p><h3>Function</h3><p>There is only one function included in the Primitive namespace:</p><h3>Message</h3><p>Message function is used to logging message and it has the signature of ( String -&gt; ( ) ). The behavior differs by simulator, but it write the input message to console in most cases.</p><p>There are other operations in the Primitive namespace but they will required a higher level of knowledge in mathematics and physics to understand. With all these operations and functions, one can start creating interesting quantum programs. In addition, Q# also include other extension namespaces performing other functionalities.</p><p>This concludes my three-part series of explaining quantum computing and Q# to my classmates. Hopefully no body gets confused and some of you readers will find it interesting enough to look further into the topic of quantum computing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fa8eb738f5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try to Explain Quantum Computing and Q# to Non-Physicists 2: Q# Type Model]]></title>
            <link>https://medium.com/@javenliang/try-to-explain-quantum-computing-and-q-to-non-physicists-2-q-type-model-94111d45e467?source=rss-24e20460a3f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/94111d45e467</guid>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Javen Liang]]></dc:creator>
            <pubDate>Mon, 26 Feb 2018 05:11:37 GMT</pubDate>
            <atom:updated>2018-02-26T05:12:10.824Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second part of a three blog posts series of my attempt to explain Quantum Computing and Q# to my software development classmates who have no physics background. The goal of the series is to provide a very high level introduction to my classmates without delving too much into the underlying theories and mathematics. No knowledge of matrix required and hopefully nobody gets confused.</p><h3>Primitive Types</h3><p>In the last blog post, I briefly mentioned some of the types Q# has. Most of them are primitive types, and all other types are constructed by using these primitive types. While a lot of these primitive types share significant similarities to Java, there are also subtle differences. For example, all primitive types in Q# have their first letter capitalized. This is not only different from Java, but also different from the influencers of Q# like C# and F#.</p><p>Just like Java, Q# has primitive types for integers, doubles and Boolean values. The integer type in Q# is represented by Int and is signed just like int in Java. However, the Q# Int type is 64-bit instead of 32-bit like int in Java. This means that the Int type can hold integer much longer than int in Java. The Double type in Q# represents a double precision floating-point number just the same as double in Java, but Q# does not offer a type for single-precision floating-point number like float in Java. Q# also does not offer type equivalent to long in Java. Boolean value is represented by type Bool in Q#, and it can be either true or false just like boolean in Java.</p><p>There are two other primitive types, String and Range, that are not directly related to quantum computing. String is also considered to be primitive type in Q#. It is a sequence of Unicode characters just like Java. However, the String in Q# is opaque to user once created and is used to send messages (such as error messages) to the host program. Range is a type that there is no direct equivalence in Java, but is quite common in other languages such as Python. It is a sequence of integers defined by a starting number, a stopping number, and optionally a step number. A Range is denoted by either start..step..stop or start..stop, in the latter case the step will be 1. For example, 1..3..10 represents the sequence 1, 4, 7, 10, and 1..3 represents the sequence 1, 2, 3.</p><p>There are three primitive types are specific for quantum computing. The Qubit type represents a quantum bit. Qubit is opaque to the user, and user can only either testing its identity (equality), or pass it to operations in the Q# standard library. The Result type represent the result of a measurement of a qubit. Result can be either One or Zero, representing the two possible states of a qubit. Important to notice, the values One and Zero here are not directly correlating to numeric value of 1 and 0 or Boolean value true and false. The Pauli type is a primitive type requiring significant mathematics and physics background knowledge to understand, so I will not go into any further detail in this blog.</p><h3>Array and Tuple</h3><p>The Array types and Tuple types are two Q# types that represent collections of other types.</p><p>The Array type represents a collection of values of a single type, just like in Java. It is possible to create an array of values of any valid types in Q#, as long as the types of each element match exactly. An array is denoted by the element type followed by a pair of square brackets. For example, an array of integers is Int[ ]. The syntax of specifying the size of an array is the same as Java (Int[5]). The syntax of calling a specific element inside an array with its index is also the same as Java (newArray[3]).</p><p>The Tuple type is denoted with a pare of brackets. They represent an immutable collection of types (Int, Double) or values of types (3, 3.3), and in the latter case we call that tuple of the tuple type (Int, Double). Tuple is often used to collect values together into a single value, which then is passed around. Java uses the same concept in passing variables into functions, though not explicitly calls that tuple. A Tuple type can have only one element, and in that case, that tuple is equivalent to the type of the element alone. This is call Singleton Tuple Equivalence, thus Int, (Int) and (((((Int))))) are the same. It is also possible to have a tuple with no element ( ). It is often used to denote a function with no input or output.</p><p>It is also possible to have arrays of tuples, tuples of arrays, arrays of arrays and tuples of sub-tuples, etc. For example, (Int, Double) [ ] [ ] is a jagged array (array of arrays) containing the value of tuple type (Int, Double), such as (4, 4.4). However, this is not a actual rectangular two-dimensional array, and Q# does not include support for multi-dimensional arrays.</p><h3>User-Defined Type</h3><p>It is also possible to create new named type based on other valid types. After created, user-defined types can be used just like any other types, including using as the base of new user-defined type. A user-defined type is created using the keyword newtype:</p><p>newtype IntPair = (Int, Int);</p><p>newtype IntPair2 = IntPair;</p><p>User-defined type also exhibits some properties similar to inheritance in Java classes. In the above example, IntPair is used as the base of IntPair2, as a result, values of type IntPair2 can be used anywhere values of type IntPair2, IntPair or (Int, Int) are expected. However, values of type IntPair can only be used where values of IntPair or (Int, Int) are expected, but not where values of IntPair2 are expected. In addition, if I create another user-defined type:</p><p>newtype IntPair3 = IntPair;</p><p>Although IntPair3 has the exact some signature as IntPair2, values of type IntPair3 are not applicable to where values of IntPair2 are required. This is because Q# treats user-defined type based on same base type as completely unrelated types.</p><p>In summary, this post provides a more in-depth look in the Q# type model, including primitive types, Array type, Tuple type and User-defined type. In the next post, I will discuss another two types Function and Operation, some of the operations available to interact with the qubits and the quantum theories behind them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94111d45e467" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try to Explain Quantum Computing and Q# to Non-Physicists 1: What is Quantum Computing, Q# and…]]></title>
            <link>https://medium.com/@javenliang/try-to-explain-quantum-computing-and-q-to-non-physicists-1-what-is-quantum-computing-q-and-e0b76898a35e?source=rss-24e20460a3f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b76898a35e</guid>
            <category><![CDATA[quantum-computing]]></category>
            <dc:creator><![CDATA[Javen Liang]]></dc:creator>
            <pubDate>Mon, 29 Jan 2018 05:07:52 GMT</pubDate>
            <atom:updated>2018-02-26T02:33:54.842Z</atom:updated>
            <content:encoded><![CDATA[<h3>Try to Explain Quantum Computing and Q# to Non-Physicists 1: What is Quantum Computing, Q# and Quantum Development Kit</h3><p>This is the first part of a three blog posts series of my attempt to explain Quantum Computing and Q# to my software development classmates who have no physics background. The goal of the series is to provide a very high level introduction to my classmates without delving too much into the underlying theories and mathematics. No knowledge of matrix required and hopefully nobody gets confused.</p><h3>What is Quantum Computing?</h3><p>While development of actual quantum computer is still in very early stage, the ideas behind quantum computing have been proposed as early as the 1980s by scientists Yuri Manin and Richard Feynman. The motivation of developing such ideas came from a great problem that still has not been perfectly solved even to today — the simulation of quantum mechanics.</p><p>Quantum mechanics has been developed for over a hundred years. As weird as a lot of the theories behind it may sound, it has been the foundation of a lot of current scientific researches and modern technologies, even something as closed as the chips within the computer this exact blog post was written on. However, even the most simple quantum system can be almost impossible to simulate with conventional computers.</p><p>Imagine a very simple coin flipping scenario. In a classical world, as soon as the coin hit the ground, even though I may not have looked at the coin yet, I know the coin has to be either face side or tail side up (let’s ignore the rare case of the coin landing on its edge). These two outcomes represent two different states. To track that information in a conventional computer, Only 1 bit of memory is needed. However, if the coin is a quantum particle (let’s call it a qucoin), instead of being in one of the two definitive states when on the ground, the qucoin is in both states and any in between stats at the same time. The qucoin only turns into one of the two states when I try to look at it and find the result. This bizarre feature is called quantum superposition and I will discuss that further in my second blog post.</p><p>As if it is not bizarre enough, if I throw multiple qucoin at the same time, when I try to look at the qucoins on the ground, every qucoin will interfere with every other qucoin and influence the states I can observe. That means, in a classical system where I throw 40 coins at the same time, I only need 40 bits of memory to track the outcome. However, in a quantum system where I throw 40 qucoins, I need 2⁴⁰ bits, or over 137 gigabytes of memory in conventional computer. Further more, to track every extra qucoins I throw, I need to double the memory every time. As a result, trying to use conventional computer to simulate large quantum system is entirely unfeasible.</p><p>However, the existence of such system, despite the complete inability for conventional computer power to simulate and engineer, leads to a great opportunity. As the examples demonstrate, quantum particles contain information that conventional computer has no chance of storing. In this case, what if the exact quantum effects are used as the fundamental of computer operations? What if information is stored right in these quantum states of particles and quantum algorithms are used to compute these information? These become the core of quantum computing and it has been demonstrated that such power can be used to solve problems that conventional computers are not capable of.</p><h3>What is Q# and Quantum Development Kit</h3><p>In December 2017, Microsoft released Quantum Development Kit, which include the Q# language. Other than the Q# language, its compiler and the Q# standard library, the Quantum Development Kit include a quantum machine simulator for running Q# programs, another simulator to estimate resource requirement of programs and Visual Studio Extension. With these tools combined, developers can develop and run quantum program even without access to a actual quantum processor. To simulate 30 qubit (the quantum equivalent of a bit, will be discussed in the next blog post) on a local computer, the simulator will need 16 gigabytes of RAM, every extra qubit requires the RAM to be doubled. Developers can also use the Azure based simulator to simulate more than 40 qubits.</p><p>Q# is a domain-specific programming language using quantum algorithms to create programs working on quantum process. In actual operation, the quantum process is treated as coprocessor like GPU, so a classical computer as host and classical programs such as ones written in C# as controller are required. Q# is heavily influenced in syntax by C# and F#, two other programming languages developed by Microsoft. Just like C# and F#, It covers both functional and imperative paradigms, and it is strongly type and has static type checking. Given the similarity between Java and C#, Q# is also relatively easy to read for Java developer.</p><p>Q# includes types such as Int, Double, Bool (boolean), String and Array, which would be familiar to Java developer. It also includes Range (a sequence of integers) and Tuple (an immutable list), which may be less familiar to Java developer. There are also several types specifically related to quantum algorithms, and all of these will be the foci of later blog posts.</p><p>In summary, this post provides a brief introduction to quantum computing, Microsoft’s Quantum Development Kit and the Q# programming language. In the next post, I will focus on the Q# type model. I will compare the types to Java datatypes and discuss how they can be used.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b76898a35e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>