Galileo

Galileo in your own page

Lesson notes, worksheets, a blog post: add one line, and every example in the page becomes math your readers can edit and run. It all runs in their browser, with nothing to install and no account.

Try it: change a number and press Run (or Shift+Enter).

f(x) := x^3 - 6*x^2 + 9*x
deriv(f(x), x)
solve(deriv(f(x), x) == 0, x)
plot(f(x), x, -1, 5)

How

Put this line in the <head> of your page:

<script src="https://cascala.github.io/igalileo/embed/galileo.js" defer></script>

Then write each example as a <pre class="galileo"> block:

<pre class="galileo">integrate(x*sin(x), x)</pre>

That's all. Results show under each block: typeset formulas, interactive plots, and a short explanation of what was computed. All blocks on a page share one session, so a block can use what an earlier one defined. Your page's own text and layout stay exactly as they are.

See an example page Download it as a template

Options

Add these to a <pre class="galileo"> tag:

OptionWhat it does
data-autorunRuns the block when the page opens, so readers see the result straight away.
data-hiddenHides the block. It runs before any other block, which makes it the place for setup such as g = 9.81; or explain = "off";
data-readonlyReaders can run the block but not edit it.

Readers can edit any other block; Reset puts your original code back, and Stop ends a computation that runs too long. Statements ending in ; run without showing a result, as everywhere in Galileo; the language reference lists every command.

Where it works

Anywhere you can add a <script> tag: your own site, GitHub Pages, most blogs, Google Sites (with Embed → Embed code). Some course platforms remove scripts from pages; there, put your page somewhere that keeps them and link to it.

Without internet

For a classroom without a connection, or to keep your own copy, download the files and keep them next to your pages. Open example.html from the folder to check it works, even straight from a USB stick. In your own pages, point the script at the copy: <script src="galileo.js" defer></script>.

Download galileo-embed.zip