Saturday, August 31, 2024

Labour Day

 Putting it all together, I am looking at my QASMTest result in light of the Binomial

Distribution Fomula. On Merlin:

                                                                       


My actual results from ibm_kyoto, and the code:

                                                                                 



My results then, were .517...

The formula predicts .512

                                                                    *     *     *

While on the IBM Quantum site noticed I now have access to a more powerful computer,

with 156 qubits, in Fez Morocco. 😏

                                                                             
                                                                      
*     *     *

HAPPY LABOUR DAY WEEK END TO ALL!


Friday, August 30, 2024

Choose

 Sometimes mathematics seem complicated, but they really aren't. It can be

a simple matter of mastering definitions. Combinations and permutations are

a case in point.


Below, a combination of three fruit, lemon, apple and lime.


Here, a permutation of these same three pieces of fruit. Permuations are orderings;

these are the possible ways of presenting my three fruit.
*     *     *


Foodie me goes to a shop on a hot day, for sherbet. I want 2 scoops, and order

is not an issue. But there is another possibility here. I can choose two of the same

flavor. It is a combination but with (possibly) repetition.


So, how many choices do I have. If I forego repetition, I have three: Lemon/Apple,

Lemon/Lime, and Apple/Lime. 

n = number of possibilities

r = how many I choose


                                                                              
                                                                    *     *     *

The following was suggested to me as a problem:

COPILOT:

Mathematics problem; How can I use these formulas to solve my problem. I go to an ice cream shop that offers 15 flavors. I want to oder three scoops, using two flavours, in a pateern in the bowl od a,b,a. How many choices do I have?

To solve your problem of choosing three scoops of ice cream in a pattern of a, b, a using two flavors from 15 available flavors, you can use the concept of permutations since the order matters.

Here’s the step-by-step process:
Choose flavor ‘a’: You have 15 options.
Choose flavor ‘b’: You have 14 options (since it must be different from ‘a’).

Since the pattern is fixed as a, b, a, you don’t need to calculate further permutations. Simply multiply the choices:
15 (choices for ’a’)×14 (choices for ’b’)=210 combinations
So, you have 210 different ways to choose three scoops of ice cream with two flavors in an a, b, a pattern. Enjoy your ice cream! 🍦

                                                             *     *     *

Both Meta and Gemini present that 210 is it, for choice; and that the order of the scoops is

a settled matter. (This might imply a permutation of 3 for the possible orders of two 'a' and

one 'b'.) It i, in effect, a different problem. I did manage to coax COPILOT with this next question:

                                                             *     *     *
                                                        
How does this change if I am uncertain about the order of the scoops in the bowl. Should I just multiply the 210 by 3?

If you’re uncertain about the order of the scoops, you need to consider all possible arrangements of the flavors. For the pattern a, b, a, there are three possible arrangements: a, b, a, a, a, b, and b, a, a.
However, since the pattern a, b, a is fixed and you want to consider all possible orders, you should calculate the permutations of the two flavors in three positions. The formula for permutations with repetition is:
n1​!⋅n2​!n!​
where ( n ) is the total number of scoops, and ( n_1 ) and ( n_2 ) are the counts of each flavor.


                                                                                        

Now, multiply this by the number of ways to choose the flavors:

210 (ways to choose ’a’ and ’b’)×3 (permutations)=630

So, if you’re uncertain about the order of the scoops, you have 630 different ways to choose and arrange three scoops of ice cream with two flavors. Enjoy your ice cream! 🍦






Thursday, August 29, 2024

Big O

 Had a bit of a math moment with Merlin (running Gemimi) this morning.

It has to do with the binomial distribution. Thought I'd share...

https://www.getmerlin.in/fr/share/chat/H5phKZFrjfP

                                                                  *     *     *

Been working through BigO notation on IBM Learn. Below, also with Gemini:

https://www.getmerlin.in/fr/share/chat/Wvgv6ZxWICg

Recalling that the number of elementary operations or gates is the standard for

evaluating the speed of algorithms, one also need to account for scaling up

with the number of outputs:

In the half adder, the AND gate is the carry:
                                                                                   

One thus needs to position gatesin a series for larger input:
                                                                 


                                                                                      


Big O notation comes in as a way of showing how a particular example scales...






Wednesday, August 28, 2024

Test

 Decided to run a test to pin the difference a Qasm backend could make. I am using

the standard set-up, but have added an S gate(phase difference). Running on the QASM

simulator backend:


Without the S gate, but still on the QASM Simulator:
                                                                                



For comparison, running with the S gate on the AerSimulator:

                                                                         

                                                                         *     *     *

My circuit, on Quantum Composer:

                                                                             



Running it on a real QComputer from Composer; Kyoto looks good...
                                                                              


     The results are in:
                                                                               

                                                                 *     *     *

Result:

                                                                    


QASM

 Below, how-to use the QASM simulator. QASM is a machine-language implementation

of circuits, but one can interact with it using AER python.

                                                         


*     *     *

A fun recipe for 'MilkBread' came through French-language Facebook this morning. It is bread 

pudding using a bit of condensed milk. 

                                                                                




                                                        *     *     *

Gemini Pro:

Qiskit 1.2; does the QASM simulator report outcomes different from AERSimulator. Please explain.

In Qiskit 1.2, the QASM simulator and AER simulator are two distinct types of simulators with different purposes and capabilities. The QASM simulator is designed to simulate quantum circuits with noise and represents measurement outcomes through a sampling process [[3](https://qiskit.github.io/qiskit-aer/stubs/qiskit_aer.QasmSimulator.html)][[7](https://docs.quantum.ibm.com/api/qiskit/0.19/qiskit.providers.aer.QasmSimulator)]. It produces results by simulating the execution of a circuit in the presence of noise, which can result in a distribution of outcomes that reflect realistic noise effects in quantum computation [[5](https://qiskit.github.io/qiskit-aer/)][[6](https://github.com/Qiskit/qiskit-aer)].

On the other hand, the AER simulator encompasses a range of simulation methods, including noise-free simulations as well as those that include noise. It supports several simulation methods, such as statevector, density matrix, and stabilizer, and can return exact results of quantum circuits under these methods [[2](https://qiskit.github.io/qiskit-aer/tutorials/1_aersimulator.html)][[5](https://qiskit.github.io/qiskit-aer/)]. In noise-free mode, AER can provide precise statevector or density matrix representations of the quantum circuit, while noise-inclusive simulations can still reflect distributions caused by noise [[1](https://quantumcomputing.stackexchange.com/questions/24072/what-are-the-differences-between-qiskits-aersimulator-qasmsimulator-and-statev)][[2](https://qiskit.github.io/qiskit-aer/tutorials/1_aersimulator.html)].

Therefore, the key difference between the two is that while QASM is inherently focused on simulating noisy quantum circuits and therefore produces outcomes that account for noise-related randomness, AER offers broader functionality including both ideal and noisy simulations. This means that the outcomes reported by QASM, especially in a noisy context, may differ from a noise-free AER simulation but should align more closely when AER is configured to simulate noise [[5](https://qiskit.github.io/qiskit-aer/)][[7](https://docs.quantum.ibm.com/api/qiskit/0.19/qiskit.providers.aer.QasmSimulator)]. 

Running a circuit using the QASM simulator on a real quantum computer involves executing the circuit as specified in the Quantum Assembly (QASM) language, which describes the gates and operations on qubits. When you run a QASM circuit on a real quantum computer, the process goes beyond simulation: it involves actual physical qubits and hardware. Consequently, the outcomes of your quantum circuit may differ from those obtained in a simulator, primarily due to the presence of noise factors inherent in real quantum systems [[1](https://www.nature.com/articles/s41467-024-46402-9)][[5](https://www.technologyreview.com/2024/01/04/1084783/quantum-computing-noise-google-ibm-microsoft/)]. 
                                                                        *     *     *
What happens if I run a circuit with QASM on a real quantum computer?

Quantum computers are extremely sensitive to disturbances such as thermal fluctuations or electromagnetic interference, which can introduce errors into computations [[5](https://www.technologyreview.com/2024/01/04/1084783/quantum-computing-noise-google-ibm-microsoft/)]. Thus, the results from running a QASM circuit on a real device are generally influenced by decoherence, gate errors, and measurement errors, factors which may lead to results that are less accurate or precise compared to simulated outcomes on an idealized simulator [[5](https://www.technologyreview.com/2024/01/04/1084783/quantum-computing-noise-google-ibm-microsoft/)][[6](https://www.bcg.com/publications/2024/long-term-forecast-for-quantum-computing-still-looks-bright)].

In practical terms, this means that if you run a QASM circuit on a real quantum computer, you should expect to see some degree of deviation in the outcome distributions when compared to the QASM simulation results. It is important to apply error mitigation techniques and increase the number of repetitions (shots) to obtain a more reliable statistical representation of the results if running a real-world application [[3](https://www.quera.com/blog-posts/current-and-future-state-of-quantum-computing)][[6](https://www.bcg.com/publications/2024/long-term-forecast-for-quantum-computing-still-looks-bright)]. 


Tuesday, August 27, 2024

Result

 Solved my ongoing problem of getting counts from a python list. Actually, ChatGPT4 Pro

solved it. Below, a complete sequence:




I kept getting 'dict object is not callable' because I was calling it. The correct procedure

is not 'pub_result = result()[0]' but 'pub_result = result[0]'.😀

*     *     *

The error message "TypeError: unhashable type: 'dict'" arises because you are attempting to use a dictionary (`pub_result.data.meas.get_counts()`) as a key in a new dictionary, which is not allowed in Python. Dictionary keys must be immutable data types, such as strings, numbers, or tuples [[6](https://www.dataquest.io/blog/python-dictionaries/)]. 

To access the counts, you should use the dictionary returned by `get_counts()` directly. Here's how you can modify your code:

python
pub_result = result[0]
counts = pub_result.data.meas.get_counts()
print(counts)

This code will first retrieve the dictionary of counts and store it in the `counts` variable. Then, it will print the `counts` dictionary.

                                                                         *     *     *
 
 https://meta.ai/s/XxUu1hmTJnRyfetm/    

                                                                        *     *     *


                                                                        *     *     *
From Copilot:

In Qiskit 1.2, both the Estimator and Sampler classes are used for different purposes in quantum computing, and they have distinct functionalities:

Estimator

Purpose: The Estimator is used to calculate the expectation values of observables for given quantum states.
Functionality: It runs quantum circuits and measures the expectation values of specified observables. This is useful for tasks like variational algorithms where you need to evaluate the expectation value of a Hamiltonian.
Output: The result is the expectation value of the observable for the state prepared by the circuit.
Deprecation: As of Qiskit 1.2, the Estimator class is deprecated and will be replaced by the StatevectorEstimator1.

Sampler

Purpose: The Sampler is used to sample bitstrings from the probability distribution defined by the quantum state.
Functionality: It runs quantum circuits and samples the resulting bitstrings. This is useful for tasks like probabilistic sampling and Monte Carlo simulations.
Output: The result is a set of sampled bitstrings, which represent the measurement outcomes of the quantum circuits.
Deprecation: Similarly, the Sampler class is deprecated in Qiskit 1.2 and will be replaced by the StatevectorSampler2.

In summary, the Estimator focuses on calculating expectation values, while the Sampler focuses on sampling bitstrings from the quantum state. Both are essential for different types of quantum algorithms and applications.



Monday, August 26, 2024

Still_at_it

 I put together a simple program to run on an actual quantum machine, just

to check that I knew how to do this solo. I then went into a queue that lasted 3 days...

The results are in this morning:

                                                                          




To be frank, I don't really know what the results mean 😕

I did experiment with finding the least busy backend, and this too worked. We'll

see when this jobs comes in...

                                                                             

                                                                               

Sunday, August 25, 2024

Performance

 Algorithm performance will be measured with repect to size,

that is, the number of gates employed.

                                                           




                                                                                      
Fanout gates are gates that lead to more than 1 next gate. The circuit above has 5

if we ignore the initial fanouts.

 
Circuit depth is not being used here; one considers a layer to be gates that can be run

at the same time because they are independent. Thus the two fanouts above are one layer,

the two NOTs another... Our example has deth 4, gates that can be run in parallel.


Add for each, input length. Below, a half-adder:

                                                            







VVeins

 I was asked about the risks associated with surgical treatment of varicose veins:

https://meta.ai/s/dfLV9aQ2nZyNDfTJ/

Saturday, August 24, 2024

Rustacean

 Rust (programming language) - Wikipedia

Copilot:

Yes, Qiskit has indeed adopted Rust as part of its development. While Qiskit’s primary language is Python, certain computationally intensive internals were re-implemented in Rust for performance reasons. Rust provides a balance between speed and safety, giving Qiskit developers the best of both worlds1Additionally, Rust is also used in other areas related to quantum computing, such as the rustworkx library, which leverages Rust’s inherent performance and safety2. 😊


Simple, and powerful:

Variables are immutable by default, and adding the mut keyword allows the variable to be mutated.[39] The following example uses //, which denotes the start of a comment.[40]

fn main() {
    let mut foo = 10; // This code would not compile without adding "mut".
    println!("The value of foo is {foo}");
    foo = 20;
    println!("The value of foo is {foo}");
}

Veggies

 Lyse brought me veggies form her garden in the country:

                                                                     


Yeah, it's been raining...

No of Bits

COPILOT:

Mathematics; is there a formula that allows me to predict how many bit it takes to encode a decimal number, say 164?


Certainly! To find the number of bits needed to encode a decimal integer like 164, you can use the following formula:

Number of bits=⌊log2​(n)⌋+1

Here, (n) represents the decimal integer. Let’s calculate it for 164:

Compute (\log_2(164)):

(\log_2(164) \approx 7.006)

Take the floor value: (\left\lfloor 7.006 \right\rfloor = 7)

Add 1: (7 + 1 = 8)

So, 164 requires 8 bits for binary representation. 🌟

If you’d like to convert 164 to binary directly, it is (10100100_2)

                                                           *     *     *

Was wondering what query gates are...

https://www.perplexity.ai/search/qiskit-how-could-i-use-the-cry-pcZj2ZpQTIm7xnLK0UyIMg

                                                             





On Quantum Composer:





These are the probilities from IBM quantum Composer. If I ask for the state ofthe 

individual qubits after measurement, they will both appear as 1. That is because this simulator

shows the measured state qubit after measurement.

                                                                



I am in the queue to actually run this simple circuit on ibm_sherbrooke.