Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ketch/dcb4fb400e13315553a794b0f5561533 to your computer and use it in GitHub Desktop.
Save ketch/dcb4fb400e13315553a794b0f5561533 to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "f55ac2e6",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"TruncatedBSeries{RootedTree{Int64, Vector{Int64}}, Sym} with 18 entries:\n",
" RootedTree{Int64}: Int64[] => a_∅\n",
" RootedTree{Int64}: [1] => a_τ\n",
" RootedTree{Int64}: [1, 2] => a_[τ]\n",
" RootedTree{Int64}: [1, 2, 3] => a_[[τ]]\n",
" RootedTree{Int64}: [1, 2, 2] => a_[τ²]\n",
" RootedTree{Int64}: [1, 2, 3, 4] => a_[[[τ]]]\n",
" RootedTree{Int64}: [1, 2, 3, 3] => a_[[τ²]]\n",
" RootedTree{Int64}: [1, 2, 3, 2] => a_[[τ]τ]\n",
" RootedTree{Int64}: [1, 2, 2, 2] => a_[τ³]\n",
" RootedTree{Int64}: [1, 2, 3, 4, 5] => a_[[[[τ]]]]\n",
" RootedTree{Int64}: [1, 2, 3, 4, 4] => a_[[[τ²]]]\n",
" RootedTree{Int64}: [1, 2, 3, 4, 3] => a_[[[τ]τ]]\n",
" RootedTree{Int64}: [1, 2, 3, 4, 2] => a_[[[τ]]τ]\n",
" RootedTree{Int64}: [1, 2, 3, 3, 3] => a_[[τ³]]\n",
" RootedTree{Int64}: [1, 2, 3, 3, 2] => a_[[τ²]τ]\n",
" RootedTree{Int64}: [1, 2, 3, 2, 3] => a_[[τ][τ]]\n",
" RootedTree{Int64}: [1, 2, 3, 2, 2] => a_[[τ]τ²]\n",
" RootedTree{Int64}: [1, 2, 2, 2, 2] => a_[τ⁴]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using BSeries, SymPy\n",
"\n",
"series = bseries(5) do t, series\n",
" return symbols(\"a_$(butcher_representation(t))\", real=true)\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "cdb62320",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"TruncatedBSeries{RootedTree{Int64, Vector{Int64}}, Sym} with 18 entries:\n",
" RootedTree{Int64}: Int64[] => 0\n",
" RootedTree{Int64}: [1] => a_τ\n",
" RootedTree{Int64}: [1, 2] => a_[τ] - a_τ^2/2\n",
" RootedTree{Int64}: [1, 2, 3] => a_[[τ]] - a_τ^3/6 - a_τ*(a_[τ]/2 - a_τ^…\n",
" RootedTree{Int64}: [1, 2, 2] => a_[τ²] - a_τ^3/3 - a_τ*(a_[τ] - a_τ^2/2)\n",
" RootedTree{Int64}: [1, 2, 3, 4] => a_[[[τ]]] - a_τ^4/24 - a_τ^2*(a_[τ]/6 -…\n",
" RootedTree{Int64}: [1, 2, 3, 3] => a_[[τ²]] - a_τ^4/12 - 2*a_τ^2*(a_[τ] - …\n",
" RootedTree{Int64}: [1, 2, 3, 2] => a_[[τ]τ] - a_τ^4/8 - 5*a_τ^2*(a_[τ] - a…\n",
" RootedTree{Int64}: [1, 2, 2, 2] => a_[τ³] - a_τ^4/4 - a_τ^2*(a_[τ] - a_τ^2…\n",
" RootedTree{Int64}: [1, 2, 3, 4, 5] => a_[[[[τ]]]] - a_τ^5/120 - a_τ^3*(a_[τ]/…\n",
" RootedTree{Int64}: [1, 2, 3, 4, 4] => a_[[[τ²]]] - a_τ^5/60 - a_τ^3*(a_[τ] - …\n",
" RootedTree{Int64}: [1, 2, 3, 4, 3] => a_[[[τ]τ]] - a_τ^5/40 - a_τ^3*(a_[τ] - …\n",
" RootedTree{Int64}: [1, 2, 3, 4, 2] => a_[[[τ]]τ] - a_τ^5/30 - 5*a_τ^3*(a_[τ] …\n",
" RootedTree{Int64}: [1, 2, 3, 3, 3] => a_[[τ³]] - a_τ^5/20 - a_τ^3*(a_[τ] - a_…\n",
" RootedTree{Int64}: [1, 2, 3, 3, 2] => a_[[τ²]τ] - a_τ^5/15 - 7*a_τ^3*(a_[τ] -…\n",
" RootedTree{Int64}: [1, 2, 3, 2, 3] => a_[[τ][τ]] - a_τ^5/20 - a_τ^3*(a_[τ]/8 …\n",
" RootedTree{Int64}: [1, 2, 3, 2, 2] => a_[[τ]τ²] - a_τ^5/10 - 3*a_τ^3*(a_[τ] -…\n",
" RootedTree{Int64}: [1, 2, 2, 2, 2] => a_[τ⁴] - a_τ^5/5 - a_τ^3*(a_[τ] - a_τ^2…"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"modeqn = modified_equation(series)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "bbc7952d",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$a_{[[τ]]} - a_{[τ]} a_{τ} + \\frac{a_{τ}^{3}}{3}$"
],
"text/plain": [
" 3\n",
" a_τ \n",
"a_[[τ]] - a_[τ]⋅a_τ + ────\n",
" 3 "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(modeqn[RootedTree([1,2,3])])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "c59e533f",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$- a_{[τ]} a_{τ} + a_{[τ²]} + \\frac{a_{τ}^{3}}{6}$"
],
"text/plain": [
" 3\n",
" a_τ \n",
"-a_[τ]⋅a_τ + a_[τ²] + ────\n",
" 6 "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"simplify(modeqn[RootedTree([1,2,2])])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.7.2",
"language": "julia",
"name": "julia-1.7"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment