Hello everyone!

I am (trying <https://github.com/jessegrabowski/gEconpy>) to use Sympy to 
automatically derive first order conditions and a log-linear approximation 
to non-linear systems of equations from user provided problem descriptions. 
An example system might look something like this:

-C_t - I_t + K_t-1*r_t + L_t*w_t 
I_t - K_t + K_t-1*(1 - delta) 
-lambda_t + C_t**(-sigma_C) 
-L_t**sigma_L + lambda_t*w_t 
beta*(lambda_t+1*r_t+1 + lambda_t+1*(1 - delta)) - lambda_t 
A_t*K_t-1**alpha*L_t**(1 - alpha) - Y_t 
alpha*A_t*K_t-1**(alpha - 1)*L_t**(1 - alpha) - r_t 
A_t*K_t-1**alpha*(1 - alpha)/L_t**alpha - w_t 
rho_A*log(A_t-1) + epsilon_A_t - log(A_t)

A priori I know that this particular system can be written in reduced form 
in only two state variables, A_t and K_t. At the bare minimum, many 
equations can be eliminated via substitution. For example, we clearly see 
that lambda_t = C_t ** (-sigma_C), and we could make that substitutions 
everywhere to eliminate the equation. Less obviously, I can combine 
equations -4, -3 and -2 to get a single expression for w_t as a function of 
r_t, eliminating that variable.

If the system were linear, I could easily obtain the reduced form in Sympy 
with something like this:

A, b = sp.linear_eq_to_matrix(system)
sp.rref(sp.hstack(A, b))

But in the non-linear case I understand there is no "nice" way to do this.

I guess I am asking if anyone knows of tricks (or better yet algorithms) to 
attack a problem like this? I currently use a big stack of heuristics, for 
example looking for equations with only 2 non-parameter atoms in the form y 
= f(x), then recursively making substitutions. These heuristics are quite 
flaky though, because I'm quite out of my depth.

Thank you to everyone for such a marvelous open source tool! 

Jesse

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/146998fa-c6e5-4c5b-8c8a-76861b7c7446n%40googlegroups.com.

Reply via email to