similar to: Is there a way to find all roots of a polynomial equation in R?

Displaying 20 results from an estimated 5000 matches similar to: "Is there a way to find all roots of a polynomial equation in R?"

2009 Jan 11
4
How to get solution of following polynomial?
Hi, I want find all roots for the following polynomial : a <- c(-0.07, 0.17); b <- c(1, -4); cc <- matrix(c(0.24, 0.00, -0.08, -0.31), 2); d <- matrix(c(0, 0, -0.13, -0.37), 2); e <- matrix(c(0.2, 0, -0.06, -0.34), 2) A1 <- diag(2) + a %*% t(b) + cc; A2 <- -cc + d; A3 <- -d + e; A4 <- -e fn <- function(z) { y <- diag(2) - A1*z - A2*z^2 - A3*z^3 - A4*z^4
2008 Oct 15
4
a really simple question on polynomial multiplication
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? thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodgess at
2013 Mar 01
2
solving x in a polynomial function
Hi there, Does anyone know how I solve for x from a given y in a polynomial function? Here's some example code: ##example file a<-1:10 b<-c(1,2,2.5,3,3.5,4,6,7,7.5,8) po.lm<-lm(a~b+I(b^2)+I(b^3)+I(b^4)); summary(po.lm) (please ignore that the model is severely overfit- that's not the point). Let's say I want to solve for the value b where a = 5.5. Any thoughts? I did
2002 Oct 09
5
polynomial
Any better (more efficient, built-in) ideas for computing coef[1]+coef[2]*x+coef[3]*x^2+ ... than polynom <- function(coef,x) { n <- length(coef) sum(coef*apply(matrix(c(rep(x,n),seq(0,n-1)),ncol=2),1,function(z)z[1]^z[2])) } ? Ben -- 318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
2001 Jan 17
2
PR#751
I'd just like to report a possible R bug--or rather, confirm an existing one (bug #751). I have had some difficulty using the polyroot() function. For example, in Win 98, R 1.1.1, > polyroot(c(2,1,1)) correctly (per the help index) gives the roots of 1 + (1*x) + (2*x^2) as [1] -0.5+1.322876i -0.5-1.322876i However, > polyroot(c(-100,0,1)) gives the roots of [1] 10+0i -10+0i
2000 Nov 28
2
BUG: polyroot() (PR#751)
I have found that the polyroot() function in R-1.1.1(both solaris and Win32 version) gives totally incorrect result. Here is the offending code: # Polyroot bug report: # from R-1.1.1 > sort(abs(polyroot(c(1, -2,1,0,0,0,0,0,0,0,0,0,-2,5,-2,0,0,0,0,0,0,0,0,0,1,-2,1)))) [1] 0.8758259 0.9486499 0.9731015 1.5419189 1.7466214 1.7535362 1.7589484 [8] 2.0216317 2.4421509 2.5098488 2.6615572
2005 Aug 19
1
Using lm coefficients in polyroot()
Dear useRs, I need to compute zero of polynomial function fitted by lm. For example if I fit cubic equation by fit=lm(y~x+I(x^2)+i(x^3)) I can do it simply by polyroot(fit$coefficients). But, if I fit polynomial of higher order and optimize it by stepAIC, I get of course some coefficients removed. Then, if i have model y ~ I(x^2) + I(x^4) i cannot call polyroot in such way, because there is
2009 May 12
2
newtons method
Hi, Does anyone know how to code newton's method for finding the roots of polynomial functions? im not sure whether i need to do this manually, or just code something with a loop to stop when it gets to the desired result thanks guys! _________________________________________________________________ Looking to move somewhere new this winter? Let ninemsn property help [[elided Hotmail
2009 May 12
2
newtons method
Hi, Does anyone know how to code newton's method for finding the roots of polynomial functions? im not sure whether i need to do this manually, or just code something with a loop to stop when it gets to the desired result thanks guys! _________________________________________________________________ Looking to move somewhere new this winter? Let ninemsn property help [[elided Hotmail
2010 Jan 05
4
solving cubic/quartic equations non-iteratively
To R-helpers, R offers the polyroot function for solving mentioned equations iteratively. However, Dr Math and Mathworld (and other places) show in detail how to solve mentioned equations non-iteratively. Do implementations for R that are non-iterative and that solve mentioned equations exists? Regards, Mads Jeppe
2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
Colleagues, I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, Error in yfu n(x,10,20) : object 'x' not found. I hope someone can tell we how I can fix the problem
2012 Jan 24
1
problems with rollapply {zoo}
Here is a relatively simple script (with comments as to the logic interspersed): # Some of these libraries are probably not needed here, but leaving them in place harms nothing: library(tseries) library(xts) library(quantmod) library(fGarch) library(fTrading) library(ggplot2) # Set the working directory, where the data file is located, and read the raw data
2007 Nov 23
1
complex conjugates roots from polyroot?
Hi, All: Is there a simple way to detect complex conjugates in the roots returned by 'polyroot'? The obvious comparison of each root with the complex conjugate of the next sometimes produces roundoff error, and I don't know how to bound its magnitude: (tst <- polyroot(c(1, -.6, .4))) tst[-1]-Conj(tst[-2]) [1] 3.108624e-15+2.22045e-16i
2001 Jul 16
1
polyroot() (PR#751)
In a bug report from Nov.28 2000, Li Dongfeng writes: ----- I have found that the polyroot() function in R-1.1.1(both solaris and Win32 version) gives totally incorrect result. Here is the offending code: # Polyroot bug report: # from R-1.1.1 > sort(abs(polyroot(c(1,-2,1,0,0,0,0,0,0,0,0,0,-2,5,-2,0,0,0,0,0,0,0,0,0,1,-2)))) [1] 0.8758259 0.9486499 0.9731015 1.5419189 1.7466214 1.7535362
2002 Mar 19
3
multiroot() anyone?
Dear list, Did anybody have something like multiroot(), similar to uniroot() only for several varibles/function? I know the difficulty several varibles bring. But for nice functions, it can be useful. We are thinking of writing one....I thought to ask first. Mai Zhou -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
2012 Apr 19
1
How to find a root for a polynomial between [-inf, -3]?
Hi all, I have a polynomial (a big one) and I would like to find a root of it between [-inf, -3] (it's known there is one root in this interval)... How to find that root? In using "uniroot" I need to supply the bounds.... In using "polyroot" I need to write it in the strict sens polynomial format... but I cannot... i.e. the polynomial is implicit... Thank you!
2020 Oct 06
0
Solving a simple linear equation using uniroot give error object 'x' not found
On 06/10/2020 11:00 a.m., Sorkin, John wrote: > Colleagues, > I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message, > Error in yfu n(x,10,20) : object 'x' not found. > > I hope someone can tell we how I can fix
2010 Oct 14
1
Fw: Problem to create a matrix polynomial
Awaiting some suggestion. Was my question not very understandable? Please let me know how can I offer more elaborate clarification. Additionally, I would like to solve the determinant of "p1" for the values of "z" (I am working with some multivariate time series modelling). When I use det() function, it am getting error that, that function is not for objects with class
2004 Mar 22
1
problem with seasonal arima
hallo to all I've to calculate an arima model and I need only the first and 365 th parameter and also the sar1 and the intercept, so I'm traing with: arima(X,order=c(365,0,0),seasonal=list(order=c(1,0,0),..),fixed=c(NA,rep(0,363),NA,NA,NA),transform.pars=F) but the error answer is: Error in polyroot(z) : polynomial degree too high (49 max) also there are problems in allocating memory
2004 Feb 16
0
how to solve a linear equation system with polynomial factors?
I'm looking for a way to solve a linear equation system where the factors are polynomials: Here is a simplified example (To solve my problem, I have to deal with dimensions larger than 2): ( s + 2) x1 + (s - 3) x2 = 2 ( s^2 + 2s - 1) x1 - 2 x2 = 1 Theoretically the solution is easy: By performing polynomial multiplications, divisions and sums. I found out, that R is able to