求解R中x的多项式方程

时间:2017-11-01 15:09:57

标签: r equation equation-solving

这可能非常简单,但如何使用R解决x的以下等式? X应该是一个实数。

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

2 个答案:

答案 0 :(得分:2)

简短的回答是这个多项式在实数集中没有根, 你可以在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

答案 1 :(得分:0)

您也可以考虑使用Ryacas来处理/解决基于计算机代数系统yacas的接口的符号表达式。当然,与例如Maple相比,当涉及到更高级的功能时,yacas的性能是有限的,但是,在你的情况下,它可以正常工作。

#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))))