I have to maximize $Q(\theta;\theta')$ with respect to $\theta$ at every iteration of my EM algorithm. It boils down to solving these two equations for $\eta$ and $\gamma$ (all the $s_i$s are sufficient statistics):
$$ 0 = -\frac{1}{2}(1 + e^{\eta} - e^{-\eta} - e^{-2\eta} ) + 2e^{-\gamma}\left[s_3(1+e^{-\eta}) + (s_0 - s_1)(1-e^{-\eta})\right], $$ $$ 0 = -\frac{T}{2} + e^{-\gamma}\left\{(e^{\eta}+e^{-\eta} + 2)^{-1})\left[ 2(s_0-s_1-s_3) \right] + \frac{s_1+s_2}{2} + s_3 \right\}. $$
I try to relegate the algebra to the computer, but the following code just hangs for a super long time.
from sympy.solvers import solve
from sympy import Symbol, exp
# constants
T = Symbol('T')
s0 = Symbol('s0')
s1 = Symbol('s1')
s2 = Symbol('s2')
s3 = Symbol('s3')
s4 = Symbol('s4')
# variables
eta = Symbol('eta')
gamma = Symbol('gamma')
solve([-T/2+exp(-gamma)*(2*(s0-s1-s3)/(exp(eta)+exp(-eta)+2)+(s1+s2)/2 +s3),
-(1/2)*(1 + exp(eta)-exp(-eta)-exp(-2*eta)) + 2*exp(-gamma)*(s3*(1+exp(-eta))+(s0-s1)*(1-exp(-eta)))],
[eta,gamma])
Any advice on getting things to run or solve the system by hand? Solving by hand would do the job, but I would prefer an answer that deals with getting the code to run. I figure I'll be in a similar spot when I try to fit a different model in the future.