Why am i getting an Inf value when i am calculating definite integral in symbolic math toolbox?

Preeti Prajapati (view profile)

on 1 Oct 2014
Latest activity Commented on by Preeti Prajapati

Preeti Prajapati (view profile)

on 2 Oct 2014

I am calculating definite integral of a polynomial using syms command, using the following code: Lb=[-4 -4 -4 -4]; Ub=[4 4 4 4];d=4; n=4; for i=1:n; nx(i,:)=Lb+(Ub-Lb).*rand(1,d); end; syms s t; H= (s^3+7*s^2+24*s+24)/(s^5+10*s^4+35*s^3+50*s^2+24*s); h=(nx(1,1)*s+nx(1,2))/(s^3+nx(1,3)*s^2+nx(1,4)*s); Y=ilaplace(H,s,t); y=ilaplace(h,s,t); Ise=int((Y-y)^2,t,0,inf); ISE=double(Ise)
The problem is when i pick values from matrix nx and put them into h, then for every value of the nx matrix i get ISE=Inf, but when i manually put h, then it calculates ISE. For example, for the following code ISE is being calculated: syms s t; H= (s^3+7*s^2+24*s+24)/(s^5+10*s^4+35*s^3+50*s^2+24*s); h=(16*s+24)/(30*s^3+42*s^2+24*s); Y=ilaplace(H,s,t); y=ilaplace(h,s,t); Ise=int((Y-y)^2,t,0,inf); ISE=double(Ise) Can anyone please let me know where am i wrong and why am i getting Inf value for ISE when i take the coefficients of s in h from nx. Please help me as soon as possible. Thank you in advance.

Products

on 2 Oct 2014

I do not think the issue lies in picking the coefficients in "h" from the matrix "nx". I think that the function you are trying to integrate does indeed integrate to "Inf" for these values of the coefficients (I did not actually integrate by hand). You can validate this by manually entering the entries in "nx" as the coefficients in "h". You will notice that this will also return "Inf".
Also, the fact that "int" returns a finite value when you manually input the coefficients is solely due to the actual values of the coefficients you are using, and not because you are manually entering them. Again, you can validate this by creating a matrix "nx" using these coefficients that you provided in the second snippet of code, i.e., 16, 24, 42, 24, and then indexing them as your coefficients. You will notice that it evaluates to a finite value.
So, the issue may lie in the actual values of the coefficients (in "h") for your particular function. Perhaps if the upper limit for integration was finite, you would get a finite answer.

Preeti Prajapati

Preeti Prajapati (view profile)

on 2 Oct 2014
Thank you very much Sir, I think i found where the problem lies. I changed the upper limit to a finite number and i am getting a finite answer now.

Alberto (view profile)

on 1 Oct 2014

Your problem is that you are trying to integrate a function say F(y)=(Y-y)^2, but using t as integration variable. That means that F is constant while t variates form 0 to Inf. Matematically that value is infinite.

Preeti Prajapati

Preeti Prajapati (view profile)

on 2 Oct 2014
Thank you Sir, but what is the solution for this, as i have to put different values into this function every time.
Alberto

Alberto (view profile)

on 2 Oct 2014
I guess you should change:
Ise=int((Y-y)^2,t,0,inf)
for this one:
Ise=int((Y-y)^2,Y,0,inf)
that will be infinite too (its a math fact, the parabola has infinite area below). If you need a finite value, then you should also change the upper integration value for a finite one. For example:
Ise=int((Y-y)^2,Y,0,10)