On 16/10/2008, at 10:44 AM, Erin Hodgess wrote:

Dear R people:

Is there a way to perform simple polynomial multiplication; that is,
something like
(x - 3) * (x + 3) = x^2 - 9, please?

I looked in poly and polyroot and expression.  There used to be a
package that had this, maybe?

The PolynomF package from CRAN will do this.  E.g.

install.packages("PolynomF")
library(PolynomF)
a <- polynom(-3,1)
b <- polynom(3,1)
a*b

The default is to print ``-9 + x^2'' rather than ``x^2 - 9''.

You can of course type
print(a*b,decreasing=TRUE)

to get ``x^2 - 9'', but this is a bit kludgy.  It would be nice to have
an options() setting to change the default.  You could program that up
yourself of course.  (And then send the contributed the improvement to
Bill Venables!)

        cheers,

                Rolf

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to