Added section on polynomial evaluation to the notebook
This commit is contained in:
1
docs/.envrc
Normal file
1
docs/.envrc
Normal file
@@ -0,0 +1 @@
|
||||
eval "$(lorri direnv)"
|
||||
@@ -466,7 +466,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 20,
|
||||
"id": "dab40dd2-2b62-4445-9a7a-4b02ae87fef0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -488,7 +488,7 @@
|
||||
" MP_FRAC = 8 # 8 fractional bits\n",
|
||||
" MP_TICK_PER_SEC = 5000\n",
|
||||
" MP_MM_PER_STEP = 0.000\n",
|
||||
" MP_AMAX = int(\n",
|
||||
" MP_AMAX = 1\n",
|
||||
" "
|
||||
]
|
||||
},
|
||||
@@ -515,6 +515,53 @@
|
||||
"Thus, our fundamental distance unit is that such that $j_{max} = 6$"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8cca2b8a-42a6-41c7-b0c6-eed4fd33342b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Polynomial evaluation\n",
|
||||
"\n",
|
||||
"As our position equation is a polynomial, we can evaluate it quickly at successive positions using the method of finite differences.\n",
|
||||
"A semi-naiive evaluation of the formula would take 6 multiplications and 4 additions, whereas FD results in only the four additions.\n",
|
||||
"\n",
|
||||
"The differences can be calculated as follows:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"id": "f8c41a01-fe9c-495c-8644-600ce88ee2e8",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/latex": [
|
||||
"$\\displaystyle \\left\\{ FD_{0} : \\frac{a_{0}}{2} + \\frac{j}{6} + v_{0}, \\ FD_{1} : a_{0} + j, \\ FD_{2} : j\\right\\}$"
|
||||
],
|
||||
"text/plain": [
|
||||
"⎧ a₀ j ⎫\n",
|
||||
"⎨FD₀: ── + ─ + v₀, FD₁: a₀ + j, FD₂: j⎬\n",
|
||||
"⎩ 2 6 ⎭"
|
||||
]
|
||||
},
|
||||
"execution_count": 21,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"eq1 = seg_d()['dp']\n",
|
||||
"def fd(eqn, var=t):\n",
|
||||
" return (eqn.subs(var, var+1) - eqn).simplify()\n",
|
||||
" \n",
|
||||
"fd1 = fd(eq1)\n",
|
||||
"fd2 = fd(fd1)\n",
|
||||
"fd3 = fd(fd2)\n",
|
||||
"\n",
|
||||
"{sympy.Symbol(f\"FD_{i}\"): e.subs(t,0).simplify() for i, e in enumerate([fd1, fd2, fd3])}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d8b4e4c3-f76f-4de7-a570-c28a462f0283",
|
||||
@@ -550,7 +597,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.9.11"
|
||||
"version": "3.9.10"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
22
docs/shell.nix
Normal file
22
docs/shell.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
|
||||
let
|
||||
pythonPackages = pkgs.python3.withPackages (p: with p; [
|
||||
ipython
|
||||
jupyterlab
|
||||
scipy
|
||||
sympy
|
||||
bokeh
|
||||
bkcharts
|
||||
]);
|
||||
in
|
||||
|
||||
pkgs.mkShell {
|
||||
|
||||
buildInputs = [
|
||||
pythonPackages
|
||||
|
||||
# keep this line if you use bash
|
||||
pkgs.bashInteractive
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user