function initializeState() {
let dt = .01;
let accelvel = math.matrix([[1, dt], [0, 1]]);
let state = {'P': 1,
'Q': math.diag(math.matrix([1, 0, 1, 0])),
'R': math.evaluate("penalty * identity(2)", {penalty: penalty}),
'A': math.concat(math.concat(accelvel, math.zeros(2, 2), 1),
math.concat(math.zeros(2, 2), accelvel, 1), 0
),
'B': math.matrix([[0, 0], [1, 0], [0, 0], [0, 1]]),
'x': math.matrix([200, 0, 200, 0]),
'u': math.matrix([0, 0]),
'goal': 100};
state.P = math.identity(state.Q.size()[0]);
for(var i = 0; i < 50; i++) {
state.P = math.evaluate("Q + (A' * P * A) - (A' * P * B * inv(R + B' * P * B) * B' * P * A)", state);
}
state.K = math.evaluate("-inv(R + B' * P * B) * B' * P * A", state);
return state
}