[R] eigenvalues of matrices of partial derivatives with ryacas
Adam Zeilinger
zeil0006 at umn.edu
Fri Mar 16 00:51:37 CET 2012
Hello,
I am trying to construct two matrices, F and V, composed of partial
derivatives and then find the eigenvalues of F*Inverse(V). I have the
following equations in ryacas notation:
> library(Ryacas)
> FIh <- Expr("betah*Sh*Iv")
> FIv <- Expr("betav*Sv*Ih")
> VIh <- Expr("(muh + gamma)*Ih")
> VIv <- Expr("muv*Iv")
I successfully found the partial derivatives:
> f11 <- deriv(FIh, "Ih")
> f12 <- deriv(FIh, "Iv")
> f21 <- deriv(FIv, "Ih")
> f22 <- deriv(FIv, "Iv")
> v11 <- deriv(VIh, "Ih")
> v12 <- deriv(VIh, "Iv")
> v21 <- deriv(VIv, "Ih")
> v22 <- deriv(VIv, "Iv")
Next I would like to put these partial derivatives into two matrices, F
and V:
> F <- Expr("{{f11, f12}, {f21, f22}}")
> V <- Expr("{{v11, v12}, {v21, v22}}")
Finally, I would like to find the eigenvalues of F*Inverse(V).
Something like:
> yacas("EigenValues(F*Inverse(V))")
However, this does not work. I get the following error message:
In function "While" : bad argument number 1 (counting from 1)The
offending argument $ii49<= $nr49 evaluated to Not
Length-1<0CommandLine(1) : Invalid argument
According to Mathematica, the correct eigenvalues are:
{-((Sqrt[betah] Sqrt[betav] Sqrt[Sh] Sqrt[Sv])/Sqrt[gamma muv + muh muv]),
(Sqrt[betah] Sqrt[betav] Sqrt[Sh] Sqrt[Sv])/Sqrt[gamma muv + muh muv]}
I don't understand the error message. Any suggestions on how to get the
correct eigenvalues using R would be greatly appreciated. I'm using R
2.14.0.
Sincerely,
Adam
--
Adam Zeilinger
Post Doctoral Scholar
Department of Entomology
University of California Riverside
www.linkedin.com/in/adamzeilinger
More information about the R-help
mailing list