如何解决r中的未知变量? [英] How to solve for unknown variables in r?

查看:32
本文介绍了如何解决r中的未知变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 R 中设置两个相等的方程来求解?

How do I set two equations equal to each other in R to solve?

例如:

xlog(x)=8273

找到 X?

推荐答案

使用公式如下:x*log(x)-8273 = 0

您应该对答案所在的范围有所了解.然后使用uniroot函数:

You should have some idea of the range in which the answer lies. Then use uniroot function:

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

或更一般的形式:

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

这篇关于如何解决r中的未知变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆