如何获得R中的幂方程中x的值

问题描述 投票:0回答:1

我有下面的等式,我想得到x的值。

(1/(1+exp(-(0.1348*x +  64.7027))))+ (x-70)=0

我尝试使用library(nleqslv),但未能成功获得x

r exponential
1个回答
0
投票
定义函数f

f <- function(x) 1/(1+exp(-(0.1348*x + 64.7027))) + (x - 70)

[为了查看根可能落在哪里,绘制函数,尝试几个限制。

curve(f, from = 0, to = 100)

上面的一个端点的符号相反,所以这是uniroot的工作。

uniroot(f, interval = c(0, 100)) #$root #[1] 69 # #$f.root #[1] 0 # #$iter #[1] 1 # #$init.it #[1] NA # #$estim.prec #[1] 69

为了获得根的值,请尝试以下两种方法中的任何一种。

uniroot(f, interval = c(0, 100))$root #[1] 69 y <- uniroot(f, interval = c(0, 100)) y$root #[1] 69

© www.soinside.com 2019 - 2024. All rights reserved.