timescalecalculus python library documentation

From timescalewiki
Revision as of 11:05, 24 December 2016 by Tom (talk | contribs) (Delta exponential $e_p(t,s)$)
Jump to: navigation, search

This is the documentation for the Python repository timescalecalculus.

The basics

After extracting the files, open a Python instance in its folder and type

 >>> from timescalecalculus import *

Right now, a time scale in this library can consist of only a finite list of numbers. Fraction types are available. Let $\mathbb{T}=\left\{0,\dfrac{1}{3},\dfrac{1}{2},\dfrac{7}{9},1,2,3,4,5,6,7 \right\}$.

>>> ts=[0,Fraction(1,3),Fraction(1,2),Fraction(7,9),1,2,3,4,5,6,7]

Forward jump and graininess

The forward jump $\sigma$ can be computed:
$\sigma(0)=\dfrac{1}{3}$

>>> sigma(0,ts)
Fraction(1, 3)

$\sigma(4)=5$

>>> sigma(4,ts)
5

$\sigma(7)=7$

>>> sigma(7,ts)
7

The forward graininess $\mu$ can be computed:
$\mu \left( \dfrac{1}{3} \right)=\dfrac{1}{2}-\dfrac{1}{3}=\dfrac{1}{6}$

>>> mu(Fraction(1,3),ts)
Fraction(1, 6)

Backward jump and graininess

The backward jump $\rho$ can be used:
$\rho(1)=\dfrac{7}{9}$

>>> rho(1,ts)
Fraction(7, 9)

$\rho(3)=2$

>>> rho(3,ts)
2

$\rho(0)=0$

>>> rho(0,ts)
0

The backward graininess $\nu$ can be computed:
$\nu\left( \dfrac{7}{9} \right)=\dfrac{7}{9}-\dfrac{1}{2}=\dfrac{5}{18}$

>>> nu(Fraction(7,9),ts)
Fraction(5, 18)

Delta-derivative

The delta derivative works as expected. The delta derivative of a constant is zero:

>>> dderivative(lambda x: 1,5,ts)
0

and obeying the delta derivative of squaring function, we see

>>> dderivative(lambda x: x*x,5,ts)
11

The delta exponential is supported. For example if $\mathbb{T}=\{1,2,3,4,5,6,7\}$ then $e_1(3,1)=(1+\mu(1))(1+\mu(2))=(2)(2)=4$ which is correctly computed:

>>> dexpf(lambda x: 1, 3, 1, ts)
4

Special functions

Delta exponential $e_p(t,s)$

On $\mathbb{T}=\{1,2,3,4,5\}$

Then the delta exponential $e_1(3,1)$ is given by $$e_1(3,1) = \displaystyle\prod_{k=1}^2 1+\mu(k)(1)=2^{2}=4$$

>>> ts=[1,2,3,4,5]
>>> dexpf(3,1,ts)
>>> dexpf(lambda x: 1,3,1,ts)
4

The function $e_2(3,1)$ is given by $$e_2(3,1) = \displaystyle\prod_{k=1}^2 1+\mu(k)(2)=3^2=9$$

>>> dexpf(lambda x: 2,3,1,ts)
9

The function $e_{\mathrm{id}}(3,1)$ (where $\mathrm{id}$ is the identity function on $\mathbb{T}$) is given by $$e_{\mathrm{id}}(3,1)=\displaystyle\prod_{k=1}^2 1+\mu(k)k=(1+(1)(1))(1+(1)(2))=6$$

>>> dexpf(lambda x: x,3,1,ts)
6

The function $e_{e_1(\cdot,1)}(3,1)$ is given by $$e_{e_1(\cdot,1)}(4,1)=\displaystyle\prod_{k=1}^3 1+\mu(k)e_1(k,1)=(1+(1)e_1(1,1))(1+(1)e_1(2,1))(1+(1)e_1(3,1))=(2)(3)(5)=30$$

>>> (1+dexpf(lambda x: 1,1,1,ts))*(1+dexpf(lambda x: 1,2,1,ts))*(1+dexpf(lambda x: 1,3,1,ts))
30