Hi,

I would like to represent a Quaternion (a 4D variable) with a 4-dimensional ensemble and use it in the subsequent calculations.

The variable which has been represented with this ensemble (A in my codes) is denominator in my calculations and because its value is zero in the first few iterations, a “Zero Division Error” is returned.

How the ensemble’s parameters could be adjusted to return a non-zero variable? This error could be eliminated if the ensemble’s parameters are properly adjusted, but which parameters are they?

A [[ 0. 0. 0. 0. ]

[ 0. 0. 0. 0. ]

[-0.00615827 0.00846977 0.00803852 0.01110903]

…

[-0.357 0.491 0.466 0.644 ]

[-0.357 0.491 0.466 0.644 ]

[-0.357 0.491 0.466 0.644 ]]

The codes are :

```
import nengo
from nengo.processes import Piecewise
import matplotlib.pyplot as plt
from pyquaternion import Quaternion
q1 = Quaternion(-0.357 ,0.491,0.466, 0.644)
v1=q1.elements
model = nengo.Network()
with model:
ndA = {0:[0,0,0,0], 0.2:v1}
inputA = nengo.Node(Piecewise(ndA))
inputA = nengo.Node(v1)
A = nengo.Ensemble(400, dimensions=4,neuron_type=nengo.Direct())
B =nengo.Ensemble(400, dimensions=4, neuron_type=nengo.Direct())
nengo.Connection(inputA, A)
def inverse(C):
q = Quaternion(a=C[0], b=C[1], c=C[2], d=C[3])
q_inv=q.inverse
inv= q_inv.elements
return inv
nengo.Connection(A,B, function=inverse)
A_probe = nengo.Probe(A, synapse=0.01)
B_probe = nengo.Probe(B, synapse=0.01)
sim_time = 1
sim = nengo.Simulator(model)
sim.run(sim_time)
plt.figure()
plt.plot(sim.trange(), sim.data[A_probe])
print("A", sim.data[A_probe])
plt.show()
plt.figure()
plt.plot(sim.trange(), sim.data[B_probe])
print("BB", sim.data[B_probe])
plt.show()
```