ugly weird expression to be passed to R??



On Mon, Jul 28, 2008 at 6:47 PM, dlakelan <dlakelan at street-artists.org> wrote:
> ... 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.
> ...I think R and maxima together are an extremely powerful combo. it would
> be nice to be able to directly export to R syntax.


Why do you want to use "fortran" rather than simply "string"?  The
Maxima output is almost exactly what you want in R. In fact, I took
exactly what you had in your email, substituted "ee" for "%e" using
subst, and surrounded the expression with parentheses (so that R would
know that the expression was incomplete) and it just ran in R with no
other changes (see below).

Of course you could get fancier (change %e^x to exp(x) etc.)....

             -s

-----------------------

<<<Random parameter values>>>

> N1 <- 1361955e-8
> N2 <- 207579012e-8
> O2p <- 91274604e-8
> T <- -160730450e-8
> k1 <- 186969585e-8
> k2 <- 226017723e-8
> ee <- 2.71828
> (
+ -log(2)*(ee^(O2p*(k2*N2+k1*N1+1)*T)-ee^((k2*N2+k1*N1+1)*T))
<<<Plus-sign is R asking for more input since there is an unmatched paren>>>
+               *ee^(ee^-((k2*N2+k1*N1+1)*T)
+                   *(log(2)*ee^(k2*O2p*N2*T+k1*O2p*N1*T+O2p*T+1)
...........
+                    -ee^((k2*N2+k1*N1+1)*T))
+                   /((O2p-1)*(k2*N2+k1*N1+1)))
+ )
[1] -0.4604812

...