Difference between revisions of "Timescalecalculus python library documentation"

From timescalewiki
Jump to: navigation, search
(Defining a time scale)
(Defining a time scale)
Line 6: Line 6:
 
After extracting the files, open a Python instance in its folder and type
 
After extracting the files, open a Python instance in its folder and type
 
<pre> >>> from timescalecalculus import *</pre>
 
<pre> >>> from timescalecalculus import *</pre>
==Defining a time scale==
+
==Time scale basics==
 
Right now, a [[time scale]] in this library can consist of only a finite list of numbers. Fraction types are available.  
 
Right now, a [[time scale]] in this library can consist of only a finite list of numbers. Fraction types are available.  
<pre>>>> ts=[1,2,3,4,5,6,7]</pre>
+
Let $\mathbb{T}=\left\{0,\dfrac{1}{3},\dfrac{1}{2},\dfrac{7}{9},1,2,3,4,5,6,7 \right\}$.<br />
The [[forward jump]] $\sigma$ can be used:
+
<pre>>>> ts=[0,Fraction(1,3),Fraction(1,2),Fraction(7,9),1,2,3,4,5,6,7]</pre>
<pre>>>> sigma(3,ts)
+
The [[forward jump]] $\sigma$ can be used:<br />
4</pre>
+
$\sigma(0)=\dfrac{1}{3}$
The [[backward jump]] $\rho$ can be used:
+
<pre>>>> sigma(0,ts)
 +
Fraction(1, 3)</pre>
 +
$\sigma(4)=5$
 +
<pre>>>> sigma(4,ts)
 +
5</pre>
 +
$\sigma(7)=7$
 +
<pre>>>> sigma(7,ts)
 +
7</pre>
 +
 
 +
The [[backward jump]] $\rho$ can be used:<br />
 +
$\rho(1)=\dfrac{7}{9}$
 +
<pre>>>> rho(1,ts)
 +
Fraction(7, 9)</pre>
 +
$\rho(3)=2$
 
<pre>>>> rho(3,ts)
 
<pre>>>> rho(3,ts)
 
2</pre>
 
2</pre>
 +
$\rho(0)=0$
 +
<pre>>>> rho(0,ts)
 +
0</pre>
 
The [[delta derivative]] works as expected. The delta derivative of a constant is zero:
 
The [[delta derivative]] works as expected. The delta derivative of a constant is zero:
 
<pre>>>> dderivative(lambda x: 1,5,ts)
 
<pre>>>> dderivative(lambda x: 1,5,ts)

Revision as of 06:22, 23 December 2016

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 *

Time scale basics

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]

The forward jump $\sigma$ can be used:
$\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 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 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