jagomart
digital resources
picture1_Programming In Haskell Pdf 188787 | 01emief2021


 123x       Filetype PDF       File size 0.11 MB       Source: arca.di.uminho.pt


File: Programming In Haskell Pdf 188787 | 01emief2021
problem set 1 haskell ana neri february 26 2021 the goal of the problem set 1 is to recall programming with haskell and some essential concepts of quantum computing mathematical ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
                        Problem Set 1 - Haskell
                                   Ana Neri
                               February 26, 2021
                The goal of the problem set 1 is to recall programming with Haskell and
                some essential concepts of quantum computing mathematical framework.
               1. Write a Haskell function that:
                 (a) Calculates the perimeter of a circle given its radius.
                 (b) Calculates the area of a circle given its radius.
               2. Write a Haskell function to calculate the factorial of a number n. Remem-
                 ber that by convention, fac(0) = 1.
               3. Prime numbers can be an advantage in many fields, such as cryptography.
                 (a) Write a function that returns all numbers from 2 to a given number
                   n.
                 (b) Implement a function to eliminate the multiples of a number n from
                   a list.
                 (c) Admit the Eratosthenes sieving algorithm:
                    • It starts with a list of numbers from 2..n.
                    • The algorithm iteratively takes out the multiples of the prime
                     elements.
                    • In each iteration, the prime number to use always lies in the
                     following position of the element used in the previous iteration.
                   Initial list: [2,3,4,5,6,7,8, 9,10]
                   Iteration 1: [2,3,5,7,9] // eliminate the multiples of 2
                   Iteration 2: [2,3,5,7] // eliminate the multiples of 3
                   Iteration 3: [2,3,5,7] // eliminate the multiples of 5.
                   (...)
                   Iteration n: [2,3,5,7]
                   // in the end, only the primes remain
                   Implement a function that returns all primes up to a number n.
                 (d) Implement a function that tests the primality of a given number n.
                               1
                                                  (e) Implement a function to factorize a number into prime factors, based
                                                       on the previous functions. Example: 15 = 3×5.
                                             4. Matrices are an invaluable tool in quantum information. Here we will
                                                try to implement some of the primitive operations involving matrices.
                                                Consider that the definition of any matrix in Haskell can be a list of type
                                                [[Int]].   For instance, the representation of the Pauli X matrix reads as
                                                follows:                                  
                                                                            σ = 0 1 →[[0,1],[1,0]]
                                                                              x      1   0
                                                  (a) Calculate the transpose of a matrix AT
                                                  (b) Multiply matrices A·B
                                                  (c) Calculate the tensor product A⊗B
                                                  (d) Calculate projection matrices A⊗AT
                                             5. The representation of an n-qubit quantum state can be a column vector
                                                         n
                                                with 2 entries. Implement a function that takes a vector representing a
                                                2-qubit state and applies a CNOT operation to it. Note that a CNOT
                                                representation can be a 4 ×4 matrix:
                                                                                                              
                                                                                                1   0    0    0
                                                                                                              
                                                                                                0   1    0    0
                                                                                CNOT =                        
                                                                                                              
                                                                                                0   0    0    1
                                                                                                0   0    1    0
                                               You may find the following book helpful:
                                               • Haskell Programming From First Principles, by Christopher Allen, and
                                               Julie Moronuki
                                                                                            2
The words contained in this file might help you see if this file matches what you are looking for:

...Problem set haskell ana neri february the goal of is to recall programming with and some essential concepts quantum computing mathematical framework write a function that calculates perimeter circle given its radius b area calculate factorial number n remem ber by convention fac prime numbers can be an advantage in many elds such as cryptography returns all from implement eliminate multiples list c admit eratosthenes sieving algorithm it starts iteratively takes out elements each iteration use always lies following position element used previous initial end only primes remain up d tests primality e factorize into factors based on functions example matrices are invaluable tool information here we will try primitive operations involving consider denition any matrix type for instance representation pauli x reads follows transpose at multiply tensor product projection qubit state column vector entries representing applies cnot operation note you may nd book helpful first principles christo...

no reviews yet
Please Login to review.