I am using MATLAB and I want to find the root of an equation F(x)-u=0. Here u=0.2861
and
F=normcdf(sqrt(lambda/t)*(t/mu-1))+exp(2*lambda/mu)*normcdf(-sqrt(lambda/t)*(t/mu+1)).
The value of lambda
and mu
are both 1.
I typed the following code
[x,fval] = fzero(@(t) normcdf(sqrt(lambda/t)*(t/mu-1))+exp(2*lambda/mu)*normcdf(-sqrt(lambda/t)*(t/mu+1))-u, 10);
and hope this can help me find the root. I can show mathematically that this equation has unique root. However, I keep on getting the following error
Error using
erfc
Input must be real and full.Error in
normcdf
>localnormcdf
(line 128)p(todo) = 0.5 * erfc(-z ./ sqrt(2));
Error in
normcdf
(line 50)[varargout{1:max(1,nargout)}] = localnormcdf(uflag,x,varargin{:});
Error in
Test
>@(t)normcdf(sqrt(lambda/t)*(t/mu-1))+exp(2*lambda/mu)*normcdf(-sqrt(lambda/t)*(t/mu+1))-u
Error in
fzero
(line 363)a = x - dx; fa = FunFcn(a,varargin{:});
Then I did a "brutal force" method.
t = [0:0.001:20];
F = normcdf(sqrt(lambda./t).*(t/mu-1))+exp(2*lambda/mu).*normcdf(-sqrt(lambda./t).*(t/mu+1))-u;
plot(t,F)
I can clearly eyeball that F(t)-u
is increasing in t
and the root is around 0.4. My question is why fzero
does not work in this case and is there a way to make fzero
work?