# weight.multiply¶

This function is overloaded, it supports these signatures:

• weight.multiply(w)

The product of two weights.

• weight.multiply(num)

The repeated multiplication (power) of a weight with itself. Exponent -1 denotes the infinity.

• weight.multiply((min,max))

The sum of repeated multiplications of an expression: w.multiply((2,4)) = $w^2 + w^3 + w^4$. When min = -1, it denotes 0, when max = -1, it denotes the infinity.

Preconditions:

• min <= max

## Examples¶

In :
import vcsn
weight = vcsn.context('law_char, q').weight


### Simple Multiplication¶

Instead of a.multiply(b), you may write a * b.

In :
weight('1/2') * weight('3')

Out:
$\frac{3}{2}$
In :
weight('1/2').multiply(weight('3'))

Out:
$\frac{3}{2}$

### Repeated Multiplication¶

Instead of w.multiply(3), you may write w ** 3.

In :
half = weight('1/2')
half ** 3

Out:
$\frac{1}{8}$
In :
half ** 0

Out:
$1$

Use the exponent -1 to mean infinity. Alternatively, you may invoke w.star instead of w ** -1.

In :
half ** -1

Out:
$2$
In :
half.star()

Out:
$2$

### Sums of Repeated Multiplications¶

Instead of w.multiply((2, 4)), you may write w ** (2, 4). Again, use exponent max = -1 to denotes infinity.

In :
half ** (2, 2)

Out:
$\frac{1}{4}$
In :
half ** (2, 4)

Out:
$\frac{7}{16}$
In :
half ** 2 + half ** 3 + half ** 4

Out:
$\frac{7}{16}$
In :
half ** (0, 2)

Out:
$\frac{7}{4}$
In :
half ** (1, -1)

Out:
$1$