t = 0.00 |ψ⟩ = [0.00, 0.00, 1.00]

Bloch Equation Dynamics

The state of a two-level quantum system can be represented as a vector r = (x, y, z) on the unit Bloch sphere. The evolution of the state under a semi-classical drive is governed by the Bloch equations.

dr/dt = Ω × r - Γ(r) [ dx/dt ] [ 0 -Δ 0 ] [ x ] [ -x/T2 ] [ dy/dt ] = [ Δ 0 -Ωx ] [ y ] + [ -y/T2 ] [ dz/dt ] [ 0 Ωx 0 ] [ z ] [ (1-z)/T1 ]

Where:
Ωx is the Rabi frequency (drive strength)
Δ is the detuning between the drive and the qubit transition
T1, T2 are relaxation and dephasing times (simplified here as general decoherence)

bloch_sim.m

% Quantum Control: Bloch Sphere Simulation
% Solves the Bloch equations for a driven two-level system

function bloch_sim()
    % Parameters
    Omega_x = 1.0;  % Drive strength
    Delta = 0.0;    % Detuning
    Gamma = 0.0;    % Decoherence rate
    
    % Initial State |0> (North Pole)
    r0 = [0; 0; 1]; 
    
    % Time span
    tspan = [0 10];
    
    % ODE Solver
    [t, r] = ode45(@(t,r) bloch_eq(t, r, Omega_x, Delta, Gamma), tspan, r0);
    
    % Visualization
    figure; hold on; grid on; view(3); axis equal;
    
    % Draw Bloch Sphere
    [X,Y,Z] = sphere(40);
    surf(X,Y,Z, 'FaceColor', '#f0f0f0', 'EdgeColor', 'none', 'FaceAlpha', 0.1);
    
    % Plot Trajectory
    plot3(r(:,1), r(:,2), r(:,3), 'LineWidth', 2);
    
    % Decorate
    xlabel('x'); ylabel('y'); zlabel('z');
    title('Bloch Vector Trajectory');
end

function drdt = bloch_eq(t, r, Wx, D, G)
    % Cross product: W x r
    W = [Wx; 0; D]; 
    cross_term = cross(W, r);
    
    % Relaxation term
    relax_term = [-G*r(1); -G*r(2); 0]; % Simplified T2
    
    drdt = cross_term + relax_term;
end