I want solve a root for this nonlinear function, and I input S, S2, S3 and S4 I calculated in advance. S2/(2*S) is the best estimator for the root; how can I set it as a starting point?
Does the code
interval = c(-1000,100)
contain the max & min of my roots
so that I can omit the code f.lower
?
R <- numeric(178)
for (i in (1:178)) {
f <- function(x){1 - exp(S[i]/x)+ (S2[i]/(2*(x^2)))- ((S2[i]^(3/2)*S3[i])/(6*(x^3))) +
(((S2[i]^2)*S4[i])/(24*(x^4)))}
R[i] <- uniroot(f,interval = c(-1000,100), f.lower = S2[i]/(2*S[i]))$root
}
I have tried to Google it, but I didn't find any code to set a starting point. Thanks for all your suggestions.