Macaulay2 » Documentation
Packages » SLPexpressions :: arithmetic with circuits
next | previous | forward | backward | up | index | toc

arithmetic with circuits

There are many arithmetic operations that can be performed on gates. This makes it easy to create combine existing gates into new gates.

i1 : declareVariable X; declareVariable Y;
i3 : m1 = Y*Y

o3 = (Y * Y)

o3 : ProductGate
i4 : m2 = X^3

o4 = (X * X * X)

o4 : ProductGate
i5 : F = m1-m2-X

o5 = (((Y * Y) + (-1 * (X * X * X))) + (-1 * X))

o5 : SumGate

If one of the inputs is a Number, it is first converted to an InputGate:

i6 : X + 2

o6 = (X + 2)

o6 : SumGate

By extension, arithmetic operations also work with gate matrices:

i7 : M = matrix {{X, Y}}

o7 = {{X, Y}}

o7 : GateMatrix
i8 : 3*M

o8 = {{(3 * X), (3 * Y)}}

o8 : GateMatrix
i9 : transpose M * M

o9 = {{((X * X)), ((X * Y))}, {((Y * X)), ((Y * Y))}}

o9 : GateMatrix

See also