Functions of one variable
 We now turn to creating nonlinear transformations in Nengo. The main idea here is that instead of using the X origin, we will create a new origin that estimates some arbitrary function of X. This will allow us to estimate any desired function.
 The accuracy of this estimate will, of course, be dependent on the properties of the neurons.

For onedimensional ensembles, we can calculate various 1dimensional functions:
 f(x)=x2
 f(x)=θ(x) (thresholding)
 f(x)=√x

To perform a nonlinear operation, we need to define a new origin

The X origin just uses f(x)=x.
 Create a new ensemble and a function input. The ensemble should be onedimensional with 100 neurons and a radius of 1. Use a Constant Function input set two 0.5.
 Create a termination on the ensemble and connect the function input to it
 Now create a new origin that will estimate the square of the value.
 Rightclick on the combined ensemble and select Add decoded origin
 Set the name to "square"
 Click on Set Functions
 Select Userdefined Function and press Set
 For the Expression, enter "x0*x0". We refer to the value as x0 because when we extend this to multiple dimensions, we will refer to them as x0, x1, x2, and so on.
 Press OK, OK, and OK.
 You can now generate a plot that shows how good the ensemble is at calculating the nonlinearity. Rightclick on the ensemble and select Plot>Plot distortion:square.
 Start Interactive Plots.
 Create a control for the input, so you can adjust it while the model runs (rightclick on the input and select "control")
 Create a graph of the "square" value from the ensemble. Do this by rightclicking on the ensemble in the Interactive Plots window and selecting "square>value".
 For comparison, also create a graph for the standard X origin byt rightclicking on the ensemble and selecting "X>value". This is the standard value graph that just shows the value being represented by this ensemble.
 Press Play to run the simulation. With the default input of 0.5, the squared value should be near 0.25. Use the control to adjust the input. The output should be the square of the input.
 You can also run this example using scripting
run demo/squaring.py
Functions of multiple variables
 Since X (the value being represented by an ensemble) can also be multidimensional, we can also calculate these sorts of functions
 f(x)=x0*x1
 f(x)=max(x0,x1)
 To begin, we create two ensembles and two function inputs. These will represent the two values we wish to multiply together.
 The ensembles should be onedimensional, use 100 neurons and have a radius of 10 (so they can represent values between 10 and 10)
 The two function inputs should be constants set to 8 and 5
 The terminations you create to connect them should have time constants of 0.01 (AMPA)
 Now create a twodimensional neural ensemble with a radius of 15 called Combined
 Since it needs to represent multiple values, we increase the number of neurons it contains to 200
 Add two terminations to Combined
 For each one, the input dimensions are 1
 For the first one, use Set Weights to make the transformation be [1 0]
 For the second one, use Set Weights to make the transformation be [0 1]
 Connect the two other ensembles to the Combined one
 Next, create an ensemble to store the result. It should have a radius of 100, since it will need to represent values from 100 to 100. Give it a single onedimensional termination with a weight of 1.
 Now we need to create a new origin that will estimate the product between the two values stored in the combined ensemble.
 Rightclick on the combined ensemble and select Add decoded origin.
 Set the name to âproductâ
 Set Output dimensions to 1
 Click on Set Functions
 Select Userdefined Function and press Set.
 For the Expression, enter x0*x1
 Press OK, OK, and OK to finish creating the origin
 Connect the new origin to the termination on the result ensemble
 Add a probe to the result ensemble and run the simulation
 The result should be approximately 40.
 Adjust the input controls to multiple different numbers together.
 You can also run this example using scripting
run demo/multiplication.py
Combined approaches
 We can combine these two approaches in order to compute more complex funxtions, such as x2y.
 Rightclick on the ensemble representing the first of the two values and select Add decoded origin.
 Give it the name "square", set its output dimensions to 1, and press Set Functions.
 As before, select the Userdefined Function and press Set.
 Set the Expression to be "x0*x0".
 Press OK, OK, and OK to finish creating the origin.
 This new origin will calculate the square of the value represented by this ensemble.
 If you connect this new origin to the Combined ensemble instead of the standard X origin, the network will calculate x2y instead of xy.