簡體   English   中英

求解R中x的多項式方程

[英]Solve polynomial equation for x in R

這可能非常簡單,但是如何使用R求解x的以下方程式? X應該是一個實數。

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

簡短的答案是,該多項式在實數集中沒有根,您可以在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

您可能還會考慮使用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))))                                                            

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM