function [ sspoint ] = StemCellSwitch( startpoint )
% uses crude ODE solver to find fixed point of stem-cell-like genetic
% control system
% takes vector (x1,x2) of start state
% returns vector of steady state

% model and simulation parameters
a1 = 0.55; a2 = 0.55;
b1 = 1; b2 = 1; k1 = 1; k2 = 1;
ta1 = 0.5; ta2 = 0.5; tb1 = 0.5; tb2 = 0.5;
n = 2;
residual = 1;
dt = 0.1;

x1 = startpoint(1); x2 = startpoint(2);
% loop until converged
while abs(residual) > 0.000001
    % update concentrations
    nx1 = x1 + dt*( a1*x1^n / (ta1^n + x1^n) + b1*tb1^n / (tb1^n + x2^n) - k1*x1);
    nx2 = x2 + dt*( a2*x2^n / (ta2^n + x2^n) + b2*tb2^n / (tb2^n + x1^n) - k2*x2);
    residual = nx1-x1;
    x1 = nx1; x2 = nx2;
end
sspoint = [x1 x2];

end

