简体   繁体   中英

Polynomial roots

I have a small issue with a polynomial:

z²+alpha1*z + alpha2 = 0

I need to fins the values of alpha1 and alpha2 wihtin the roots of |z| < 1. Is there any program in R or Matlab able to do it? the thing is that the alpha values are not known. I need to find the allowed area where the roots of the polynomial are <= |1|

@Jonel_R, your problem can be solved analytically.

First I'll rename your variables to make it easier to type. I'll also use some notation abuse...

We want to find the values (a, b) such that the roots of z^2 + az + b == 0 satisfy the property |z|<=1 .

The roots are given by (-a +- sqrt(d))/2 , where d = a^2 - 4b

There are 3 possibilities. Two real distinct roots, one real root or two complex conjugate roots.

The middle case happens when d = 0 , ie, b = a^2 / 4 . This is a parabola in the a vs. b plane. Not all points in this parabola generate polynomials whose root satisfy |z|<=1 , however. The root, is this case, is simply -a/2 , so we mus add the condition -1 <= a/2 <=1 , ie, -2 <= a <= 2 .

Now let's consider the first case. The points in the a vs. b plae that generate polynomials with two distinct real roots lie below the parabola, ie, they must satisfy b < a^2/4 . The additional condition is that |z| = |(-a +- sqrt(d))/2| <= 1 |z| = |(-a +- sqrt(d))/2| <= 1 |z| = |(-a +- sqrt(d))/2| <= 1 .

The condition can be written as -1 <= (-a +- sqrt(d))/2 <= 1 , where +- means both roots must satisfy the condition. Working this out we get:
a-2 <= sqrt(d) <= a+2 & a-2 <= -sqrt(d) <= a+2

Since both sqrt(d) and -sqrt(d) must lie in the interval [a-2, a+2] , and d > 0 , then this interval must contain zero in its interior. This means -2 < a < 2 .

The conditions can be joined as: a-2 <= -sqrt(d) < 0 < sqrt(d) <= a+2

Squaring gives: (a-2)^2 >= d & d <= (a+2)^2

d <= a^2 - 4a + 4 & d <= a^2 + 4a + 4

-4b <= -4a + 4 & -4b <= +4a + 4

b >= a-1 & b >= -a-1

This means that b must be located above the lines b = a-1 and b=-a-1 . Also, a must be in [-2,2] . And, of course, we must have b < a^2/4 . Wow...

Now the last case: complex roots. This is easier. Since d < 0 , the roots are -a/2 +- i * sqrt(-d)/2 . The absolute value of this is a^2/4 - d/4 . This equals b , simply. So the condition is b <= 1 , and, as always, b lying above that parabola.

That's it... Quite interesting problem. :-)

You can try the following test function: It'll plot the points with real roots in blue and complex roots in red.

test <- function(x=2, n=10000)
{
    plot(c(-x,x), c(-x,x), type="n")

    plot(function(a) (a^2)/4, from=-x, to=x, add=T)

    plot(function(a) a-1, from=-x, to=x, add=T)

    plot(function(a) -a-1, from=-x, to=x, add=T)

    a <- runif(n, -x, x)

    b <- runif(n, -x, x)

    for( i in 1:n )
    {
        if( all(abs(polyroot(c(b[i],a[i],1))) <= 1) )
        {
            col <- ifelse(b[i] < 0.25*a[i]^2, "blue", "red")

            points(a[i], b[i], pch=".", col=col)
        }
    }
}

BTW: the syntax for polyroot is polyroot(c(C, B, A)) gives the roots of Ax^2 + Bx + C . I believe @agstudy response got it wrong.

Similar to matlab solution in R ,

  polyroot(c(1,alpha1,alpha2))

EDIT here a method to get the values of alpha graphically, it can be used to get intution about the plausible values. The idea here is :

  • choose a range of aplha1
  • choose a range of alpha2
  • for each combination of alpha1 and alpha2, compute the roots. Compute the module (||), if > 1 we remove it.
  • we get a grid of values with 4 column: alpha1,alpha2,norm1,norm2 where All the norms are <1
  • I plot alpha1 versus alpha2 to get regions...

So the code

## I choose alpha1 in interavl [-1,1]
alpha1 <- seq(-1, 1, length=200)
## I choose alpha2 in interavl [-2,2]
alpha2 <- seq(-2, 2, length=200)
dat <- expand.grid(data.frame(alpha1,alpha2))
## for each combination of (alpha1,alpha2)
## i compute the module of the roots 
## I replace |roots|> 1 by NA
ll <- apply(dat,1,function(x) {
  rr =Mod(polyroot(c(1,x['alpha1'],x['alpha2'])))
  res <- ifelse(rr>1,NA,rr)
  if (length(res)==1) res <- rep(res,2)
  if (length(res)==0) res <- rep(NA,2)
  else res
  })
dat <- na.omit(cbind(dat,t(ll)))
## finally i plot the result
library(lattice)
xyplot(alpha2~alpha1,data=dat)

在此输入图像描述

In matlab:

roots(1,alpha1,alpha2)

see http://www.mathworks.se/help/matlab/ref/roots.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM