Download notebook
Inspect locally

Do not run the notebook before reviewing it. Verify the archive, then use KaimonSlate's inactive view, which does not start a worker or evaluate cells.

using DocumenterSlate
verify_slate_bundle("giac_intro.tar.gz")
using KaimonSlate
KaimonSlate.serve_notebook("giac_intro.jl"; inactive = true)
Download and inspect safely

This notebook is arbitrary code. Instantiating its environment may run package build scripts, and live opening may execute cells.

Download source · Checksums · Provenance · Local instructions

Verify after downloading the directory: sha256sum -c SHA256SUMS.

Inspect without starting a worker or executing cells:

using KaimonSlate
KaimonSlate.serve_notebook("giac_intro.jl"; inactive = true)
ArtifactSHA-256
Dockerfileae39430b941dd157fbe23edbf18f040cb63023eeb459397a6ead1c0bf6df687d
Manifest.tomlf2810a9c1f516c881f51e12fab61cc4585349cfe850622943394aa8a08efc065
PROVENANCE.toml82cbb4149f1a8d61324fe1df3050c76aedd3f86b746af3fa4e057dd8f4a55e37
Project.toml47810962ec0e39b7dd20de00dcef692ba653519f69bb872450bf0eaa67688d07
README.md20b3f398028cb6ae7cadab4e5d9c11296c0da7afc7388af1b742c40620c4e0c0
devcontainer.json7738cb88b4a6e4848d4545f555750df97fe66b5137f84be8931bc06eb368682e
giac_intro.jl3eb63acbad5e77d998fb649e7ffbcc812e9e5b315b01e25b46887c47a3fb5d44
giac_intro.tar.gz2f85ec84fd315fa1d6b4ebad428171d4ab2b37d415e70e151cd8bb79efb3fc72
Giac ready — variables x, a, t, s; helpers tex / mathblock / taylor_poly loaded.

Symbolic Computation with Giac.jl

A computer algebra system, live in a Slate notebook

Giac (the engine behind Xcas) gives us exact algebra, calculus, and linear algebra. Here we drive it from Julia through Giac.jl and let Slate render every result as typeset mathematics — no floating-point roundoff anywhere below.

1. Algebra — exact, not approximate

Factoring, expanding, simplifying, and partial-fraction decomposition all return closed forms, which Slate typesets directly.

mathblock([
    "x^4 - 1 &= " * tex(factor(x^4 - 1)),
    "(x+2)^4 &= " * tex(expand((x + 2)^4)),
    "\\frac{x^2+3x+2}{x+1} &= " * tex(simplify((x^2 + 3x + 2) / (x + 1))),
    "\\frac{1}{x^2-1} &= " * tex(partfrac(1 / (x^2 - 1))),
])
$$
\begin{aligned}x^4 - 1 &= \left(x-1\right) \left(x+1\right) \left(x^{2}+1\right) \\[6pt] (x+2)^4 &= x^{4}+8 x^{3}+24 x^{2}+32 x+16 \\[6pt] \frac{x^2+3x+2}{x+1} &= x+2 \\[6pt] \frac{1}{x^2-1} &= \frac{1}{2 \left(x-1\right)}-\frac{1}{2 \left(x+1\right)}\end{aligned}
$$

Equation solving returns exact roots — rational, irrational, and complex.

# Exact roots, including irrational and complex ones
mathblock([
    "x^2 - 5x + 6 = 0 &\\;\\Rightarrow\\; x \\in " * tex(solve(x^2 - 5x + 6, x)),
    "x^2 - 2 = 0 &\\;\\Rightarrow\\; x \\in " * tex(solve(x^2 - 2, x)),
    "x^2 + 1 = 0 &\\;\\Rightarrow\\; x \\in " * tex(solve(x^2 + 1, x)),
    "x^3 - x = 0 &\\;\\Rightarrow\\; x \\in " * tex(solve(x^3 - x, x)),
])
$$
\begin{aligned}x^2 - 5x + 6 = 0 &\;\Rightarrow\; x \in \left[2,3\right] \\[6pt] x^2 - 2 = 0 &\;\Rightarrow\; x \in \left[-\sqrt{2},\sqrt{2}\right] \\[6pt] x^2 + 1 = 0 &\;\Rightarrow\; x \in \left[\right] \\[6pt] x^3 - x = 0 &\;\Rightarrow\; x \in \left[-1,0,1\right]\end{aligned}
$$

2. Calculus — derivatives, integrals, limits

The engine differentiates and integrates in closed form and evaluates limits, including improper ones.

f = x * sin(x)
mathblock([
    "\\frac{d}{dx}\\,x\\sin x &= " * tex(diff(f, x)),
    "\\int x\\,e^{x}\\,dx &= " * tex(integrate(x * exp(x), x)),
    "\\int_{0}^{\\pi}\\sin x\\,dx &= " * tex(integrate(sin(x), x, 0, Giac.giac_eval("pi"))),
    "\\lim_{x\\to 0}\\frac{\\sin x}{x} &= " * tex(limit(sin(x) / x, x, 0)),
    "\\lim_{x\\to\\infty}\\left(1+\\tfrac{1}{x}\\right)^{x} &= " * tex(limit((1 + 1/x)^x, x, Inf)),
])
$$
\begin{aligned}\frac{d}{dx}\,x\sin x &= \sin x+x \cos x \\[6pt] \int x\,e^{x}\,dx &= x \mathrm{e}^{x}-\mathrm{e}^{x} \\[6pt] \int_{0}^{\pi}\sin x\,dx &= 2 \\[6pt] \lim_{x\to 0}\frac{\sin x}{x} &= 1 \\[6pt] \lim_{x\to\infty}\left(1+\tfrac{1}{x}\right)^{x} &= \mathrm{e}\end{aligned}
$$

3. Interactive: Taylor series, live

Pick a function and a truncation order. Giac computes the Taylor polynomial about $x = 0$ symbolically; we compile it to a Julia function with build_function and plot it against the exact curve. Push the order up and watch the polynomial hug the true function — then notice how $\arctan x$ still diverges past its radius of convergence $|x| = 1$, no matter how many terms you add.

@bind fkey Select(["sin(x)" => "sin x", "cos(x)" => "cos x",
                   "exp(x)" => "exp x", "atan(x)" => "arctan x"];
                  label="f(x)")
@bind ord Slider(1:2:15; default=5, label="order n")

fexpr  = Giac.giac_eval(fkey.value)
poly   = taylor_poly(fexpr, ord)
approx = build_function(poly, x)
truef  = build_function(fexpr, x)

xs   = collect(range(-3, 3; length=241))
ytru = truef.(xs)
yapp = approx.(xs)

# keep the view framed on the true curve even when the series runs off
ymax = maximum(abs, ytru) * 1.6
yapp = clamp.(yapp, -ymax, ymax)

echart(series(:line, xs, ytru; name="f(x) = $(fkey.value)", smooth=true, symbol="none"),
       series(:line, xs, yapp; name="Taylor, order $ord", smooth=true, symbol="none",
              lineStyle=(type=:dashed, width=2));
       legend=true, title="Taylor approximation about x = 0",
       yAxis=(min=round(-ymax; digits=2), max=round(ymax; digits=2)),
       height=420)
KaimonSlate.ReportEngine.EChart(Dict{String, Any}("xAxis" => Dict{String, Any}("type" => "value"), "animationDurationUpdate" => 300, "__size" => Dict{String, Any}("height" => 420), "series" => Dict{String, Any}[Dict("name" => "f(x) = sin(x)", "data" => [[-3.0, -0.14112000806], [-2.975, -0.165823144744], [-2.95, -0.190422647361], [-2.925, -0.214903142022], [-2.9, -0.239249329214], [-2.875, -0.263445993363], [-2.85, -0.287478012343], [-2.825, -0.311330366922], [-2.8, -0.334988150156], [-2.775, -0.358436576701], [-2.75, -0.381660992052], [-2.725, -0.404646881708], [-2.7, -0.427379880234], [-2.675, -0.449845780247], [-2.65, -0.47203054129], [-2.625, -0.49392029861], [-2.6, -0.515501371821], [-2.575, -0.536760273456], [-2.55, -0.557683717391], [-2.525, -0.578258627157], [-2.5, -0.598472144104], [-2.475, -0.618311635442], [-2.45, -0.637764702135], [-2.425, -0.656819186648], [-2.4, -0.675463180551], [-2.375, -0.693685031953], [-2.35, -0.711473352791], [-2.325, -0.728817025942], [-2.3, -0.745705212177], [-2.275, -0.762127356927], [-2.25, -0.778073196888], [-2.225, -0.793532766428], [-2.2, -0.80849640382], [-2.175, -0.822954757277], [-2.15, -0.836898790799], [-2.125, -0.850319789818], [-2.1, -0.863209366649], [-2.075, -0.875559465724], [-2.05, -0.887362368633], [-2.025, -0.898610698947], [-2.0, -0.909297426826], [-1.975, -0.919415873411], [-1.95, -0.928959715004], [-1.925, -0.937922987014], [-1.9, -0.946300087687], [-1.875, -0.95408578161], [-1.85, -0.961275202975], [-1.825, -0.96786385863], [-1.8, -0.973847630878], [-1.775, -0.979222780057], [-1.75, -0.983985946874], [-1.725, -0.988134154504], [-1.7, -0.991664810452], [-1.675, -0.994575708175], [-1.65, -0.996865028454], [-1.625, -0.99853134054], [-1.6, -0.999573603042], [-1.575, -0.999991164579], [-1.55, -0.999783764189], [-1.525, -0.998951531492], [-1.5, -0.997494986604], [-1.475, -0.99541503982], [-1.45, -0.992712991038], [-1.425, -0.98939052895], [-1.4, -0.985449729988], [-1.375, -0.980893057023], [-1.35, -0.975723357827], [-1.325, -0.969943863293], [-1.3, -0.963558185417], [-1.275, -0.956570315041], [-1.25, -0.948984619356], [-1.225, -0.940805839174], [-1.2, -0.932039085967], [-1.175, -0.922689838671], [-1.15, -0.912763940261], [-1.125, -0.902267594099], [-1.1, -0.891207360061], [-1.075, -0.879590150434], [-1.05, -0.867423225594], [-1.025, -0.854714189474], [-1.0, -0.841470984808], [-0.975, -0.827701888167], [-0.95, -0.813415504789], [-0.925, -0.798620763199], [-0.9, -0.783326909627], [-0.875, -0.767543502236], [-0.85, -0.75128040514], [-0.825, -0.734547782247], [-0.8, -0.7173560909], [-0.775, -0.699716075347], [-0.75, -0.681638760023], [-0.725, -0.663135442663], [-0.7, -0.644217687238], [-0.675, -0.624897316728], [-0.65, -0.605186405736], [-0.625, -0.58509727294], [-0.6, -0.564642473395], [-0.575, -0.543834790684], [-0.55, -0.522687228931], [-0.525, -0.501213004674], [-0.5, -0.479425538604], [-0.475, -0.457338447179], [-0.45, -0.434965534111], [-0.425, -0.412320781743], [-0.4, -0.389418342309], [-0.375, -0.366272529086], [-0.35, -0.342897807455], [-0.325, -0.319308785857], [-0.3, -0.295520206661], [-0.275, -0.271546936956], [-0.25, -0.247403959255], [-0.225, -0.223106362132], [-0.2, -0.198669330795], [-0.175, -0.174108137594], [-0.15, -0.149438132474], [-0.125, -0.124674733385], [-0.1, -0.0998334166468], [-0.075, -0.0749297072727], [-0.05, -0.0499791692707], [-0.025, -0.0249973959147], [0.0, 0.0], [0.025, 0.0249973959147], [0.05, 0.0499791692707], [0.075, 0.0749297072727], [0.1, 0.0998334166468], [0.125, 0.124674733385], [0.15, 0.149438132474], [0.175, 0.174108137594], [0.2, 0.198669330795], [0.225, 0.223106362132], [0.25, 0.247403959255], [0.275, 0.271546936956], [0.3, 0.295520206661], [0.325, 0.319308785857], [0.35, 0.342897807455], [0.375, 0.366272529086], [0.4, 0.389418342309], [0.425, 0.412320781743], [0.45, 0.434965534111], [0.475, 0.457338447179], [0.5, 0.479425538604], [0.525, 0.501213004674], [0.55, 0.522687228931], [0.575, 0.543834790684], [0.6, 0.564642473395], [0.625, 0.58509727294], [0.65, 0.605186405736], [0.675, 0.624897316728], [0.7, 0.644217687238], [0.725, 0.663135442663], [0.75, 0.681638760023], [0.775, 0.699716075347], [0.8, 0.7173560909], [0.825, 0.734547782247], [0.85, 0.75128040514], [0.875, 0.767543502236], [0.9, 0.783326909627], [0.925, 0.798620763199], [0.95, 0.813415504789], [0.975, 0.827701888167], [1.0, 0.841470984808], [1.025, 0.854714189474], [1.05, 0.867423225594], [1.075, 0.879590150434], [1.1, 0.891207360061], [1.125, 0.902267594099], [1.15, 0.912763940261], [1.175, 0.922689838671], [1.2, 0.932039085967], [1.225, 0.940805839174], [1.25, 0.948984619356], [1.275, 0.956570315041], [1.3, 0.963558185417], [1.325, 0.969943863293], [1.35, 0.975723357827], [1.375, 0.980893057023], [1.4, 0.985449729988], [1.425, 0.98939052895], [1.45, 0.992712991038], [1.475, 0.99541503982], [1.5, 0.997494986604], [1.525, 0.998951531492], [1.55, 0.999783764189], [1.575, 0.999991164579], [1.6, 0.999573603042], [1.625, 0.99853134054], [1.65, 0.996865028454], [1.675, 0.994575708175], [1.7, 0.991664810452], [1.725, 0.988134154504], [1.75, 0.983985946874], [1.775, 0.979222780057], [1.8, 0.973847630878], [1.825, 0.96786385863], [1.85, 0.961275202975], [1.875, 0.95408578161], [1.9, 0.946300087687], [1.925, 0.937922987014], [1.95, 0.928959715004], [1.975, 0.919415873411], [2.0, 0.909297426826], [2.025, 0.898610698947], [2.05, 0.887362368633], [2.075, 0.875559465724], [2.1, 0.863209366649], [2.125, 0.850319789818], [2.15, 0.836898790799], [2.175, 0.822954757277], [2.2, 0.80849640382], [2.225, 0.793532766428], [2.25, 0.778073196888], [2.275, 0.762127356927], [2.3, 0.745705212177], [2.325, 0.728817025942], [2.35, 0.711473352791], [2.375, 0.693685031953], [2.4, 0.675463180551], [2.425, 0.656819186648], [2.45, 0.637764702135], [2.475, 0.618311635442], [2.5, 0.598472144104], [2.525, 0.578258627157], [2.55, 0.557683717391], [2.575, 0.536760273456], [2.6, 0.515501371821], [2.625, 0.49392029861], [2.65, 0.47203054129], [2.675, 0.449845780247], [2.7, 0.427379880234], [2.725, 0.404646881708], [2.75, 0.381660992052], [2.775, 0.358436576701], [2.8, 0.334988150156], [2.825, 0.311330366922], [2.85, 0.287478012343], [2.875, 0.263445993363], [2.9, 0.239249329214], [2.925, 0.214903142022], [2.95, 0.190422647361], [2.975, 0.165823144744], [3.0, 0.14112000806]], "smooth" => true, "symbol" => "none", "type" => "line"), Dict("name" => "Taylor, order 5", "data" => [[-3.0, -0.525], [-2.975, -0.528584684163], [-2.95, -0.533052861979], [-2.925, -0.538351591553], [-2.9, -0.544429083333], [-2.875, -0.551234690348], [-2.85, -0.558718898438], [-2.825, -0.566833316488], [-2.8, -0.575530666667], [-2.775, -0.584764774658], [-2.75, -0.594490559896], [-2.725, -0.604664025798], [-2.7, -0.61524225], [-2.675, -0.626183374593], [-2.65, -0.637446596354], [-2.625, -0.648992156982], [-2.6, -0.660781333333], [-2.575, -0.672776427653], [-2.55, -0.684940757813], [-2.525, -0.697238647542], [-2.5, -0.709635416667], [-2.475, -0.722097371338], [-2.45, -0.734591794271], [-2.425, -0.747086934977], [-2.4, -0.759552], [-2.375, -0.771957143148], [-2.35, -0.784273455729], [-2.325, -0.796472956787], [-2.3, -0.808528583333], [-2.275, -0.820414180583], [-2.25, -0.832104492187], [-2.225, -0.843575150472], [-2.2, -0.854802666667], [-2.175, -0.865764421143], [-2.15, -0.876438653646], [-2.125, -0.886804453532], [-2.1, -0.89684175], [-2.075, -0.906531302327], [-2.05, -0.915854690104], [-2.025, -0.924794303467], [-2.0, -0.933333333333], [-1.975, -0.941455761637], [-1.95, -0.949146351563], [-1.925, -0.956390637777], [-1.9, -0.963174916667], [-1.875, -0.969486236572], [-1.85, -0.975312388021], [-1.825, -0.980641893962], [-1.8, -0.985464], [-1.775, -0.989768664632], [-1.75, -0.993546549479], [-1.725, -0.996789009521], [-1.7, -0.999488083333], [-1.675, -1.00163648332], [-1.65, -1.00322758594], [-1.625, -1.00425542196], [-1.6, -1.00471466667], [-1.575, -1.00460063013], [-1.55, -1.0039092474], [-1.525, -1.00263706877], [-1.5, -1.00078125], [-1.475, -0.998339542562], [-1.45, -0.995310283854], [-1.425, -0.991692387451], [-1.4, -0.987485333333], [-1.375, -0.982689158122], [-1.35, -0.977304445313], [-1.325, -0.971332315511], [-1.3, -0.964774416667], [-1.275, -0.957632914307], [-1.25, -0.949910481771], [-1.225, -0.941610290446], [-1.2, -0.932736], [-1.175, -0.923291748617], [-1.15, -0.913282143229], [-1.125, -0.902712249756], [-1.1, -0.891587583333], [-1.075, -0.879914098551], [-1.05, -0.867698179687], [-1.025, -0.854946630941], [-1.0, -0.841666666667], [-0.975, -0.827865901611], [-0.95, -0.813552341146], [-0.925, -0.798734371501], [-0.9, -0.78342075], [-0.875, -0.767620595296], [-0.85, -0.751343377604], [-0.825, -0.734598908936], [-0.8, -0.717397333333], [-0.775, -0.699749117106], [-0.75, -0.681665039062], [-0.725, -0.663156180745], [-0.7, -0.644233916667], [-0.675, -0.624909904541], [-0.65, -0.605196075521], [-0.625, -0.58510462443], [-0.6, -0.564648], [-0.575, -0.543838895101], [-0.55, -0.522690236979], [-0.525, -0.50121517749], [-0.5, -0.479427083333], [-0.475, -0.457339526286], [-0.45, -0.434966273437], [-0.425, -0.412321277425], [-0.4, -0.389418666667], [-0.375, -0.366272735596], [-0.35, -0.342897934896], [-0.325, -0.319308861735], [-0.3, -0.29552025], [-0.275, -0.271546960531], [-0.25, -0.247403971354], [-0.225, -0.22310636792], [-0.2, -0.198669333333], [-0.175, -0.17410813859], [-0.15, -0.149438132812], [-0.125, -0.12467473348], [-0.1, -0.0998334166667], [-0.075, -0.0749297072754], [-0.05, -0.0499791692708], [-0.025, -0.0249973959147], [0.0, 0.0], [0.025, 0.0249973959147], [0.05, 0.0499791692708], [0.075, 0.0749297072754], [0.1, 0.0998334166667], [0.125, 0.12467473348], [0.15, 0.149438132812], [0.175, 0.17410813859], [0.2, 0.198669333333], [0.225, 0.22310636792], [0.25, 0.247403971354], [0.275, 0.271546960531], [0.3, 0.29552025], [0.325, 0.319308861735], [0.35, 0.342897934896], [0.375, 0.366272735596], [0.4, 0.389418666667], [0.425, 0.412321277425], [0.45, 0.434966273437], [0.475, 0.457339526286], [0.5, 0.479427083333], [0.525, 0.50121517749], [0.55, 0.522690236979], [0.575, 0.543838895101], [0.6, 0.564648], [0.625, 0.58510462443], [0.65, 0.605196075521], [0.675, 0.624909904541], [0.7, 0.644233916667], [0.725, 0.663156180745], [0.75, 0.681665039062], [0.775, 0.699749117106], [0.8, 0.717397333333], [0.825, 0.734598908936], [0.85, 0.751343377604], [0.875, 0.767620595296], [0.9, 0.78342075], [0.925, 0.798734371501], [0.95, 0.813552341146], [0.975, 0.827865901611], [1.0, 0.841666666667], [1.025, 0.854946630941], [1.05, 0.867698179687], [1.075, 0.879914098551], [1.1, 0.891587583333], [1.125, 0.902712249756], [1.15, 0.913282143229], [1.175, 0.923291748617], [1.2, 0.932736], [1.225, 0.941610290446], [1.25, 0.949910481771], [1.275, 0.957632914307], [1.3, 0.964774416667], [1.325, 0.971332315511], [1.35, 0.977304445313], [1.375, 0.982689158122], [1.4, 0.987485333333], [1.425, 0.991692387451], [1.45, 0.995310283854], [1.475, 0.998339542562], [1.5, 1.00078125], [1.525, 1.00263706877], [1.55, 1.0039092474], [1.575, 1.00460063013], [1.6, 1.00471466667], [1.625, 1.00425542196], [1.65, 1.00322758594], [1.675, 1.00163648332], [1.7, 0.999488083333], [1.725, 0.996789009521], [1.75, 0.993546549479], [1.775, 0.989768664632], [1.8, 0.985464], [1.825, 0.980641893962], [1.85, 0.975312388021], [1.875, 0.969486236572], [1.9, 0.963174916667], [1.925, 0.956390637777], [1.95, 0.949146351563], [1.975, 0.941455761637], [2.0, 0.933333333333], [2.025, 0.924794303467], [2.05, 0.915854690104], [2.075, 0.906531302327], [2.1, 0.89684175], [2.125, 0.886804453532], [2.15, 0.876438653646], [2.175, 0.865764421143], [2.2, 0.854802666667], [2.225, 0.843575150472], [2.25, 0.832104492187], [2.275, 0.820414180583], [2.3, 0.808528583333], [2.325, 0.796472956787], [2.35, 0.784273455729], [2.375, 0.771957143148], [2.4, 0.759552], [2.425, 0.747086934977], [2.45, 0.734591794271], [2.475, 0.722097371338], [2.5, 0.709635416667], [2.525, 0.697238647542], [2.55, 0.684940757813], [2.575, 0.672776427653], [2.6, 0.660781333333], [2.625, 0.648992156982], [2.65, 0.637446596354], [2.675, 0.626183374593], [2.7, 0.61524225], [2.725, 0.604664025798], [2.75, 0.594490559896], [2.775, 0.584764774658], [2.8, 0.575530666667], [2.825, 0.566833316488], [2.85, 0.558718898438], [2.875, 0.551234690348], [2.9, 0.544429083333], [2.925, 0.538351591553], [2.95, 0.533052861979], [2.975, 0.528584684163], [3.0, 0.525]], "smooth" => true, "symbol" => "none", "type" => "line", "lineStyle" => Dict{String, Any}("width" => 2, "type" => "dashed"))], "backgroundColor" => "transparent", "yAxis" => Dict{String, Any}("max" => 1.6, "min" => -1.6), "tooltip" => Dict{String, Any}("trigger" => "axis"), "grid" => Dict{String, Any}("top" => 72, "containLabel" => true), "textStyle" => Dict{String, Any}("fontFamily" => "inherit"), "title" => Dict{String, Any}("text" => "Taylor approximation about x = 0"), "legend" => Dict{String, Any}("top" => 30)))
mathblock(["f(x) = $(fkey.value) &\\approx " * tex(poly)])
$$
\begin{aligned}f(x) = sin(x) &\approx x-\frac{x^{3}}{6}+\frac{x^{5}}{120}\end{aligned}
$$

4. Laplace transforms

Giac transforms between the time domain $t$ and the complex frequency domain $s$ exactly. laplace carries $f(t)$ to $F(s)$; ilaplace inverts it. This is the workhorse of linear-systems and control theory — and a round trip should return where it started.

# Forward transforms:  f(t)  ⟶  F(s) = ∫₀^∞ f(t) e^{-st} dt
mathblock([
    "\\mathcal{L}\\{1\\} &= " * tex(laplace(Giac.giac_eval("1"), t, s)),
    "\\mathcal{L}\\{t^{2}\\} &= " * tex(laplace(t^2, t, s)),
    "\\mathcal{L}\\{e^{-2t}\\sin 3t\\} &= " * tex(laplace(exp(-2t) * sin(3t), t, s)),
    "\\mathcal{L}\\{t\\,e^{-t}\\} &= " * tex(laplace(t * exp(-t), t, s)),
])
$$
\begin{aligned}\mathcal{L}\{1\} &= \frac1{s} \\[6pt] \mathcal{L}\{t^{2}\} &= \frac{2}{s^{3}} \\[6pt] \mathcal{L}\{e^{-2t}\sin 3t\} &= \frac{3}{s^{2}+4 s+13} \\[6pt] \mathcal{L}\{t\,e^{-t}\} &= \frac1{s^{2}+2 s+1}\end{aligned}
$$
# Inverse transforms:  F(s)  ⟶  f(t).  A partial-fraction split makes the
# underlying second-order system's response transparent.
F = (s + 3) / (s^2 + 2s + 5)
mathblock([
    "F(s) &= " * tex(F),
    "\\mathcal{L}^{-1}\\!\\left\\{\\tfrac{1}{s^{2}+4}\\right\\} &= " *
        tex(ilaplace(1 / (s^2 + 4), s, t)),
    "\\mathcal{L}^{-1}\\{F(s)\\} &= " * tex(ilaplace(F, s, t)),
])
$$
\begin{aligned}F(s) &= \frac{s+3}{s^{2}+2 s+5} \\[6pt] \mathcal{L}^{-1}\!\left\{\tfrac{1}{s^{2}+4}\right\} &= \frac{\sin \left(2 t\right)}{2} \\[6pt] \mathcal{L}^{-1}\{F(s)\} &= \cos \left(2 t\right) \mathrm{e}^{-t}+\sin \left(2 t\right) \mathrm{e}^{-t}\end{aligned}
$$
# Round trip: transform, invert, and simplify back to the original signal.
g       = exp(-t) * cos(2t)
G       = laplace(g, t, s)
back    = simplify(ilaplace(G, s, t))
mathblock([
    "g(t) &= " * tex(g),
    "\\mathcal{L}\\{g\\} = G(s) &= " * tex(G),
    "\\mathcal{L}^{-1}\\{G\\} &= " * tex(back),
])
$$
\begin{aligned}g(t) &= \mathrm{e}^{-t} \cos \left(2 t\right) \\[6pt] \mathcal{L}\{g\} = G(s) &= \frac{s+1}{s^{2}+2 s+5} \\[6pt] \mathcal{L}^{-1}\{G\} &= \cos \left(2 t\right) \mathrm{e}^{-t}\end{aligned}
$$

5. A second-order system, end to end

The canonical control-theory system

\[H(s) = \frac{\omega_n^{2}}{s^{2} + 2\zeta\omega_n s + \omega_n^{2}}\]

has behaviour governed entirely by its damping ratio $\zeta$ and natural frequency $\omega_n$. Giac inverts $H(s)/s$ symbolically to get the exact step response $y(t)$ — no numerical ODE solver. Drag the sliders: the closed form, the pole locations in the complex $s$-plane, and the time response all update together. Watch the poles split into a complex-conjugate pair as $\zeta$ drops below $1$ and the response begins to ring.

@bind ζ  Slider(0.1, 2.0, 0.3; step=0.05, label="damping ζ")
@bind ωn Slider(0.5, 4.0, 2.0; step=0.1, label="natural freq ωₙ")

# Giac inverts the step response Y(s) = H(s)/s to y(t), exactly.
ystep = Giac.giac_eval(
    "ilaplace($(ωn)^2/(s*(s^2+2*$(ζ)*$(ωn)*s+$(ωn)^2)), s, t)")
yfun  = build_function(ystep, t)

# Poles = roots of s² + 2ζωₙs + ωₙ²
disc  = complex(ζ^2 - 1)
poles = [-ζ*ωn + ωn*sqrt(disc), -ζ*ωn - ωn*sqrt(disc)]
regime = ζ < 1 ? "under-damped (ringing)" : ζ ≈ 1 ? "critically damped" : "over-damped"

mathblock(["y(t) &= " * tex(Giac.Commands.simplify(ystep))])
$$
\begin{aligned}y(t) &= \frac{\sqrt{91} \mathrm{e}^{\frac{3}{5} t} \tan ^{2}\left(\frac{1}{10} \sqrt{91} t\right)+\sqrt{91} \mathrm{e}^{\frac{3}{5} t}+\sqrt{91} \tan ^{2}\left(\frac{1}{10} \sqrt{91} t\right)-\sqrt{91}-6 \tan \left(\frac{1}{10} \sqrt{91} t\right)}{\sqrt{91} \mathrm{e}^{\frac{3}{5} t} \tan ^{2}\left(\frac{1}{10} \sqrt{91} t\right)+\sqrt{91} \mathrm{e}^{\frac{3}{5} t}}\end{aligned}
$$
# Pole map in the complex s-plane. Poles in the left half-plane ⇒ stable;
# imaginary part ⇒ oscillation.
R  = ωn * 1.3
px = real.(poles); py = imag.(poles)

echart(series(:scatter, px, py; name="poles", symbol="path://M0,-1 L0,1 M-1,0 L1,0",
              symbolSize=18, itemStyle=(color="#f56c6c",));
       title="Poles in the s-plane — $regime",
       xAxis=(name="Re(s)", min=-R, max=R, axisLine=(onZero=true,)),
       yAxis=(name="Im(s)", min=-R, max=R, axisLine=(onZero=true,)),
       grid=(left=60, right=30, top=50, bottom=50),
       tooltip=(formatter="Re {@[0]}, Im {@[1]}",),
       height=360)
KaimonSlate.ReportEngine.EChart(Dict{String, Any}("xAxis" => Dict{String, Any}("name" => "Re(s)", "max" => 2.6, "min" => -2.6, "axisLine" => Dict{String, Any}("onZero" => true)), "animationDurationUpdate" => 300, "__size" => Dict{String, Any}("height" => 360), "series" => Dict{String, Any}[Dict("name" => "poles", "symbolSize" => 18, "itemStyle" => Dict{String, Any}("color" => "#f56c6c"), "data" => [[-0.6, 1.9078784028338913], [-0.6, -1.9078784028338913]], "symbol" => "path://M0,-1 L0,1 M-1,0 L1,0", "type" => "scatter")], "backgroundColor" => "transparent", "yAxis" => Dict{String, Any}("name" => "Im(s)", "max" => 2.6, "min" => -2.6, "axisLine" => Dict{String, Any}("onZero" => true)), "tooltip" => Dict{String, Any}("formatter" => "Re {@[0]}, Im {@[1]}"), "grid" => Dict{String, Any}("left" => 60, "bottom" => 50, "right" => 30, "top" => 50), "textStyle" => Dict{String, Any}("fontFamily" => "inherit"), "title" => Dict{String, Any}("text" => "Poles in the s-plane — under-damped (ringing)")))
# Exact step response y(t), sampled from Giac's symbolic solution.
tmax = clamp(8 / (ζ * ωn), 4, 40)
ts   = collect(range(0, tmax; length=400))
ys   = yfun.(ts)

echart(:line, ts, ys; title="Step response y(t)  —  ζ = $ζ, ωₙ = $ωn",
       smooth=true, symbol="none", areaStyle=(opacity=0.12,),
       xAxis=(name="t",), yAxis=(name="y",),
       markLine=(silent=true, symbol="none",
                 data=[(yAxis=1, lineStyle=(type=:dashed, color="#888"))]),
       height=360)
KaimonSlate.ReportEngine.EChart(Dict{String, Any}("xAxis" => Dict{String, Any}("name" => "t"), "yAxis" => Dict{String, Any}("name" => "y"), "animationDurationUpdate" => 300, "textStyle" => Dict{String, Any}("fontFamily" => "inherit"), "tooltip" => Dict{String, Any}("trigger" => "axis"), "title" => Dict{String, Any}("text" => "Step response y(t)  —  ζ = 0.3, ωₙ = 2.0"), "__size" => Dict{String, Any}("height" => 360), "series" => Dict{String, Any}[Dict("areaStyle" => Dict{String, Any}("opacity" => 0.12), "data" => [[0.0, 0.0], [0.03341687552213868, 0.00220300106147], [0.06683375104427736, 0.00868651416391], [0.10025062656641603, 0.0192539090551], [0.1336675020885547, 0.0336984102859], [0.1670843776106934, 0.0518044009902], [0.20050125313283207, 0.0733487141135], [0.23391812865497075, 0.0981019059336], [0.2673350041771094, 0.125829506994], [0.3007518796992481, 0.156293245861], [0.3341687552213868, 0.189252241426], [0.36758563074352546, 0.224464159755], [0.40100250626566414, 0.261686331832], [0.4344193817878028, 0.300676828827], [0.4678362573099415, 0.341195491869], [0.5012531328320802, 0.383004913582], [0.5346700083542189, 0.425871369011], [0.5680868838763575, 0.469565693827], [0.6015037593984962, 0.513864108062], [0.6349206349206349, 0.558548983891], [0.6683375104427736, 0.603409556317], [0.7017543859649122, 0.648242575873], [0.7351712614870509, 0.692852902788], [0.7685881370091896, 0.737054042294], [0.8020050125313283, 0.780668621062], [0.835421888053467, 0.82352880498], [0.8688387635756056, 0.865476658765], [0.9022556390977443, 0.906364448118], [0.935672514619883, 0.946054885345], [0.9690893901420217, 0.984421319612], [1.0025062656641603, 1.02134787316], [1.035923141186299, 1.05672952501], [1.0693400167084377, 1.09047214388], [1.1027568922305764, 1.12249247213], [1.136173767752715, 1.15271806275], [1.1695906432748537, 1.18108717149], [1.2030075187969924, 1.20754860644], [1.236424394319131, 1.23206153729], [1.2698412698412698, 1.25459526675], [1.3032581453634084, 1.27512896661], [1.3366750208855471, 1.29365138098], [1.3700918964076858, 1.31016049927], [1.4035087719298245, 1.32466320163], [1.4369256474519632, 1.33717487934], [1.4703425229741018, 1.34771903291], [1.5037593984962405, 1.35632685047], [1.5371762740183792, 1.36303676911], [1.5705931495405179, 1.36789402168], [1.6040100250626566, 1.37095017173], [1.6374269005847952, 1.37226263898], [1.670843776106934, 1.37189421781], [1.7042606516290726, 1.36991259118], [1.7376775271512113, 1.36638984225], [1.77109440267335, 1.36140196588], [1.8045112781954886, 1.35502838234], [1.8379281537176273, 1.34735145502], [1.871345029239766, 1.33845601424], [1.9047619047619047, 1.32842888907], [1.9381787802840433, 1.31735844867], [1.971595655806182, 1.30533415502], [2.0050125313283207, 1.29244612842], [2.0384294068504594, 1.27878472712], [2.071846282372598, 1.26444014258], [2.1052631578947367, 1.24950201121], [2.1386800334168754, 1.23405904391], [2.172096908939014, 1.21819867417], [2.2055137844611528, 1.20200672559], [2.2389306599832914, 1.18556709957], [2.27234753550543, 1.16896148362], [2.305764411027569, 1.15226908087], [2.3391812865497075, 1.13556636106], [2.372598162071846, 1.1189268333], [2.406015037593985, 1.10242084072], [2.4394319131161235, 1.08611537702], [2.472848788638262, 1.07007392493], [2.506265664160401, 1.05435631636], [2.5396825396825395, 1.03901861402], [2.573099415204678, 1.02411301424], [2.606516290726817, 1.00968777045], [2.6399331662489556, 0.995787137008], [2.6733500417710943, 0.982451332671], [2.706766917293233, 0.969716523217], [2.7401837928153716, 0.957614822456], [2.7736006683375103, 0.946174310946], [2.807017543859649, 0.93541907163], [2.8404344193817876, 0.925369241561], [2.8738512949039263, 0.91604107887], [2.907268170426065, 0.907447044076], [2.9406850459482037, 0.899595894823], [2.9741019214703424, 0.892492793095], [3.007518796992481, 0.886139423961], [3.0409356725146197, 0.880534124865], [3.0743525480367584, 0.875672024488], [3.107769423558897, 0.871545190194], [3.1411862990810357, 0.86814278308], [3.1746031746031744, 0.865451219652], [3.208020050125313, 0.86345433916], [3.241436925647452, 0.862133575627], [3.2748538011695905, 0.861468133656], [3.308270676691729, 0.861435167076], [3.341687552213868, 0.86200995954], [3.3751044277360065, 0.86316610622], [3.408521303258145, 0.864875695734], [3.441938178780284, 0.867109491534], [3.4753550543024225, 0.869837111948], [3.508771929824561, 0.87302720817], [3.5421888053467, 0.876647639475], [3.5756056808688386, 0.880665645024], [3.6090225563909772, 0.885048011621], [3.642439431913116, 0.889761236862], [3.6758563074352546, 0.894771687131], [3.7092731829573933, 0.900045749968], [3.742690058479532, 0.905549980348], [3.7761069340016706, 0.911251240478], [3.8095238095238093, 0.917116832761], [3.842940685045948, 0.923114625599], [3.8763575605680867, 0.92921317178], [3.9097744360902253, 0.935381819209], [3.943191311612364, 0.941590813816], [3.9766081871345027, 0.94781139448], [4.010025062656641, 0.954015879881], [4.0434419381787805, 0.96017774721], [4.076858813700919, 0.966271702716], [4.110275689223058, 0.972273744097], [4.143692564745196, 0.978161214793], [4.177109440267335, 0.98391285025], [4.2105263157894735, 0.989508816273], [4.243943191311613, 0.994930739613], [4.277360066833751, 1.00016173096], [4.31077694235589, 1.00518640052], [4.344193817878028, 1.00999086645], [4.377610693400167, 1.01456275635], [4.4110275689223055, 1.01889120203], [4.444444444444445, 1.02296682802], [4.477861319966583, 1.0267817339], [4.511278195488722, 1.03032947086], [4.54469507101086, 1.03360501294], [4.578111946532999, 1.03660472306], [4.611528822055138, 1.03932631432], [4.644945697577277, 1.04176880701], [4.678362573099415, 1.04393248143], [4.711779448621554, 1.04581882721], [4.745196324143692, 1.04743048921], [4.778613199665831, 1.04877121055], [4.81203007518797, 1.04984577308], [4.845446950710109, 1.05065993556], [4.878863826232247, 1.05122037014], [4.912280701754386, 1.05153459717], [4.945697577276524, 1.05161091903], [4.9791144527986635, 1.05145835296], [5.012531328320802, 1.0510865636], [5.045948203842941, 1.05050579515], [5.079365079365079, 1.04972680379], [5.112781954887218, 1.04876079051], [5.146198830409356, 1.04761933454], [5.179615705931496, 1.04631432786], [5.213032581453634, 1.04485791081], [5.246449456975773, 1.04326240924], [5.279866332497911, 1.04154027322], [5.31328320802005, 1.03970401771], [5.3467000835421885, 1.03776616523], [5.380116959064328, 1.03573919073], [5.413533834586466, 1.03363546885], [5.446950710108605, 1.03146722377], [5.480367585630743, 1.02924648155], [5.513784461152882, 1.02698502532], [5.547201336675021, 1.02469435323], [5.58061821219716, 1.02238563937], [5.614035087719298, 1.02006969755], [5.647451963241437, 1.01775694818], [5.680868838763575, 1.01545738809], [5.714285714285714, 1.01318056344], [5.747702589807853, 1.01093554567], [5.781119465329992, 1.00873091041], [5.81453634085213, 1.00657471949], [5.847953216374269, 1.00447450581], [5.881370091896407, 1.00243726119], [5.9147869674185465, 1.00046942702], [5.948203842940685, 0.998576887697], [5.981620718462824, 0.996764966784], [6.015037593984962, 0.995038425744], [6.048454469507101, 0.993401465193], [6.081871345029239, 0.991857728566], [6.1152882205513786, 0.990410308065], [6.148705096073517, 0.989061752799], [6.182121971595656, 0.987814078968], [6.215538847117794, 0.986668781993], [6.248955722639933, 0.985626850433], [6.2823725981620715, 0.984688781589], [6.315789473684211, 0.983854598631], [6.349206349206349, 0.983123869138], [6.382623224728488, 0.982495724895], [6.416040100250626, 0.981968882825], [6.449456975772765, 0.981541666911], [6.482873851294904, 0.981212030975], [6.516290726817043, 0.980977582188], [6.549707602339181, 0.980835605162], [6.58312447786132, 0.980783086519], [6.616541353383458, 0.980816739791], [6.649958228905597, 0.980933030536], [6.683375104427736, 0.981128201559], [6.716791979949875, 0.981398298107], [6.750208855472013, 0.98173919295], [6.783625730994152, 0.982146611215], [6.81704260651629, 0.982616154909], [6.8504594820384295, 0.983143327002], [6.883876357560568, 0.983723555001], [6.917293233082707, 0.984352213934], [6.950710108604845, 0.98502464865], [6.984126984126984, 0.985736195385], [7.017543859649122, 0.986482202506], [7.0509607351712615, 0.987258050399], [7.0843776106934, 0.988059170426], [7.117794486215539, 0.988881062919], [7.151211361737677, 0.989719314162], [7.184628237259816, 0.990569612329], [7.2180451127819545, 0.991427762354], [7.251461988304094, 0.992289699699], [7.284878863826232, 0.993151503014], [7.318295739348371, 0.994009405673], [7.351712614870509, 0.994859806175], [7.385129490392648, 0.995699277418], [7.4185463659147866, 0.996524574845], [7.451963241436926, 0.997332643465], [7.485380116959064, 0.998120623778], [7.518796992481203, 0.998885856601], [7.552213868003341, 0.999625886836], [7.58563074352548, 1.00033846619], [7.619047619047619, 1.0010215549], [7.652464494569758, 1.00167332244], [7.685881370091896, 1.00229214732], [7.719298245614035, 1.00287661598], [7.752715121136173, 1.00342552079], [7.7861319966583125, 1.00393785722], [7.819548872180451, 1.0044128203], [7.85296574770259, 1.00484980027], [7.886382623224728, 1.00524837757], [7.919799498746867, 1.00560831722], [7.953216374269005, 1.00592956259], [7.9866332497911445, 1.0062122286], [8.020050125313283, 1.00645659455], [8.053467000835422, 1.00666309635], [8.086883876357561, 1.00683231852], [8.1203007518797, 1.00696498577], [8.153717627401837, 1.0070619543], [8.187134502923977, 1.00712420291], [8.220551378446116, 1.00715282389], [8.253968253968255, 1.00714901377], [8.287385129490392, 1.00711406398], [8.320802005012531, 1.00704935151], [8.35421888053467, 1.00695632945], [8.38763575605681, 1.0068365177], [8.421052631578947, 1.00669149367], [8.454469507101086, 1.0065228831], [8.487886382623225, 1.00633235108], [8.521303258145364, 1.00612159318], [8.554720133667502, 1.00589232685], [8.58813700918964, 1.00564628304], [8.62155388471178, 1.00538519808], [8.654970760233919, 1.00511080591], [8.688387635756056, 1.00482483054], [8.721804511278195, 1.0045289789], [8.755221386800335, 1.00422493407], [8.788638262322474, 1.00391434882], [8.822055137844611, 1.00359883959], [8.85547201336675, 1.00327998084], [8.88888888888889, 1.00295929978], [8.922305764411028, 1.00263827158], [8.955722639933166, 1.00231831495], [8.989139515455305, 1.00200078814], [9.022556390977444, 1.00168698537], [9.055973266499583, 1.0013781337], [9.08939014202172, 1.00107539029], [9.12280701754386, 1.00077984005], [9.156223893065999, 1.00049249382], [9.189640768588138, 1.00021428674], [9.223057644110275, 0.999946077236], [9.256474519632414, 0.999688646215], [9.289891395154553, 0.999442696721], [9.323308270676693, 0.999208853908], [9.35672514619883, 0.998987665373], [9.390142021720969, 0.9987796018], [9.423558897243108, 0.99858505793], [9.456975772765247, 0.998404353816], [9.490392648287385, 0.998237736356], [9.523809523809524, 0.998085381089], [9.557226399331663, 0.997947394236], [9.590643274853802, 0.99782381495], [9.62406015037594, 0.997714617792], [9.657477025898078, 0.997619715373], [9.690893901420218, 0.997538961175], [9.724310776942357, 0.997472152518], [9.757727652464494, 0.997419033649], [9.791144527986633, 0.997379298953], [9.824561403508772, 0.997352596251], [9.857978279030911, 0.997338530164], [9.891395154553049, 0.997336665552], [9.924812030075188, 0.997346530974], [9.958228905597327, 0.997367622179], [9.991645781119466, 0.997399405607], [10.025062656641603, 0.997441321872], [10.058479532163743, 0.997492789227], [10.091896407685882, 0.997553206988], [10.12531328320802, 0.99762195891], [10.158730158730158, 0.997698416493], [10.192147034252297, 0.997781942216], [10.225563909774436, 0.997871892682], [10.258980785296576, 0.997967621664], [10.292397660818713, 0.998068483045], [10.325814536340852, 0.998173833641], [10.359231411862991, 0.998283035903], [10.39264828738513, 0.998395460482], [10.426065162907268, 0.998510488667], [10.459482038429407, 0.998627514667], [10.492898913951546, 0.998745947762], [10.526315789473685, 0.998865214291], [10.559732664995822, 0.998984759496], [10.593149540517961, 0.999104049204], [10.6265664160401, 0.999222571355], [10.65998329156224, 0.99933983738], [10.693400167084377, 0.999455383409], [10.726817042606516, 0.999568771333], [10.760233918128655, 0.999679589711], [10.793650793650794, 0.99978745452], [10.827067669172932, 0.999892009757], [10.86048454469507, 0.999992927901], [10.89390142021721, 1.00008991022], [10.927318295739349, 1.00018268695], [10.960735171261486, 1.00027101735], [10.994152046783626, 1.00035468958], [11.027568922305765, 1.00043352053], [11.060985797827904, 1.00050735547], [11.094402673350041, 1.00057606762], [11.12781954887218, 1.00063955761], [11.16123642439432, 1.00069775283], [11.194653299916459, 1.00075060668], [11.228070175438596, 1.0007980978], [11.261487050960735, 1.00084022913], [11.294903926482874, 1.00087702692], [11.328320802005013, 1.00090853979], [11.36173767752715, 1.00093483754], [11.39515455304929, 1.00095601006], [11.428571428571429, 1.00097216613], [11.461988304093568, 1.00098343224], [11.495405179615705, 1.00098995128], [11.528822055137844, 1.00099188131], [11.562238930659984, 1.00098939426], [11.595655806182123, 1.00098267464], [11.62907268170426, 1.00097191823], [11.6624895572264, 1.00095733078], [11.695906432748538, 1.00093912672], [11.729323308270677, 1.00091752789], [11.762740183792815, 1.00089276225], [11.796157059314954, 1.00086506267], [11.829573934837093, 1.00083466573], [11.862990810359232, 1.00080181046], [11.89640768588137, 1.00076673732], [11.929824561403509, 1.00072968697], [11.963241436925648, 1.00069089931], [11.996658312447787, 1.00065061237], [12.030075187969924, 1.00060906142], [12.063492063492063, 1.000566478], [12.096908939014202, 1.00052308908], [12.130325814536342, 1.0004791162], [12.163742690058479, 1.00043477479], [12.197159565580618, 1.00039027341], [12.230576441102757, 1.00034581311], [12.263993316624896, 1.00030158686], [12.297410192147034, 1.00025777905], [12.330827067669173, 1.00021456494], [12.364243943191312, 1.00017211035], [12.397660818713451, 1.00013057124], [12.431077694235588, 1.00009009342], [12.464494569757727, 1.00005081234], [12.497911445279867, 1.00001285289], [12.531328320802006, 0.999976329249], [12.564745196324143, 0.999941344839], [12.598162071846282, 0.999907992276], [12.631578947368421, 0.999876353392], [12.66499582289056, 0.999846499305], [12.698412698412698, 0.999818490521], [12.731829573934837, 0.999792377097], [12.765246449456976, 0.999768198823], [12.798663324979115, 0.999745985456], [12.832080200501252, 0.999725756985], [12.865497076023392, 0.999707523924], [12.89891395154553, 0.999691287642], [12.93233082706767, 0.999677040713], [12.965747702589807, 0.999664767297], [12.999164578111946, 0.99965444354], [13.032581453634085, 0.99964603799], [13.065998329156225, 0.999639512039], [13.099415204678362, 0.999634820367], [13.132832080200501, 0.999631911409], [13.16624895572264, 0.999630727824], [13.19966583124478, 0.999631206973], [13.233082706766917, 0.999633281402], [13.266499582289056, 0.999636879325], [13.299916457811195, 0.999641925114], [13.333333333333334, 0.999648339771]], "smooth" => true, "symbol" => "none", "markLine" => Dict{String, Any}("data" => Any[Dict{String, Any}("yAxis" => 1, "lineStyle" => Dict{String, Any}("color" => "#888", "type" => "dashed"))], "symbol" => "none", "silent" => true), "type" => "line")], "backgroundColor" => "transparent"))

6. Symbolic linear algebra

Matrices with symbolic entries carry through determinants, inverses, and eigenvalues as exact expressions in the parameter $a$.

M   = GiacMatrix(Giac.giac_eval("[[a,1],[1,a]]"))
det = Giac.invoke_cmd(:det, M)
inv = Giac.invoke_cmd(:inverse, M)
eig = Giac.invoke_cmd(:eigenvalues, M)
mathblock([
    "A &= " * tex(M),
    "\\det A &= " * tex(det),
    "A^{-1} &= " * tex(inv),
    "\\operatorname{eig}(A) &= " * tex(eig),
])
$$
\begin{aligned}A &= \left[\begin{array}{cc}a&1\\1&a\end{array}\right] \\[6pt] \det A &= a^{2}-1 \\[6pt] A^{-1} &= \left[\begin{array}{cc}\frac{a}{a^{2}-1}&-\frac1{a^{2}-1}\\-\frac1{a^{2}-1}&\frac{a}{a^{2}-1}\end{array}\right] \\[6pt] \operatorname{eig}(A) &= a+1,a-1\end{aligned}
$$
# Giac symbolic output embedded inline in markdown prose.
# `tex(e)` renders any Giac expression to a LaTeX string; drop it into a
# Markdown.parse string and it typesets alongside ordinary text.
let
    fac  = factor(x^4 - 1)
    dsol = solve(x^2 - 5x + 6, x)
    ig   = integrate(x * exp(x), x)

    Markdown.parse("""
    We can weave Giac's **symbolic output** straight into markdown prose.

    - The quartic factors as \$x^4 - 1 = $(tex(fac))\$.
    - Solving \$x^2 - 5x + 6 = 0\$ gives \$x \\in $(tex(dsol))\$.
    - And \$\\displaystyle\\int x\\,e^{x}\\,dx = $(tex(ig)) + C\$.

    The same aligned `mathblock` also renders as markdown:

    \$\$\\begin{aligned}
    x^4 - 1 &= $(tex(fac)) \\\\[6pt]
    \\int x\\,e^{x}\\,dx &= $(tex(ig)) + C
    \\end{aligned}\$\$
    """)
end
We can weave Giac's **symbolic output** straight into markdown prose.

  * The quartic factors as $x^4 - 1 = \left(x-1\right) \left(x+1\right) \left(x^{2}+1\right)$.
  * Solving $x^2 - 5x + 6 = 0$ gives $x \in \left[2,3\right]$.
  * And $\displaystyle\int x\,e^{x}\,dx = x \mathrm{e}^{x}-\mathrm{e}^{x} + C$.

The same aligned `mathblock` also renders as markdown:

$$
\begin{aligned}
x^4 - 1 &= \left(x-1\right) \left(x+1\right) \left(x^{2}+1\right) \\[6pt]
\int x\,e^{x}\,dx &= x \mathrm{e}^{x}-\mathrm{e}^{x} + C
\end{aligned}
$$
begin
    h = 10
    y = 2
end
2