I have an equation here:
2/(1+exp(-4.292*x))-1 = 0.95
I want to find the unknown x without changing the formula. Can this be done in R or Excel? Thank you in advance!
I have an equation here:
2/(1+exp(-4.292*x))-1 = 0.95
I want to find the unknown x without changing the formula. Can this be done in R or Excel? Thank you in advance!
Try Solve
in Ryacas0 for a symbolic result or use that and convert it to a numeric result:
library(Ryacas0)
library(readr)
x <- Sym("x")
res <- Solve(2/(1+exp(-4.292*x))-1 == 0.95, x); res
## Yacas vector:
## [1] x == -(log(0.05/1.95)/4.292)
res2 <- Eval(res); res2
## [1] "( x == 0.853579134699358 )"
parse_number(res2)
## [1] 0.8535791
Alternatively for a numeric result directly use Ryacas0 Newton
. The arguments are the expression to solve for its root, the variable name, the starting value and the accuracy.
x <- Sym("x")
Eval(Newton(2/(1+exp(-4.292*x))-1-0.95, x, 1, 0.0001))
## [1] 0.8535791
Apart from the great solutions already provided here if you are just interested in a "convenient" way to solve such equations the (mathematical) search engine "WolframAlpha" might be interesting, too:
https://www.wolframalpha.com/input?i=solve%282%2F%281%2Bexp%28-4.292*x%29%29-1+%3D+0.95%3B+x%29
It comes to the same final result for x = 0.853579, but can even write it in a closed form : x = (250 * (log(3) + log(13)))/1073
(with log()
using exp(1)
as base)