Solve for integral limit

混江龙づ霸主 提交于 2019-12-20 03:23:56

问题


I need to find the limit of an integral in a numerical way, knowing the result of that integral. What I need to solve is:

As you can see, that is the incomplete beta function. I know a, b and c. And the integral limits are from 0 to x. I need to find x.


回答1:


The fzero function can solve all sorts of nonlinear equations.

First, calculate the incomplete beta function as a function of X (I subtracted the c because we want to find the x that makes Y=0):

Y=@(X) beta(a,b)*betainc(X,a,b)-c

or, without using the builtin betainc function, and instead using symbolic algebra:

syms t x
Y=matlabFunction(int(t^(a-1)*(1-t)^(b-1),t,0,x)-c);

Now use fzero, since x must be between 0 and 1, we constrain the solution to be within [0 1]:

x=fzero(Y,[0 1])

If fzero doesn't work, the simplest numerical method to try is a bisection search. It's easy, and works well here, so why not use it. I did assume that Y(x) is monotonically increasing on [0 1], but I think that's always the case.

x=0.5;
xmin=0;
xMAX=1;
tol=1e-12;
numIts=0;
while abs(Y(x))>tol
    if Y(x)>0
        xMAX=x;
    elseif Y(x)<0
        xmin=x;
    end
    x=(xmin+xMAX)/2;
    numIts=numIts+1;
    if numIts>237 %// If it's not working, stop
        disp('Solution has not converged, there is probably no solution in [0,1]')
        break
    end
end
x
Y(x)


来源:https://stackoverflow.com/questions/29978885/solve-for-integral-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!