# expression.shortest(num = None, len = None)¶

Return a (finite) approximation of the series denoted by the expression.

This is equivalent to calling expression.derived_term().shortest. See its documentation for more details.

## Examples¶

### Boolean Expressions¶

In [1]:
import vcsn
e = vcsn.B.expression('[ab]*a[ab]')
e.shortest()

Out[1]:
$\mathit{aa}$
In [2]:
e.shortest(4)

Out[2]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab}$
In [3]:
e.shortest(len=4)

Out[3]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab} \oplus \mathit{aaaa} \oplus \mathit{aaab} \oplus \mathit{abaa} \oplus \mathit{abab} \oplus \mathit{baaa} \oplus \mathit{baab} \oplus \mathit{bbaa} \oplus \mathit{bbab}$
In [4]:
e.shortest(num=10, len=4)

Out[4]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab} \oplus \mathit{aaaa} \oplus \mathit{aaab} \oplus \mathit{abaa} \oplus \mathit{abab}$
In [5]:
e.shortest(num=10, len=3)

Out[5]:
$\mathit{aa} \oplus \mathit{ab} \oplus \mathit{aaa} \oplus \mathit{aab} \oplus \mathit{baa} \oplus \mathit{bab}$

### Weighted Expressions¶

In [6]:
e = vcsn.Z.expression('(<2>a)*')
e.shortest(len=3)

Out[6]:
$\varepsilon \oplus \left\langle 2\right\rangle \mathit{a} \oplus \left\langle 4\right\rangle \mathit{aa} \oplus \left\langle 8\right\rangle \mathit{aaa}$
In [7]:
e.shortest(num=10)

Out[7]:
$\varepsilon \oplus \left\langle 2\right\rangle \mathit{a} \oplus \left\langle 4\right\rangle \mathit{aa} \oplus \left\langle 8\right\rangle \mathit{aaa} \oplus \left\langle 16\right\rangle \mathit{aaaa} \oplus \left\langle 32\right\rangle \mathit{aaaaa} \oplus \left\langle 64\right\rangle \mathit{aaaaaa} \oplus \left\langle 128\right\rangle \mathit{aaaaaaa} \oplus \left\langle 256\right\rangle \mathit{aaaaaaaa} \oplus \left\langle 512\right\rangle \mathit{aaaaaaaaa}$