Re: help with the code



Hi Steven,
To help you better understand the variables, i have uploaded an image with the relevant function details.
the variables d,phi all find mention there.

http://www.freeimagehosting.net/uploads/af5550f546.gif


Since i use "dblquad" to perform the double integration, d and phi have to be made vectors since in the dblquad routine, x is a vector and d and phi are calculated variables for different values of x.
The whole intent is towards numerically integrating the function.
z=z_num/z_den is actually the function to be integrated.

I understand the spike thing you are talking about and somehow want to get beyod it. SInce, my functon is f>=0 (as you will see from the uploaded pic equation), and i want to minimize the integral of function, i am not concerned with positive singularities and would like to avoid integrating in such cases and change the parameters.

Please provide some inputs in this case.

thanks and regards...



"Steven Lord" <slord@xxxxxxxxxxxxx> wrote in message <grku0k$q4$1@xxxxxxxxxxxxxxxxxx>...

"Amitalok Budkuley" <amitalok86@xxxxxxxxx> wrote in message
news:grk95l$t9f$1@xxxxxxxxxxxxxxxxxxxxx
Hi,

I am having some issues with the numerical integration of a function with
parameter.
I overall aim is to minimize the same with respect to the parameter in
question. I have chosen the numerical integration approach since i am
unable to derive an analytic expression fr the integral of the function
with parameter.

The function code is as follows...

*snip to show just a few lines in the integrand function*

phi(:,j)=((y-Pset(i+1))./(x-Pset(i)));

*snip more*

z_num=z_num+d(:,k).^(-1);

*and again snip*

z_den=z_den+(d(:,i).^(-1)).*(d(:,j).^(-1));%.*sin(phi(:,i)-phi(:,j)).^2;

*once more*

z=z_num./z_den;
end
r=val;
end
******************

Now, when i try to integrate this function with a set of parameters, i get
the error
"Warning: Maximum function count exceeded; singularity likely."
But my aim is to run the optimizaton routine. So, need to dwell only with
minima not maxima. Hence, should not have problems with singularities.
THE NATURE OF MY FUNCTION IS SUCH THAT IT IS ALWAYS f>=0.

What happens if the integration routine tries to evaluate the first line I
left unsnipped at x = Pset(i)? What value will phi(:, j) have?

What if it turns out that for some reason one of the d(:, k)'s contains a
zero? What happens on the second or third line I left unsnipped?

Finally, can z_den ever be zero when it reaches the last line I left
unsnipped?

The message you received means that during the integration process, for
whatever reason, the integration function was forced to subdivide your
interval so many times that the width of the subinterval was VERY small,
which is often a sign that there's a singularity in your function at that
point. The three questions I asked above are intended to make you think
about your function to determine if (despite your assertion that your
function is always nonnegative) your function has some region where there's
a singularity (or a region that looks a lot like a singularity.) For
example, this function:

f = @(x) 1./((x-1).^2+eps)

is always positive and finite for all real x [both numerator and denominator
are strictly positive] ... but if you try to use QUAD to integrate it on an
interval that includes x = 1, the "spike" at x = 1 looks an awful lot like a
singularity, and you'll receive the same "singularity likely" message.

--
Steve Lord
slord@xxxxxxxxxxxxx

.



Relevant Pages

  • Re: Integrable singularity
    ... > I wish to numerically integrate a real function with an integrable ... > singularity. ... > What are the recommended methods for accomplishing the above? ... You need to consult my column, "Gauss-Legendre Principal Value Integration" ...
    (comp.lang.fortran)
  • Re: help with the code
    ... I overall aim is to minimize the same with respect to the parameter in question. ... I have chosen the numerical integration approach since i am unable to derive an analytic expression fr the integral of the function with parameter. ... Singularity here might also be the Software's Singularity, ...
    (comp.soft-sys.matlab)
  • Re: help with the code
    ... I have chosen the numerical integration approach since i am ... But my aim is to run the optimizaton routine. ... which is often a sign that there's a singularity in your function at that ...
    (comp.soft-sys.matlab)
  • incurable definite integration behavior [Re: Bug in Mathematica 6 - Integrate - 1]
    ... antiderivative jumps a branch cut on the integration path and the ... such branch cut jumps. ... Offhand I've no idea whether this path singularity has a "nice" closed ... We will briefly outline methods used by Mathematica. ...
    (sci.math.symbolic)
  • Re: Integrable singularity
    ... >> I wish to numerically integrate a real function with an integrable ... >> What are the recommended methods for accomplishing the above? ... > integration region. ... > remove the singularity. ...
    (sci.math.num-analysis)

Loading