
This is a non-linear equation in "mu" that I want to solve numerically using R. All paired (x, y) are known. So the only variable is "mu"
Now I wrote a function in R. Then I try to get the root using the package "rootSolve". But he gives an error.
This is my function code:
f = function(k){
sum(((2*exp(-x) - 1)*(2*exp(-y)- 1))/
(1 + k*(2*exp(-x) - 1)*(2*exp(-y)- 1)))
}
This is the error after running "uniroot.all" from the "rootSolve" package:
> library(rootSolve)
> uniroot.all(f, interval = c(-1, 1))
numeric(0)
Warning message:
In k * (2 * exp(-x) - 1) :
longer object length is not a multiple of shorter object length
In addition, I am looking for my root in the interval (-1, 1).
Can anybody help? I think my way of defining a function is wrong. Therefore, this error occurs.
Can anyone confirm that my way of defining the function in the picture is correct or not?
Thank you in advance!
Let me add something else:
( , ), (x, y), f(-1) < f(1) and also f(-1) * f(1) < 0. .
, :
R. , curve(f, from = -1, to = 1)
Vectorize(f), curve.
- ?
!