Question: Problem 3: Quantum Computing Quantum Computing is a different model of computation imagined by the physicist Feynman. Instead of whole numbers, like we use in






Problem 3: Quantum Computing Quantum Computing is a different model of computation imagined by the physicist Feynman. Instead of whole numbers, like we use in the Turing model, it uses complex numbers. Complex numbers are actually simply pairs of real numbers. Python has complex numbers available, albeit slightly different from what people normally use, because it's said), engineers use j. complex number = x+yi (19) where r, yek (they're just numbers) and there's a lone i. The x is called the real part and the y is called the imaginary part. This is a solution to: (20) 22 + i = 0 = V-I = i (21) For example: 2 - V-1 V-1--1 (22) In middle school one of the most terrifying first encounter with mathematics is in the form of the dreaded quadratic formula. We have Babylonian tablets that showing students millenia ago having to solve this problem-so take comfort in that. To refresh your memory, given: ar? + ba+c = 0 (23) has two solutions: -b3V12 4oc = (24) 20 For example, c? 2.1 4 = 0 2+ 1-(4)(1)-4) (25) 2(1) 21/4+16 (26) 2 2120 (27) Observe that you'll get zero (on the x-axis or abscissa) if you put either of these two x values there. See Fig. 1. below. Assignment No 3 Functions and Choice Page 9 403 +4 +2= 20 (-1.2360679774997898,01 13.23606797749979,0) - 2r - d=D Figure 1: The red dots (with red arrows) are where your solutions are to 32 - 2.2 - 1 = 0. The dash curve is the function itself. The horizontal line just makes it easier to see the x- axis. The two values are - 1.2360679774997898 and 3.23606797749979. For the other function 3x2 +4.0 +2 = 0 shown in blue, because it has an imaginary part, it cannot cross the axis. You'll use the matplotlib library you were introduced last homework to actually plot this! Sometimes the discriminant (the value in the squareroot) is negative. This is where i comes in. We simply multiply the value by -1, thereby allowing us to take the squareroot, but then we append an i to signal it's imaginary. For example, suppose we have 3.0? + 4.2 + 2 = 0. Then we find, after some algebra: - 47-8 (28) (29) - -4V-2 x 4 -4v-2x 14 (30) _-42V-2 (31) = - 2 (32) So, there's a simple test whether the roots are complex or not-check the value in the square- root called the discriminant: 62 - 4ac >> (1+j) Traceback (most recent call last): File "", line 1, in NameError: name 'j' is not defined >>> (1+Oj) (1+0j) >>> (1+Oj)*(1-0) (1+0j) >>> complex(1,0) (1+0j) >>> X = complex(1,2) (1+2j) >>> y = complex(1,-4) >>> y (1-4) > x+y (9-2j) >>> X.real 1.0 >>> x.imag 2.0 >>> type(x) >>> abs(X) 2.23606797749979 >>> (1+*2 + (-2)**2))**(1/2) 2.23606797749979 >>> X (1+2j) Assignment No 3 Functions and Choice Page 14 Problem 3: Quantum Computing Quantum Computing is a different model of computation imagined by the physicist Feynman. Instead of whole numbers, like we use in the Turing model, it uses complex numbers. Complex numbers are actually simply pairs of real numbers. Python has complex numbers available, albeit slightly different from what people normally use, because it's said), engineers use j. complex number = x+yi (19) where r, yek (they're just numbers) and there's a lone i. The x is called the real part and the y is called the imaginary part. This is a solution to: (20) 22 + i = 0 = V-I = i (21) For example: 2 - V-1 V-1--1 (22) In middle school one of the most terrifying first encounter with mathematics is in the form of the dreaded quadratic formula. We have Babylonian tablets that showing students millenia ago having to solve this problem-so take comfort in that. To refresh your memory, given: ar? + ba+c = 0 (23) has two solutions: -b3V12 4oc = (24) 20 For example, c? 2.1 4 = 0 2+ 1-(4)(1)-4) (25) 2(1) 21/4+16 (26) 2 2120 (27) Observe that you'll get zero (on the x-axis or abscissa) if you put either of these two x values there. See Fig. 1. below. Assignment No 3 Functions and Choice Page 9 403 +4 +2= 20 (-1.2360679774997898,01 13.23606797749979,0) - 2r - d=D Figure 1: The red dots (with red arrows) are where your solutions are to 32 - 2.2 - 1 = 0. The dash curve is the function itself. The horizontal line just makes it easier to see the x- axis. The two values are - 1.2360679774997898 and 3.23606797749979. For the other function 3x2 +4.0 +2 = 0 shown in blue, because it has an imaginary part, it cannot cross the axis. You'll use the matplotlib library you were introduced last homework to actually plot this! Sometimes the discriminant (the value in the squareroot) is negative. This is where i comes in. We simply multiply the value by -1, thereby allowing us to take the squareroot, but then we append an i to signal it's imaginary. For example, suppose we have 3.0? + 4.2 + 2 = 0. Then we find, after some algebra: - 47-8 (28) (29) - -4V-2 x 4 -4v-2x 14 (30) _-42V-2 (31) = - 2 (32) So, there's a simple test whether the roots are complex or not-check the value in the square- root called the discriminant: 62 - 4ac >> (1+j) Traceback (most recent call last): File "", line 1, in NameError: name 'j' is not defined >>> (1+Oj) (1+0j) >>> (1+Oj)*(1-0) (1+0j) >>> complex(1,0) (1+0j) >>> X = complex(1,2) (1+2j) >>> y = complex(1,-4) >>> y (1-4) > x+y (9-2j) >>> X.real 1.0 >>> x.imag 2.0 >>> type(x) >>> abs(X) 2.23606797749979 >>> (1+*2 + (-2)**2))**(1/2) 2.23606797749979 >>> X (1+2j) Assignment No 3 Functions and Choice Page 14