Everything on the site.

Big-O notationAlgorithms · Count the steps in real loops, then compare n, n log n, n² and 2ⁿ on a live chart.RecursionAlgorithms · Watch frames push and pop on the call stack for factorial and Fibonacci.BFS vs DFSAlgorithms · A queue against a stack: draw a graph and see which order each search visits it in.Sorting algorithmsAlgorithms · Seven sorts on the same input, with comparison, swap and write counts side by side.Binary searchAlgorithms · Halve the range, probe the middle, repeat: with lo, mid and hi drawn on the array.Sets, relations and functionsDiscrete maths · Shade any set expression on a Venn diagram and test a relation for its properties.Proof by inductionDiscrete maths · Four worked proofs revealed one step at a time, and a broken one to diagnose.CombinatoricsDiscrete maths · An exact nPr and nCr calculator, and a Pascal’s triangle that shows its own addition rule.Boolean algebraDiscrete maths · The laws, De Morgan, and normal forms, with a truth-table generator built in.Finite-state machinesTheory · Build a DFA in a table, see it drawn, and run strings through it one symbol at a time.Domain theoryTheory · Why recursion needs least fixed points, and how CPOs, Scott continuity and powerdomains supply them.Truth table generatorTools · Expression in, truth table out: with DNF, CNF, a minimal form and LaTeX.Graph traversal visualiserTools · Draw a graph, then animate BFS, DFS and Dijkstra with the frontier shown.Recursion tree visualiserTools · Paste a recursive function or a recurrence and see its call tree and call count.Gradient descentML maths · Drag the starting point, set the learning rate, and watch it converge or blow up.Vectors and embeddingsML maths · Bend the plane with a 2×2 matrix and measure how close toy word vectors are.Softmax and cross-entropyML maths · Edit the logits and watch the probabilities, the loss and the gradient update live.Attention mechanismML maths · Q, K and V for three tokens, a live score heatmap, and the weighted sum of values.Formatting a CS paper in LaTeXLaTeX · Page limits, \documentclass, front matter, theorem environments and the bibliography.Camera-ready checklistLaTeX · Fonts embedded, PDF/A, copyright form, source bundle, and why final versions get rejected.LaTeX templatesLaTeX · Where the official classes live, plus a minimal article template you can copy.Boolean algebra calculatorTools · A Boolean expression simplifier that names the law used at every step.K-map solverTools · Fill in a Karnaugh map and see the groups, the minimal SOP and POS, and the essential terms.Logic gate simulatorTools · Wire up gates, flip the switches, and get the truth table and expression of your circuit.Regex to NFA converterTools · Type a regular expression and watch Thompson’s construction build its NFA, fragment by fragment.NFA to DFA converterTools · Enter an NFA or a regex and step through the subset construction, then minimise the DFA.DFA simulatorTools · Edit a DFA, run strings through it step by step, batch-test them and share the machine as a link.Regular expressions to automataTheory · Regex to NFA to DFA to minimal DFA, worked through on one example with every set shown.The halting problemTheory · Why no program can tell whether every program halts, with the paradox program played out.Pigeonhole principleDiscrete maths · n pigeons, k holes: why some hole gets ⌈n/k⌉, and the surprising things that follows from it.Dijkstra’s algorithmAlgorithms · Shortest paths with a priority queue: a worked table, a proof, and a graph you can redraw.Hash functionsAlgorithms · Keys in, buckets out: hash a word four ways, then watch chaining and probing handle collisions.Sorting algorithm visualizerTools · Up to seven sorts race on the same data, then step through any one of them line by line.LaTeX table generatorTools · Type or paste a table, merge cells, pick booktabs, and copy clean tabular code.Combination calculatorTools · Exact nCr with the cancelling shown, combinations with repetition, and a full list for small n.Permutation calculatorTools · nPr, nʳ, anagrams like MISSISSIPPI and round-table seatings, with exact working.AlgorithmsSection · Step-through visualisations of sorting, searching, recursion, graph traversal, Dijkstra’s algorithm, hash functions and Big-O growth, with pseudocode that follows along.Discrete mathsSection · Sets, relations and functions, proof by induction, counting, the pigeonhole principle and Boolean algebra, explained with worked examples and interactive checkers.TheorySection · Finite-state machines, regular expressions and automata, the halting problem, and the mathematical semantics of programming languages, explained from first principles.ML mathsSection · Gradient descent, vectors and embeddings, softmax and cross-entropy, and attention, each with a formula, a worked numeric example and a live version.ToolsSection · Free browser tools: truth tables, Boolean simplification, K-maps, logic gates, nCr and nPr, regex to NFA to DFA, sorting and graph visualisers, and LaTeX tables.LaTeXSection · How to format a CS conference or workshop paper in LaTeX, a camera-ready checklist, and a minimal template you can adapt.
Free tool

Logic gate simulator: build and test circuits online

Build a digital circuit from switches, gates and lamps, then flip the switches and watch the signals change. The simulator writes out the truth table and the Boolean expression of whatever you build, handles circuits with feedback such as latches, and runs entirely in your browser.

Interactive: Drag-and-drop circuit builder with live signals and a truth tableUpdated

Logic gate simulator

Drag parts to move them. Drag from a part’s right-hand port to another part’s left-hand port to connect them (or tap one, then the other). Tap a switch to flip it. Select a part or wire and press Delete to remove it.

Truth table

Boolean expressions

How to use the simulator

  1. Add parts with the buttons above the canvas: switches (inputs), lamps (outputs) and the eight gate types. Switches are named A, B, C … and lamps X, Y, Z … in the order you add them.
  2. Move parts by dragging them. With the keyboard, tab to a part and use the arrow keys (hold Shift for bigger steps).
  3. Connect them. Every part has its output on the right and its inputs on the left. Drag from an output dot to an input dot. On a touch screen or with the keyboard, tap or press Enter on the output, then on the input. An output can feed any number of inputs, but each input takes one wire; connecting a new wire replaces the old one.
  4. Flip the switches by tapping them, or with Enter or Space. Wires carrying a 1 turn amber and lamps light up. The matching row of the truth table is highlighted.
  5. Delete a part or a wire by selecting it and pressing Delete, or with the “Delete selected” button.

Your circuit is saved in this browser, so it is still there when you come back. “Copy link” puts the whole circuit in the address, which you can send to someone else or keep as a bookmark. The ready-made circuits in “Load a circuit” are a good place to start.

The gates

A logic gate computes a Boolean function of its inputs. NOT and the buffer take one input; the others take two. The small circle on NAND, NOR, XNOR and NOT is the symbol for inversion.

GateOutput isExpression00011011
AND1 only when both inputs are 1A⋅BA \cdot B0001
OR1 when at least one input is 1A+BA + B0111
NANDNOT AND: 0 only when both inputs are 1A⋅B‾\overline{A \cdot B}1110
NORNOT OR: 1 only when both inputs are 0A+B‾\overline{A + B}1000
XOR1 when the inputs differA⊕BA \oplus B0110
XNOR1 when the inputs are equalA⊕B‾\overline{A \oplus B}1001
NOTthe opposite of its inputA‾\overline{A}A = 0 → 1A = 1 → 0
Bufferthe same as its input (in hardware it restores signal strength)AAA = 0 → 0A = 1 → 1

The column headings are the two inputs ABAB. Unconnected inputs in the simulator read as 0, which is a convenient default but not how real chips behave: a floating CMOS input can read as either value, so in hardware every input must be tied to something.

Truth tables and expressions

For a circuit without feedback, every output is a fixed function of the switches, so the simulator can list it for every combination of inputs: the truth table, with the first switch as the most significant bit. It shows up to 6 switches (64 rows).

It also writes each lamp’s value as a Boolean expression, by walking back from the lamp through the gates it is wired to. The expression mirrors the circuit exactly, gate for gate, so it is usually not the simplest form. Copy it into the Boolean algebra calculator to simplify it, or design in the other direction: start from a truth table, minimise it with the K-map solver, and build the minimal circuit here.

Worked example: a full adder

Load “Full adder” from the menu. It adds three bits, AA, BB and a carry-in CinC_\text{in}, and produces a sum bit SS and a carry-out CoutC_\text{out}. The simulator produces this table:

ABCinCoutSA + B + Cin
000000
001011
010011
011102
100011
101102
110102
111113

Read Cout SC_\text{out}\,S as a two-bit binary number and it is the count of 1s among the inputs, which is what adding three bits means. The sum is S=A⊕B⊕CinS = A \oplus B \oplus C_\text{in}, 1 when an odd number of inputs are 1, and the carry is Cout=AB+Cin(A⊕B)C_\text{out} = AB + C_\text{in}(A \oplus B). Chain 32 of these, each carry-out feeding the next carry-in, and you have a ripple-carry adder for 32-bit numbers.

Worked example: a multiplexer

“2-to-1 multiplexer” passes input AA through when the select switch SS is 0 and input BB when it is 1. The simulator writes its output as Y = A ∧ ¬S ∨ B ∧ S, which is AS‾+BSA\overline{S} + BS. Multiplexers are how a processor chooses between values, such as which register feeds the adder.

One gate is enough

NAND is functionally complete: every Boolean function can be built from NAND gates alone. Tie a NAND gate’s inputs together and it becomes NOT. Follow it with a NOT and it becomes AND. NOT both inputs first and it becomes OR, by De Morgan’s law A‾⋅B‾‾=A+B\overline{\overline{A}\cdot\overline{B}} = A + B. Load “XOR from four NANDs” to see the classic four-gate XOR. NOR is complete too. Chips are often built mostly from NAND and NOR gates, because in CMOS they need fewer transistors than AND and OR.

Feedback and memory

Wire a gate’s output back into an earlier gate and the circuit can remember. Load “SR latch (NOR)”: two NOR gates, each feeding the other. Turn S on and off: QQ becomes 1 and stays 1. Turn R on and off: QQ becomes 0 and stays 0. With both switches off, the latch holds whichever value it had, so the same inputs give different outputs depending on what happened before. That is why the simulator shows no truth table for circuits with loops. Latches like this are the basis of flip-flops, registers and static RAM.

The simulator settles a loop by re-evaluating the gates until nothing changes. Some loops never settle: a single NOT gate feeding itself flips forever. In hardware that is a ring oscillator, and the simulator warns you when it finds one. Setting S and R to 1 together forces both latch outputs to 0, the “forbidden” state; switching both off at once then leaves the result depending on which gate is faster.

What this simulator does not model Every gate here switches instantly, so there are no propagation delays, glitches or race conditions. Real gates take time, which is what limits clock speeds and why a K-map sometimes needs an extra, redundant group to remove a hazard. There are also no clocks, tri-state outputs or analogue effects. For timing, use a hardware description language such as Verilog or VHDL with a simulator.

Common mistakes

  • Leaving an input unconnected. A gate with a missing wire still computes, using 0 for that input, so a half-wired circuit can look as if it works for some rows. Check the expression: an unconnected input shows up as a 0.
  • Confusing XOR and OR. They differ only when both inputs are 1. A half adder’s sum needs XOR; with OR, 1 + 1 would give sum 1.
  • Reading the bubble as decoration. The small circle inverts. NAND is not AND, and the output side of an XNOR is the opposite of XOR.
  • Expecting a truth table from a latch. A circuit with feedback has state, so it is described by a state table or a timing diagram, not a truth table.

To check a hand-made truth table, use the truth table generator; for the algebra of gates, the Boolean algebra explainer.

References

  1. C. E. Shannon, “A symbolic analysis of relay and switching circuits”, Transactions of the AIEE 57(12), 1938. doi:10.1109/T-AIEE.1938.5057767
  2. D. M. Harris and S. L. Harris, Digital Design and Computer Architecture, 2nd ed., Morgan Kaufmann, 2012. Chapters 1–3 cover gates, combinational logic and latches.
  3. C. Petzold, Code: The Hidden Language of Computer Hardware and Software, 2nd ed., Microsoft Press, 2022. Builds an adder and memory from relays and gates.
  4. “Logic gate”, Wikipedia.