Last active
August 6, 2019 09:26
-
-
Save aakhmetz/38abbdcf3edd22610fbfec1ace9586e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$\\displaystyle \\left[\\begin{matrix}- \\kappa & 0 & 0 & 0 & 0\\\\\\kappa & - \\gamma - \\tau & 0 & 0 & 0\\\\0 & \\tau & - \\gamma & 0 & 0\\\\0 & \\gamma m & 0 & - \\omega_{I} & 0\\\\0 & 0 & \\epsilon \\gamma m & 0 & - \\omega_{H}\\end{matrix}\\right]$" | |
], | |
"text/plain": [ | |
"⎡-κ 0 0 0 0 ⎤\n", | |
"⎢ ⎥\n", | |
"⎢κ -γ - τ 0 0 0 ⎥\n", | |
"⎢ ⎥\n", | |
"⎢0 τ -γ 0 0 ⎥\n", | |
"⎢ ⎥\n", | |
"⎢0 γ⋅m 0 -ω_I 0 ⎥\n", | |
"⎢ ⎥\n", | |
"⎣0 0 ε⋅γ⋅m 0 -ω_H⎦" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import sympy as sym\n", | |
"\n", | |
"# Not necessary but gives nice-looking latex output\n", | |
"# More info at: http://docs.sympy.org/latest/tutorial/printing.html\n", | |
"sym.init_printing()\n", | |
"\n", | |
"kappa, gamma, tau, gamma, m, omega_I, omega_H, epsilon = sym.symbols('kappa gamma tau gamma, m omega_I omega_H epsilon')\n", | |
"matrix = sym.Matrix([[-kappa,0,0,0,0], \n", | |
" [kappa,-gamma-tau,0,0,0],\n", | |
" [0,tau,-gamma,0,0],\n", | |
" [0,gamma*m,0,-omega_I,0],\n", | |
" [0,0,epsilon*gamma*m,0,-omega_H]])\n", | |
"\n", | |
"matrix" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/latex": [ | |
"$\\displaystyle \\left[\\begin{matrix}- \\frac{1}{\\kappa} & 0 & 0 & 0 & 0\\\\\\frac{1}{- \\gamma - \\tau} & \\frac{1}{- \\gamma - \\tau} & 0 & 0 & 0\\\\\\frac{\\tau}{\\gamma \\left(- \\gamma - \\tau\\right)} & \\frac{\\tau}{\\gamma \\left(- \\gamma - \\tau\\right)} & - \\frac{1}{\\gamma} & 0 & 0\\\\\\frac{\\gamma m}{\\omega_{I} \\left(- \\gamma - \\tau\\right)} & \\frac{\\gamma m}{\\omega_{I} \\left(- \\gamma - \\tau\\right)} & 0 & - \\frac{1}{\\omega_{I}} & 0\\\\\\frac{\\epsilon m \\tau}{\\omega_{H} \\left(- \\gamma - \\tau\\right)} & \\frac{\\epsilon m \\tau}{\\omega_{H} \\left(- \\gamma - \\tau\\right)} & - \\frac{\\epsilon m}{\\omega_{H}} & 0 & - \\frac{1}{\\omega_{H}}\\end{matrix}\\right]$" | |
], | |
"text/plain": [ | |
"⎡ -1 ⎤\n", | |
"⎢ ─── 0 0 0 0 ⎥\n", | |
"⎢ κ ⎥\n", | |
"⎢ ⎥\n", | |
"⎢ 1 1 ⎥\n", | |
"⎢ ────── ────── 0 0 0 ⎥\n", | |
"⎢ -γ - τ -γ - τ ⎥\n", | |
"⎢ ⎥\n", | |
"⎢ τ τ -1 ⎥\n", | |
"⎢ ────────── ────────── ─── 0 0 ⎥\n", | |
"⎢ γ⋅(-γ - τ) γ⋅(-γ - τ) γ ⎥\n", | |
"⎢ ⎥\n", | |
"⎢ γ⋅m γ⋅m -1 ⎥\n", | |
"⎢──────────── ──────────── 0 ─── 0 ⎥\n", | |
"⎢ω_I⋅(-γ - τ) ω_I⋅(-γ - τ) ω_I ⎥\n", | |
"⎢ ⎥\n", | |
"⎢ ε⋅m⋅τ ε⋅m⋅τ -ε⋅m -1 ⎥\n", | |
"⎢──────────── ──────────── ───── 0 ───⎥\n", | |
"⎣ω_H⋅(-γ - τ) ω_H⋅(-γ - τ) ω_H ω_H⎦" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"matrix.inv()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment