A time scale is any nonempty closed subset of the real numbers. It provides a unified framework that includes both continuous time () and discrete time () as special cases, as well as hybrid structures such as {0,1,2,3, } together with intervals like [5,7].
The principal objects of timescale calculus are the forward jump operator (t), the graininess function (t)=(t)-t, and the delta derivative f^(t). When = these reduce to the classic derivative, and when = they become the forward difference operator.
Mathematica (Wolfram Language) has builtin support for symbolic manipulation, numerical evaluation, and graphics. With a few custom definitions it can handle timescale calculus directly, letting you explore examples without writing lengthy code from scratch. The following sections show how to set up the basic operators and then apply them to typical calculus problems.
First we define a time scale as a list or interval. Below is a helper function that creates a numeric representation of and the associated jump and graininess functions.
ClearAll[TimeScale, Sigma, Mu];TimeScale[ts_List] := ts; (* discrete set *)TimeScale[{{a_, b_}}] := N[Range[a, b, 1]]; (* integer interval, can be refined *)(* Forward jump operator: smallest point in ts greater than t *)Sigma[ts_][t_] := Module[{cand = Select[ts, # > t &]}, If[cand === {}, t, Min[cand]]];(* Graininess (t) = (t) t *)Mu[ts_][t_] := Sigma[ts][t] - t; For a mixed time scale we can concatenate discrete points and an interval:
myTS = Join[Range[0, 4], Range[6, 10, 2]]; (* {0,1,2,3,4,6,8,10} *) The delta derivative of a function f[t] at a point t is defined as
f(t) = Limit[(f[(t)] - f[t]) / (t), (t) 0]
On a purely continuous time scale this limit recovers the usual derivative; on a purely discrete time scale it becomes the forward difference (f[t+1] - f[t]).
In Mathematica we can implement a numerical version as follows:
DeltaDerivative[ts_][f_][t_?NumericQ] := If[Mu[ts][t] == 0, D[f[t], t] /. t -> t, (* continuous part *) (f[Sigma[ts][t]] - f[t]) / Mu[ts][t] (* discrete part *) ]; f(t)=t^2 on a mixed time scalef[t_] := t^2;myDerivative = DeltaDerivative[myTS][f];Table[{t, myDerivative[t]}, {t, myTS}](* Output: {{0,0},{1,2},{2,4},{3,6},{4,8},{6,12},{8,16},{10,20}} *) The result coincides with 2t at every point as expected because the quadratic function is differentiable on and its forward differences equal the derivative at integer points.
The delta integral is the inverse operation to the delta derivative. For a function g[t] the delta integral from a to b on a time scale is written ab g(t) t. In practice we compute it by summing contributions from each subinterval of :
DeltaIntegral[ts_][g_][a_, b_] := Module[{pts = Select[ts, a <= # <= b]}, If[Length[pts] < 2, 0, Total[Table[ g[pts[[i]]] * Mu[ts][pts[[i]]], {i, 1, Length[pts] - 1} ]] ]]; g(t)=t from 0 to 10 on myTSg[t_] := t;DeltaIntegral[myTS][g][0, 10](* Output: 70 *) Manually, the contribution of each step is t(t). Adding them gives 01 + 11 + 21 + 31 + 42 + 62 + 82 = 70, which matches the Mathematica result.
Mathematicas Plot and DiscretePlot functions can be combined to present a continuous picture together with the discrete values of the delta derivative.
derPlot = Plot[2 t, {t, 0, 10}, PlotStyle->Blue, PlotLegends->"2t"];derPoints = ListPlot[ Table[{t, myDerivative[t]}, {t, myTS}], PlotStyle->{Red, PointSize[Medium]}, PlotLegends->"f"];Show[derPlot, derPoints, PlotRange->All] The blue curve represents the classical derivative 2t, while the red points show the computed delta derivative on the same time scale. The agreement confirms the correctness of the implementation.
A basic initialvalue problem on a time scale is
y(t) = y(t),y(0)=1
Its solution is the timescale exponential exp_(, t). In Mathematica we can generate the numerical solution by iterating the forward jump relation:
ClearAll[TimeScaleExp];TimeScaleExp[ts_][_][t0_, t_] := Module[{pts = Select[ts, t0 <= # <= t], y = Association[ t0 -> 1 ]}, Do[ y[pts[[i + 1]]] = y[pts[[i]]] * (1 + * Mu[ts][pts[[i]]]), {i, 1, Length[pts] - 1} ]; y[t]]; = 0.5;sol = Table[{t, TimeScaleExp[myTS][][0, t]}, {t, myTS}];ListLinePlot[sol, PlotMarkers->Automatic, AxesLabel->{"t","y(t)"}, PlotLabel->"Solution of y^= y"] The plot displays an exponentialtype growth that aligns with the classical solution e^{t} on the continuous portions while adapting to the larger graininess on the discrete jumps.
Timescale calculus bridges the gap between differential and difference equations, providing a powerful language for hybrid dynamical systems. Using Mathematica we can define the core operators (, , delta derivative, delta integral), explore analytic examples, and visualise results with just a few lines of code. The approach scales naturally to more sophisticated problemsoptimal control, stochastic equations, or fractional dynamicsmaking Mathematica an excellent platform for both teaching and research in this rapidly evolving field.
