简体   繁体   English

如何在R中的expoetial方程中获得x的值

[英]How to get the value of x in an expoetial equation in R

I have the following equation and I want to get the value of x.我有以下等式,我想得到 x 的值。

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

I try library(nleqslv), but I was unsuccessful to get x我尝试了 library(nleqslv),但没有成功获得 x

Define a function f :定义一个函数f

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

In order to see where a root might fall, plot the function, trying several limits.为了查看根可能落在何处,绘制函数,尝试几个限制。

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

The one above has end points of opposite signs, so it's a job for uniroot .上面那个有相反符号的端点,所以这是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

In order to have the value of the root, try any of the two ways below.为了获得根的值,请尝试以下两种方法中的任何一种。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM