Subject: ugly weird expression to be passed to R??
From: dlakelan
Date: Mon, 28 Jul 2008 15:47:54 -0700
I have a differential equation model for the probability density of a
random variable. I am totally stoked on the fact that Maxima was able to
solve this problem. The result is a maxima expression that is pretty
damn ugly. here is the ratsimp version:
(%o40) -log(2)*(%e^(O2p*(k2*N2+k1*N1+1)*T)-%e^((k2*N2+k1*N1+1)*T))
*%e^(%e^-((k2*N2+k1*N1+1)*T)
*(log(2)*%e^(k2*O2p*N2*T+k1*O2p*N1*T+O2p*T+1)
-log(2)*k2*O2p*N2*T*%e^(k2*N2*T+k1*N1*T+T+1)
+log(2)*k2*N2*T*%e^(k2*N2*T+k1*N1*T+T+1)
-log(2)*k1*O2p*N1*T*%e^(k2*N2*T+k1*N1*T+T+1)
+log(2)*k1*N1*T*%e^(k2*N2*T+k1*N1*T+T+1)
-log(2)*O2p*T*%e^(k2*N2*T+k1*N1*T+T+1)
+log(2)*T*%e^(k2*N2*T+k1*N1*T+T+1)
-log(2)*%e^(k2*N2*T+k1*N1*T+T+1)
-k2^2*O2p*N2^2*T*%e^((k2*N2+k1*N1+1)*T)
+k2^2*N2^2*T*%e^((k2*N2+k1*N1+1)*T)
-2*k1*k2*O2p*N1*N2*T*%e^((k2*N2+k1*N1+1)*T)
+2*k1*k2*N1*N2*T*%e^((k2*N2+k1*N1+1)*T)
-2*k2*O2p*N2*T*%e^((k2*N2+k1*N1+1)*T)
+2*k2*N2*T*%e^((k2*N2+k1*N1+1)*T)
-k1^2*O2p*N1^2*T*%e^((k2*N2+k1*N1+1)*T)
+k1^2*N1^2*T*%e^((k2*N2+k1*N1+1)*T)
-2*k1*O2p*N1*T*%e^((k2*N2+k1*N1+1)*T)
+2*k1*N1*T*%e^((k2*N2+k1*N1+1)*T)
-O2p*T*%e^((k2*N2+k1*N1+1)*T)+T*%e^((k2*N2+k1*N1+1)*T)
+k2*O2p*N2*%e^((k2*N2+k1*N1+1)*T)
-k2*N2*%e^((k2*N2+k1*N1+1)*T)
+k1*O2p*N1*%e^((k2*N2+k1*N1+1)*T)
-k1*N1*%e^((k2*N2+k1*N1+1)*T)+O2p*%e^((k2*N2+k1*N1+1)*T)
-%e^((k2*N2+k1*N1+1)*T))
/((O2p-1)*(k2*N2+k1*N1+1)))
I want to do a maximum likelihood estimation of the values of k1,k2, and
Cmax given data for other variables. I think I can do a little cleaning
up of the output of maxima's function "fortran" and then hand it to R
for numerical analysis.
Does anyone have a suggestion for how to clean up this expression in
maxima before outputting to fortran? I've tried pickapart and a few
other things to figure out the structure of this expression, and so far
haven't figured out anything helpful to simplify it further. Pickapart
and reveal mostly make it harder to read for me.
Has anyone created a function like "fortran" but that outputs something
compatible with some sort of more modern language (ie. no line numbers
and continuation lines, and column indentation etc?) anyone want to give
a try at converting the "fortran" function in maxima to output "R" code?
I think R and maxima together are an extremely powerful combo. it would
be nice to be able to directly export to R syntax.