如何解决r中的未知变量?

run*_*rds 2 statistics r

如何在R中设置两个等于彼此的方程式来求解?

例如:

xlog(x)=8273
Run Code Online (Sandbox Code Playgroud)

找到X?

rns*_*nso 15

使用以下形式的等式:x*log(x)-8273 = 0

你应该知道答案的范围.然后使用uniroot功能:

f <- function(x)  (x*log(x)-8273)
uniroot(f, lower=0.1, upper=100000000)$root
[1] 1170.897
Run Code Online (Sandbox Code Playgroud)

或者更一般的形式:

f <- function(x,y)  (x*log(x)-y)
uniroot(f, y=8273, lower=0.1, upper=100000000)$root
[1] 1170.897
Run Code Online (Sandbox Code Playgroud)


Ben*_*ker 5

事实证明(在Wolfram Alpha的帮助下)这个特殊的解决方案与Lambert W功能(Wolfram Alpha称之为"产品日志"功能)有关:

library(emdbook)
exp(lambertW(8273))  ## 1170.897
Run Code Online (Sandbox Code Playgroud)

Lambert W还有其他几种R软件包(LambertW,spatstat,pracma,condmixt,VGAM).