Erlang b formula continuous
Show older comments
Hello,
I'm trying to use a continuous form of Erlang B formula in my code as a function. I also need to differentiate this function so I need to use a symbolic variable in it. I'm using the function in: https://www.mathworks.com/matlabcentral/fileexchange/37279-erlang-b-continuation?product=EL
However, gammainc does not accept symbolic variables, i've tried to use igamma(nu,z)/gamma(nu) for the incomplete gamma upper, the problem with this one is that once I use subs command and then vpa, it always outputs NaN,
I also try another function -> gamma_symbolic (which requires maple as symengine, now i'm using matlab R2015b that cannot change between mupad and maple anymore) https://nl.mathworks.com/matlabcentral/answers/96854-how-can-i-use-incomplete-gamma-function-gammainc-in-matlab-7-5-r2007b-to-accept-symbolic-input
Please help. I spent really a lot of time trying to fix this issue. But I still haven't solved it yet!
PS. Why does the first alternative always outputs NaN? I don't understand. For example, I do:
syms S
tes = igamma(sym(S),0.5)/gamma(sym(S))
diftes = diff(tes,S)
subs(diftes, S,6)
which outputs:
tes =
igamma(S, 1/2)/gamma(S)
diftes =
((1/2)^S*(hypergeom([S, S], [S + 1, S + 1], -1/2)/S^2 - (1/(1/2)^S*pi*(log(2) + psi(1 - S) - pi*cot(pi*(S - 1))))/(gamma(1 - S)*sin(pi*(S - 1)))) + (1/2)^S*log(1/2)*expint(1 - S, 1/2))/gamma(S) - (psi(S)*igamma(S, 1/2))/gamma(S)
ans =
NaN
Please help. It seems like I can never solve this!
5 Comments
Torsten
on 5 Aug 2016
Plotting "diftes" should show why you can't evaluate it for S=6.
Best wishes
Torsten.
Torsten
on 5 Aug 2016
By the way:
I think you mean
tes=igamma(0.5,S)/gamma(0.5),
don't you ?
Best wishes
Torsten.
K_Kharis
on 5 Aug 2016
Torsten
on 5 Aug 2016
Please exactly tell us whether you want to analyze
igamma(0.5,S)/gamma(0.5)
or
igamma(S,0.5)/gamma(S)
Best wishes
Torsten.
Answers (0)
Categories
Find more on Code Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!