Skip to content

Instantly share code, notes, and snippets.

@ketch
Created May 17, 2022 06:21
Show Gist options
  • Save ketch/d3106318fd74433a271f12e6fb098d02 to your computer and use it in GitHub Desktop.
Save ketch/d3106318fd74433a271f12e6fb098d02 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"using BSeries\n",
"using Latexify\n",
"using RootedTrees\n",
"using Symbolics\n",
"import SymPy; sp=SymPy;"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$F_{f}\\mathopen{}\\left( \\varnothing \\right)\\mathclose{} + h F_{f}\\mathopen{}\\left( \\rootedtree[] \\right)\\mathclose{} + \\frac{h^{2}}{2} F_{f}\\mathopen{}\\left( \\rootedtree[[]] \\right)\\mathclose{} + \\frac{h^{3}}{8 \\alpha} F_{f}\\mathopen{}\\left( \\rootedtree[[][]] \\right)\\mathclose{}$"
],
"text/plain": [
"L\"$F_{f}\\mathopen{}\\left( \\varnothing \\right)\\mathclose{} + h F_{f}\\mathopen{}\\left( \\rootedtree[] \\right)\\mathclose{} + \\frac{h^{2}}{2} F_{f}\\mathopen{}\\left( \\rootedtree[[]] \\right)\\mathclose{} + \\frac{h^{3}}{8 \\alpha} F_{f}\\mathopen{}\\left( \\rootedtree[[][]] \\right)\\mathclose{}$\""
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"α = sp.symbols(\"α\", real=true)\n",
"A = [0 0; 1/(2*α) 0]; b = [1-α, α]; c = [0, 1/(2*α)]\n",
"coeffs = bseries(A,b,c,3)\n",
"latexify(coeffs, cdot=false)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"ename": "LoadError",
"evalue": "OverflowError: -499541949138073 * 25441 overflowed for type Int64",
"output_type": "error",
"traceback": [
"OverflowError: -499541949138073 * 25441 overflowed for type Int64",
"",
"Stacktrace:",
" [1] throw_overflowerr_binaryop(op::Symbol, x::Int64, y::Int64)",
" @ Base.Checked ./checked.jl:154",
" [2] checked_mul",
" @ ./checked.jl:288 [inlined]",
" [3] +(x::Rational{Int64}, y::Rational{Int64})",
" @ Base ./rational.jl:286",
" [4] dot(x::Vector{Rational{Int64}}, y::Vector{Rational{Int64}})",
" @ LinearAlgebra /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/generic.jl:916",
" [5] elementary_weight",
" @ ~/.julia/packages/RootedTrees/J2eWh/src/RootedTrees.jl:1223 [inlined]",
" [6] bseries(A::Matrix{Rational{Int64}}, b::Vector{Rational{Int64}}, c::Vector{Rational{Int64}}, order::Int64)",
" @ BSeries ~/.julia/packages/BSeries/Uz1I9/src/BSeries.jl:210",
" [7] top-level scope",
" @ In[3]:5",
" [8] eval",
" @ ./boot.jl:360 [inlined]",
" [9] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)",
" @ Base ./loading.jl:1116"
]
}
],
"source": [
"A = [0 0 0 0 0 0 0 0;(-1//6) (1//2) 0 0 0 0 0 0;(-1//10) (1//10) (1//2) 0 0 0 0 0;(-21463//39375) (21017//26250) (-5//9) (1//2) 0 0 0 0;(-59588//54675) (118717//36450) (-4375//2187) 0 (1//2) 0 0 0;(-19993033//9443328) (28508695//3147776) (-13577105//2360832) (-4090625//3147776) (1136025//3147776) (1//2) 0 0;(367020141781//199294617600) (814214904871//22143846400) (-29834937659//1992946176) (-1983358776875//87689631744) (-6702625935//885753856) (688576//109395) (1//2) 0;(1081252805//134140608) (2639189439//74522560) (33646441//4191894) (-7873511875//210792384) (-504040617//14904512) (2110843561//115277085) (13//7) (1//2)];\n",
"b = [(1081252805//134140608),(2639189439//74522560),(33646441//4191894),(-7873511875//210792384),(-504040617//14904512),(2110843561//115277085),(13//7),(1//2)];\n",
"c = [0,(1//3),(1//2),(1//5),(2//3),(3//4),(1//4),1];\n",
"\n",
"coeffs = bseries(A,b,c,5)\n",
"latexify(coeffs, cdot=false)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.6.3",
"language": "julia",
"name": "julia-1.6"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.6.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment