diff --git a/docs/examples/notebooks/basic_quantum.ipynb b/docs/examples/notebooks/basic_quantum.ipynb index 1e18fa2..2b48dc1 100644 --- a/docs/examples/notebooks/basic_quantum.ipynb +++ b/docs/examples/notebooks/basic_quantum.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"text","text":"

Basic Symbolic Quantum Mechanics

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Bras and Kets

"},{"code":"phi, psi = Ket('phi'), Ket('psi')\nalpha, beta = symbols('alpha beta', complex=True)","cell_type":"code","prompt_number":3},{"code":"state = alpha*psi + beta*phi; state\n","cell_type":"code","prompt_number":4},{"code":"ip = Dagger(state)*state; ip\n","cell_type":"code","prompt_number":5},{"code":"qapply(expand(ip))\n","cell_type":"code","prompt_number":6},{"cell_type":"text","text":"

Operators

"},{"code":"A = Operator('A')\nB = Operator('B')\nC = Operator('C')","cell_type":"code","prompt_number":7},{"code":"A*B == B*A\n","cell_type":"code","prompt_number":8},{"code":"expand((A+B)**2)","cell_type":"code","prompt_number":9},{"code":"comm = Commutator(A,B); comm\n","cell_type":"code","prompt_number":10},{"code":"comm.doit()","cell_type":"code","prompt_number":11},{"code":"comm = Commutator(A*B,B+C); comm","cell_type":"code","prompt_number":12},{"code":"comm.expand(commutator=True)","cell_type":"code","prompt_number":13},{"code":"_.doit().expand()\n","cell_type":"code","prompt_number":14},{"code":"Dagger(_)","cell_type":"code","prompt_number":15},{"code":"%notebook save basic_quantum.ipynb","cell_type":"code","prompt_number":16},{"code":"%notebook load quantum_computing.ipynb","cell_type":"code","prompt_number":19}]} \ No newline at end of file +{"cells":[{"cell_type":"text","text":"

Basic Symbolic Quantum Mechanics

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":7},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Bras and Kets

"},{"code":"phi, psi = Ket('phi'), Ket('psi')\nalpha, beta = symbols('alpha beta', complex=True)","cell_type":"code","prompt_number":9},{"code":"state = alpha*psi + beta*phi; state\n","cell_type":"code","prompt_number":10},{"code":"ip = Dagger(state)*state; ip\n","cell_type":"code","prompt_number":11},{"code":"qapply(expand(ip))\n","cell_type":"code","prompt_number":12},{"cell_type":"text","text":"

Operators

"},{"code":"A = Operator('A')\nB = Operator('B')\nC = Operator('C')","cell_type":"code","prompt_number":13},{"code":"A*B == B*A\n","cell_type":"code","prompt_number":14},{"code":"expand((A+B)**2)","cell_type":"code","prompt_number":15},{"code":"comm = Commutator(A,B); comm\n","cell_type":"code","prompt_number":16},{"code":"comm.doit()","cell_type":"code","prompt_number":17},{"code":"comm = Commutator(A*B,B+C); comm","cell_type":"code","prompt_number":18},{"code":"comm.expand(commutator=True)","cell_type":"code","prompt_number":19},{"code":"_.doit().expand()\n","cell_type":"code","prompt_number":20},{"code":"Dagger(_)","cell_type":"code","prompt_number":21},{"code":"%notebook save basic_quantum.ipynb","cell_type":"code","prompt_number":16},{"code":"%notebook load quantum_computing.ipynb","cell_type":"code","prompt_number":19}]} \ No newline at end of file diff --git a/docs/examples/notebooks/decompose.ipynb b/docs/examples/notebooks/decompose.ipynb index 461f435..23e59a5 100644 --- a/docs/examples/notebooks/decompose.ipynb +++ b/docs/examples/notebooks/decompose.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"text","text":"

Gate Decomposition

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Example 1

"},{"code":"CY10 = CGate(1, Y(0)); CY10\n","cell_type":"code","prompt_number":3},{"code":"CY10.decompose()\n","cell_type":"code","prompt_number":4},{"code":"circuit_plot(CY10.decompose(), nqubits=2)","cell_type":"code","prompt_number":5},{"cell_type":"text","text":"

Example 2

"},{"code":"CZ01 = CGate(0, Z(1)); CZ01\n","cell_type":"code","prompt_number":6},{"code":"CZ01.decompose()\n","cell_type":"code","prompt_number":7},{"code":"circuit_plot(CZ01.decompose(), nqubits=2)","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Example 3

"},{"code":"SWAP10 = SWAP(1, 0); SWAP10\n","cell_type":"code","prompt_number":9},{"code":"SWAP10.decompose()","cell_type":"code","prompt_number":10},{"code":"circuit_plot(SWAP10.decompose(), nqubits=2)","cell_type":"code","prompt_number":11},{"cell_type":"text","text":"

All together now

"},{"code":"gates = [CGate(1,Y(0)), CGate(0,Z(1)), SWAP(1, 0)]","cell_type":"code","prompt_number":12},{"code":"for g in gates:\n dg = g.decompose()\n display(Eq(g, dg))\n circuit_plot(g, nqubits=2)\n circuit_plot(dg, nqubits=2) ","cell_type":"code","prompt_number":13},{"code":"%notebook save decompose.ipynb","cell_type":"code","prompt_number":30}]} \ No newline at end of file +{"cells":[{"cell_type":"text","text":"

Gate Decomposition

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Example 1

"},{"code":"CY10 = CGate(1, Y(0)); CY10\n","cell_type":"code","prompt_number":3},{"code":"CY10.decompose()\n","cell_type":"code","prompt_number":4},{"code":"circuit_plot(CY10.decompose(), nqubits=2)","cell_type":"code","prompt_number":5},{"cell_type":"text","text":"

Example 2

"},{"code":"CZ01 = CGate(0, Z(1)); CZ01\n","cell_type":"code","prompt_number":6},{"code":"CZ01.decompose()\n","cell_type":"code","prompt_number":7},{"code":"circuit_plot(CZ01.decompose(), nqubits=2)","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Example 3

"},{"code":"SWAP10 = SWAP(1, 0); SWAP10\n","cell_type":"code","prompt_number":9},{"code":"SWAP10.decompose()","cell_type":"code","prompt_number":10},{"code":"circuit_plot(SWAP10.decompose(), nqubits=2)","cell_type":"code","prompt_number":11},{"cell_type":"text","text":"

All together now

"},{"code":"gates = [CGate(1,Y(0)), CGate(0,Z(1)), SWAP(1, 0)]","cell_type":"code","prompt_number":12},{"code":"for g in gates:\n dg = g.decompose()\n display(Eq(g, dg))\n circuit_plot(g, nqubits=2)\n circuit_plot(dg, nqubits=2) ","cell_type":"code","prompt_number":13},{"code":"%notebook save decompose.ipynb","cell_type":"code","prompt_number":30},{"code":"%notebook load gate_rules.ipynb","cell_type":"code","prompt_number":53}]} \ No newline at end of file diff --git a/docs/examples/notebooks/density_matrix.ipynb b/docs/examples/notebooks/density_matrix.ipynb new file mode 100644 index 0000000..f08a09d --- /dev/null +++ b/docs/examples/notebooks/density_matrix.ipynb @@ -0,0 +1 @@ +{"cells":[{"cell_type":"text","text":"

Symbolic Density Matrices

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":2},{"code":"from sympy import sqrt, symbols, Rational, S\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot\nfrom sympy.physics.quantum.densityOp import *","cell_type":"code","prompt_number":4},{"code":"state = Density([Qubit('00'),0.5],[(Qubit('00')+Qubit('11'))/sqrt(2),0.5]); state","cell_type":"code","prompt_number":6},{"code":"represent(state, nqubits=2)","cell_type":"code","prompt_number":7},{"code":"qapply(state.operate_on(HadamardGate(0)))\n","cell_type":"code","prompt_number":9},{"code":"state.entropy(nqubits=2)","cell_type":"code","prompt_number":10},{"code":"Density([Qubit('00'),1]).entropy(nqubits=2)\n","cell_type":"code","prompt_number":11},{"code":"%notebook save density_matrix.ipynb","cell_type":"code","prompt_number":16},{"code":"%notebook load qerror.ipynb","cell_type":"code","prompt_number":19}]} \ No newline at end of file diff --git a/docs/examples/notebooks/gate_rules.ipynb b/docs/examples/notebooks/gate_rules.ipynb new file mode 100644 index 0000000..bf3e8b4 --- /dev/null +++ b/docs/examples/notebooks/gate_rules.ipynb @@ -0,0 +1 @@ +{"cells":[{"cell_type":"text","text":"

Gate rules and circuit simplification

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot\nfrom sympy.physics.quantum.gaterules import *","cell_type":"code","prompt_number":2},{"code":"h0 = match_gate_rules(H(0))\nfor rule in h0:\n display(Eq(H(0),rule))","cell_type":"code","prompt_number":5},{"code":"z0 = match_gate_rules(Z(0))\nfor rule in z0:\n display(Eq(Z(0),rule))","cell_type":"code","prompt_number":7},{"code":"x0 = match_gate_rules(X(0))\nfor rule in x0:\n display(Eq(X(0),rule))","cell_type":"code","prompt_number":9},{"code":"circuit_plot(CNOT(1,0), nqubits=2)\n","cell_type":"code","prompt_number":10},{"code":"c10 = match_gate_rules(CNOT(1,0))","cell_type":"code","prompt_number":12},{"code":"circuit_plot(c10[8], nqubits=2)","cell_type":"code","prompt_number":13},{"code":"%notebook save gate_rules.ipynb","cell_type":"code","prompt_number":16},{"code":"","cell_type":"code","prompt_number":25}]} \ No newline at end of file diff --git a/docs/examples/notebooks/qft.ipynb b/docs/examples/notebooks/qft.ipynb index ce78109..a2c1e50 100644 --- a/docs/examples/notebooks/qft.ipynb +++ b/docs/examples/notebooks/qft.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"text","text":"

Quantum Fourier Transform

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

QFT Gate and Circuit

"},{"cell_type":"text","text":"Build a 3 qubit QFT and decompose it into primitive gates."},{"code":"fourier = QFT(0,3).decompose(); fourier\n","cell_type":"code","prompt_number":3},{"code":"circuit_plot(fourier, nqubits=3)","cell_type":"code","prompt_number":4},{"cell_type":"text","text":"The QFT circuit can be represented in various symbolic forms."},{"code":"m = represent(fourier, nqubits=3)","cell_type":"code","prompt_number":5},{"code":"m","cell_type":"code","prompt_number":6},{"code":"represent(Fourier(0,3), nqubits=3)*4/sqrt(2)\n","cell_type":"code","prompt_number":7},{"cell_type":"text","text":"

QFT in Action

"},{"cell_type":"text","text":"Build a 3 qubit state to take the QFT of."},{"code":"state = (Qubit('000') + Qubit('010') + Qubit('100') + Qubit('110'))/sqrt(4); state\n","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"Perform the QFT."},{"code":"qapply(fourier*state)\n","cell_type":"code","prompt_number":9},{"code":"%notebook save qft.ipynb","cell_type":"code","prompt_number":23},{"code":"%notebook load qerror.ipynb","cell_type":"code","prompt_number":207}]} \ No newline at end of file +{"cells":[{"cell_type":"text","text":"

Quantum Fourier Transform

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

QFT Gate and Circuit

"},{"cell_type":"text","text":"Build a 3 qubit QFT and decompose it into primitive gates."},{"code":"fourier = QFT(0,3).decompose(); fourier\n","cell_type":"code","prompt_number":3},{"code":"circuit_plot(fourier, nqubits=3)","cell_type":"code","prompt_number":4},{"cell_type":"text","text":"The QFT circuit can be represented in various symbolic forms."},{"code":"m = represent(fourier, nqubits=3)","cell_type":"code","prompt_number":5},{"code":"m","cell_type":"code","prompt_number":6},{"code":"represent(Fourier(0,3), nqubits=3)*4/sqrt(2)\n","cell_type":"code","prompt_number":7},{"cell_type":"text","text":"

QFT in Action

"},{"cell_type":"text","text":"Build a 3 qubit state to take the QFT of."},{"code":"state = (Qubit('000') + Qubit('010') + Qubit('100') + Qubit('110'))/sqrt(4); state\n","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"Perform the QFT."},{"code":"qapply(fourier*state)\n","cell_type":"code","prompt_number":9},{"code":"%notebook save qft.ipynb","cell_type":"code","prompt_number":23},{"code":"%notebook load density_matrix.ipynb","cell_type":"code","prompt_number":207}]} \ No newline at end of file diff --git a/docs/examples/notebooks/quantum_computing.ipynb b/docs/examples/notebooks/quantum_computing.ipynb index e610088..2451d7f 100644 --- a/docs/examples/notebooks/quantum_computing.ipynb +++ b/docs/examples/notebooks/quantum_computing.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"text","text":"

Symbolic Quantum Computing

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Qubits

"},{"code":"alpha, beta = symbols('alpha beta',real=True)","cell_type":"code","prompt_number":3},{"code":"psi = alpha*Qubit('00') + beta*Qubit('11'); psi\n","cell_type":"code","prompt_number":4},{"code":"Dagger(psi)\n","cell_type":"code","prompt_number":5},{"code":"qapply(Dagger(Qubit('00'))*psi)\n","cell_type":"code","prompt_number":6},{"cell_type":"text","text":"SymPy supports many different types of measurements."},{"code":"for state, prob in measure_all(psi):\n display(state)\n display(prob)\n","cell_type":"code","prompt_number":7},{"cell_type":"text","text":"Qubits can be represented in the computational basis."},{"code":"represent(psi)\n","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Gates

"},{"code":"g = X(0); g\n","cell_type":"code","prompt_number":9},{"code":"represent(g, nqubits=2)\n","cell_type":"code","prompt_number":10},{"code":"c = H(0)*Qubit('00'); c\n","cell_type":"code","prompt_number":11},{"code":"qapply(c)\n","cell_type":"code","prompt_number":12},{"cell_type":"text","text":"

Symbolic gate rules and circuit simplification

"},{"code":"for g1 in (Y,Z,H):\n for g2 in (Y,Z,H):\n e = Commutator(g1(0),g2(0))\n if g1 != g2:\n display(Eq(e,e.doit()))\n","cell_type":"code","prompt_number":13},{"code":"c = H(0)*X(1)*H(0)**2*CNOT(0,1)*X(1)**3*X(0)*Z(1)**2; c\n","cell_type":"code","prompt_number":14},{"code":"circuit_plot(c, nqubits=2)","cell_type":"code","prompt_number":15},{"cell_type":"text","text":"This performs a commutator/anticommutator aware bubble sort algorithm to simplify a circuit."},{"code":"gate_simp(c)\n","cell_type":"code","prompt_number":16},{"code":"circuit_plot(gate_simp(c),nqubits=2)","cell_type":"code","prompt_number":17},{"code":"%notebook save quantum_computing.ipynb","cell_type":"code","prompt_number":35},{"code":"%notebook load grovers.ipynb","cell_type":"code","prompt_number":90}]} \ No newline at end of file +{"cells":[{"cell_type":"text","text":"

Symbolic Quantum Computing

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from sympy import sqrt, symbols, Rational\nfrom sympy import expand, Eq, Symbol, simplify, exp, sin\nfrom sympy.physics.quantum import *\nfrom sympy.physics.quantum.qubit import *\nfrom sympy.physics.quantum.gate import *\nfrom sympy.physics.quantum.grover import *\nfrom sympy.physics.quantum.qft import QFT, IQFT, Fourier\nfrom sympy.physics.quantum.circuitplot import circuit_plot","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Qubits

"},{"code":"alpha, beta = symbols('alpha beta',real=True)","cell_type":"code","prompt_number":3},{"code":"psi = alpha*Qubit('00') + beta*Qubit('11'); psi\n","cell_type":"code","prompt_number":4},{"code":"Dagger(psi)\n","cell_type":"code","prompt_number":5},{"code":"qapply(Dagger(Qubit('00'))*psi)\n","cell_type":"code","prompt_number":6},{"cell_type":"text","text":"SymPy supports many different types of measurements."},{"code":"for state, prob in measure_all(psi):\n display(state)\n display(prob)\n","cell_type":"code","prompt_number":7},{"cell_type":"text","text":"Qubits can be represented in the computational basis."},{"code":"represent(psi)\n","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Gates

"},{"code":"g = X(0); g\n","cell_type":"code","prompt_number":9},{"code":"represent(g, nqubits=2)\n","cell_type":"code","prompt_number":10},{"code":"c = H(0)*Qubit('00'); c\n","cell_type":"code","prompt_number":11},{"code":"qapply(c)\n","cell_type":"code","prompt_number":12},{"code":"for gate in [H,X,Y,Z,S,T]:\n for state in [Qubit('0'),Qubit('1')]:\n lhs = gate(0)*state\n rhs = qapply(lhs)\n display(Eq(lhs,rhs))","cell_type":"code","prompt_number":13},{"cell_type":"text","text":"

Symbolic gate rules and circuit simplification

"},{"code":"for g1 in (Y,Z,H):\n for g2 in (Y,Z,H):\n e = Commutator(g1(0),g2(0))\n if g1 != g2:\n display(Eq(e,e.doit()))\n","cell_type":"code","prompt_number":14},{"code":"c = H(0)*X(1)*H(0)**2*CNOT(0,1)*X(1)**3*X(0)*Z(1)**2; c\n","cell_type":"code","prompt_number":15},{"code":"circuit_plot(c, nqubits=2)","cell_type":"code","prompt_number":16},{"cell_type":"text","text":"This performs a commutator/anticommutator aware bubble sort algorithm to simplify a circuit."},{"code":"gate_simp(c)\n","cell_type":"code","prompt_number":17},{"code":"circuit_plot(gate_simp(c),nqubits=2)","cell_type":"code","prompt_number":18},{"code":"%notebook save quantum_computing.ipynb","cell_type":"code","prompt_number":35},{"code":"%notebook load grovers.ipynb","cell_type":"code","prompt_number":90}]} \ No newline at end of file diff --git a/docs/examples/notebooks/sympy.ipynb b/docs/examples/notebooks/sympy.ipynb index 6bc312a..c1baaf8 100644 --- a/docs/examples/notebooks/sympy.ipynb +++ b/docs/examples/notebooks/sympy.ipynb @@ -1 +1 @@ -{"cells":[{"cell_type":"text","text":"

SymPy: Open Source Symbolic Mathematics

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":1},{"code":"from __future__ import division\nfrom sympy import *\nx, y, z = symbols(\"x y z\")\nk, m, n = symbols(\"k m n\", integer=True)\nf, g, h = map(Function, 'fgh')","cell_type":"code","prompt_number":2},{"cell_type":"text","text":"

Elementary operations

"},{"code":"Rational(3,2)*pi + exp(I*x) / (x**2 + y)\n","cell_type":"code","prompt_number":3},{"code":"exp(I*x).subs(x,pi).evalf()\n","cell_type":"code","prompt_number":4},{"code":"e = x + 2*y","cell_type":"code","prompt_number":5},{"code":"srepr(e)","cell_type":"code","prompt_number":6},{"code":"exp(pi * sqrt(163)).evalf(50)","cell_type":"code","prompt_number":7},{"cell_type":"text","text":"

Algebra

"},{"code":"((x+y)**2 * (x+1)).expand()","cell_type":"code","prompt_number":8},{"code":"a = 1/x + (x*sin(x) - 1)/x\ndisplay(a)\nsimplify(a)","cell_type":"code","prompt_number":9},{"code":"solve(Eq(x**3 + 2*x**2 + 4*x + 8, 0), x)","cell_type":"code","prompt_number":10},{"code":"a, b = symbols('a b')\nSum(6*n**2 + 2**n, (n, a, b))","cell_type":"code","prompt_number":11},{"cell_type":"text","text":"

Calculus

"},{"code":"limit((sin(x)-x)/x**3, x, 0)","cell_type":"code","prompt_number":12},{"code":"(1/cos(x)).series(x, 0, 6)","cell_type":"code","prompt_number":13},{"code":"diff(cos(x**2)**2 / (1+x), x)","cell_type":"code","prompt_number":14},{"code":"integrate(x**2 * cos(x), (x, 0, pi/2))","cell_type":"code","prompt_number":15},{"code":"eqn = Eq(Derivative(f(x),x,x) + 9*f(x), 1)\ndisplay(eqn)\ndsolve(eqn, f(x))","cell_type":"code","prompt_number":16},{"code":"%notebook save sympy.ipynb","cell_type":"code","prompt_number":40},{"code":"%notebook load basic_quantum.ipynb","cell_type":"code","prompt_number":41}]} \ No newline at end of file +{"cells":[{"cell_type":"text","text":"

SymPy: Open Source Symbolic Mathematics

"},{"code":"%load_ext sympyprinting","cell_type":"code","prompt_number":2},{"code":"from __future__ import division\nfrom sympy import *\nx, y, z = symbols(\"x y z\")\nk, m, n = symbols(\"k m n\", integer=True)\nf, g, h = map(Function, 'fgh')","cell_type":"code","prompt_number":3},{"cell_type":"text","text":"

Elementary operations

"},{"code":"Rational(3,2)*pi + exp(I*x) / (x**2 + y)\n","cell_type":"code","prompt_number":4},{"code":"exp(I*x).subs(x,pi).evalf()\n","cell_type":"code","prompt_number":5},{"code":"e = x + 2*y","cell_type":"code","prompt_number":6},{"code":"srepr(e)","cell_type":"code","prompt_number":7},{"code":"exp(pi * sqrt(163)).evalf(50)","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"

Algebra

"},{"code":"((x+y)**2 * (x+1)).expand()","cell_type":"code","prompt_number":9},{"code":"a = 1/x + (x*sin(x) - 1)/x\ndisplay(a)\nsimplify(a)","cell_type":"code","prompt_number":10},{"code":"solve(Eq(x**3 + 2*x**2 + 4*x + 8, 0), x)","cell_type":"code","prompt_number":11},{"code":"a, b = symbols('a b')\nSum(6*n**2 + 2**n, (n, a, b))","cell_type":"code","prompt_number":12},{"cell_type":"text","text":"

Calculus

"},{"code":"limit((sin(x)-x)/x**3, x, 0)","cell_type":"code","prompt_number":13},{"code":"(1/cos(x)).series(x, 0, 6)","cell_type":"code","prompt_number":14},{"code":"diff(cos(x**2)**2 / (1+x), x)","cell_type":"code","prompt_number":15},{"code":"integrate(x**2 * cos(x), (x, 0, pi/2))","cell_type":"code","prompt_number":16},{"code":"eqn = Eq(Derivative(f(x),x,x) + 9*f(x), 1)\ndisplay(eqn)\ndsolve(eqn, f(x))","cell_type":"code","prompt_number":17},{"code":"%notebook save sympy.ipynb","cell_type":"code","prompt_number":40},{"code":"%notebook load basic_quantum.ipynb","cell_type":"code","prompt_number":41}]} \ No newline at end of file