ApasScript.

Output

What a script shows, and how it becomes a PDF worked solution.

What each line shows

Each line shows one result: a named line its name and value, a bare expression its value, print exactly what you give it, and a # line its text. Plots, diagrams and animations appear where their line is.

Moving pictures

animate(t0, t1, frames, f) calls your function f(t) once for each of frames values of t from t0 to t1, and whatever that call draws is one frame; the result plays, pauses and steps like a video. Anything you can write in terms of t moves: a projectile, a pendulum, a wave.

The transformations -- translate, rotate, scale, reflect, shear -- make shapes move in one line each: rotate(tri, 90*t) turns a triangle through a quarter turn as t goes from 0 to 1, and scale(sq, t) grows a square. Fix the view with xrange/yrange first so the frames share one frame of reference.

A PDF worked solution

The same script makes a typeset worked solution. Each line becomes a step with the formula written out -- v = u + a*t appears as v = u + at = 60 -- and # lines become paragraphs between the steps. From the command line, --tex writes a LaTeX file next to the script, and pdflatex turns it into the PDF.

apas_dsl motion.as --tex
pdflatex motion.tex

Random numbers

In the playground, random functions give new numbers on every Run. PDFs and pages always start from the same seed, so a printed worksheet never changes; seed(n) fixes the numbers anywhere.