简体   繁体   中英

Solve polynomial equation for x in R

This might be insanely simple, but how can I solve the following equation for x using R? X should be a real number.

((4*x)^2+(2*x)^2+(1*x)^2+(0.5*x)^2+0.25)*((1 - 0.167)/0.167) = 1

the short answer is that this polynomial has no roots in the set of real numbers, you can see that analytically with some help from R :

> #((4*x)^2+(2*x)^2+(1*x)^2+(0.5*x)^2+0.25)*((1 - 0.167)/0.167) = 1
> 
> # first add up your coefficients 
> coefs <- c(16 + 4 + 1+ .25 , .25)
> coefs 
[1] 21.25  0.25
> 
> # apply the second product 
> coefs <- (coefs - 0.167*coefs)/0.167
> coefs
[1] 105.995509   1.247006
> 
> # move the one from one side to another
> 
> coefs <- coefs - c(0,1)
> coefs
[1] 105.995509   0.247006
> 
> #106*x^2 + 1/4 = 0 has no solution in the set of real number

You might also consider using Ryacas that can handle/solve symbolic expression on basis of the interface to the Computer Algebra System yacas. Of course, the perfomance of yacas is limited when it comes to more advanced functions in comparison to, eg, Maple, however, in your case it works fine.

#Ryacas solves the equation and shows that there is only a complex solution 
library("Ryacas")
yacas("Solve(((4*x)^2+(2*x)^2+(1*x)^2+(0.5*x)^2+0.25)*((1 - 0.167)/0.167) == 1, x)")

# expression(list(x == complex_cartesian(0,  root(0.00688875/2.95610875, 2)),                                              
#                 x == complex_cartesian(0, -root(0.00688875/2.95610875, 2))))                                                            

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