My First Quantum Code

PaulaJedi

Survivor
☀️ Zenith
My first quantum circuit used a combination of Hadamard gates and CNOT gates to create a superposition state.

OPENQASM 2.0;
include "qelib1.inc";
qubit q[1]; <--register a qubit
H q[0]; <-- Hadamard gate that creates superposition
cx q[0],q[1]; <- controlled NOT gate - flips one qubit

measure q[0] ->
c[0]; measure q[1] -> c[1]; <----measuring the distance between the 2 particles


This is the code for sending a message to the future, but we need actual particles to do this:

OPENQASM 2.0;
include "qelib1.inc";
qreg q[5]; <--- placing quibits in the register
creg c[8]; <---- placing quibits in the register
h q[0]; <---- gate to send the quibits through. Gates are mathematical equations.
x q[0]; <---- gate to send the quibits through.
x q[1]; <---- gate to send the quibits through.

creg[0] = [place binary coded message here];

So, we were getting an error with the semicolons. That's why I needed help. John tried to trouble shoot but nothing worked.

I am still studying these simple programs to understand them, but I'm getting there.
 
Last edited:
@Einstein What’s so funny? At least I tried. That’s
more than what most people do. I’m thinking of new things and experimenting. We know we need a laser and 2 particles. And we obviously don’t have them. If you see an error, please share.
 

@Einstein What’s so funny? At least I tried. That’s
more than what most people do. I’m thinking of new things and experimenting. We know we need a laser and 2 particles. And we obviously don’t have them. If you see an error, please share.

You still seem to not differentiate between Superposition and Entanglement. They are two separate phenomena.
 

My bad. I thought quantum entanglement involved superposition but apparently not. As I said, I’m learning. Best to correct me rather than laugh. I learn from mistakes. Not ashamed. It’s why I am thinking out loud and creating a conversation. I don’t claim to know it all. I know nearly nothing. I’m learning. I thought the particles had to be in super position to correlate, but now I know that’s not true. Beginner’s error.
 
My bad. I thought quantum entanglement involved superposition but apparently not. As I said, I’m learning. Best to correct me rather than laugh. I learn from mistakes. Not ashamed. It’s why I am thinking out loud and creating a conversation. I don’t claim to know it all. I know nearly nothing. I’m learning. I thought the particles had to be in super position to correlate, but now I know that’s not true. Beginner’s error.

It was a friendly like. You got a laugh out of me. If you want to think outside the box, try my favorite tool. One step forward, two steps back. Like 3D or 4D. We use this a lot in math. But it's like a rigid brick wall. Or a failed assumption. Science is not moving forward with those math models.

Then again I am not up to speed on time crystals. But I do seem to remember they had some interesting properties. And they are real! Might be what you are looking for.
 
I don't know enough about the language to see a syntax error. Your "measure" statement is split across 2 lines, but usually languages that use ';' as line endings don't care. "place binary coded message here" would seem to be a string of some sort. That may need quotes and there may be size limitations. A loop may be needed when loading "creg". If you're using it like a radio, that loop would need to be throttled to give the other side a chance to read each state. Sticking with radio and serial transmissions, there would also need to be a clock signal so the other side would know when to read the next data bit.
 
I don't know enough about the language to see a syntax error. Your "measure" statement is split across 2 lines, but usually languages that use ';' as line endings don't care. "place binary coded message here" would seem to be a string of some sort. That may need quotes and there may be size limitations. A loop may be needed when loading "creg". If you're using it like a radio, that loop would need to be throttled to give the other side a chance to read each state. Sticking with radio and serial transmissions, there would also need to be a clock signal so the other side would know when to read the next data bit.

Yeah, I was experiementing with brackets and quotes.... really frustrating to get a syntax error that won't go away.
 
Regardless of the elements needed whether it’s lasers and particles or other things, do they affect the lowest level of code, assembly language? Maybe ask it to provide the 0’s and 1’s sequence of whatever you need it to be? Or along that frame of mind.
 

Top