![](/img/trans.png)
[英]Given an x and polynomial equation, is there way to get the y value using r?
[英]How to get the value of x in an expoetial equation in R
我有以下等式,我想得到 x 的值。
(1/(1+exp(-(0.1348*x + 64.7027))))+ (x-70)=0
我嘗試了 library(nleqslv),但沒有成功獲得 x
定義一個函數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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.