Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Integration with non-numeric parameters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79793] Re: Integration with non-numeric parameters
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sat, 4 Aug 2007 06:01:04 -0400 (EDT)
  • References: <f8v1cb$ded$1@smc.vnet.net>

ingramfinance at gmail.com schrieb:
> When I use Mathematica to solve the following
> y=x1/(2*sigma^2*t)
> 
> Integrate[y, {t, .5, 1}]
> 
> I get the following answer:
> 
> (0.34657*x1/sigma^2)
> 
> OK, so far, so good. It appears that I can generate an answer with a
> non-numeric parameter. Note that I am looking for an answer in terms
> of x1.
> 
> But when I try
> 
>  q=Exp[-(x1-t)^2/2*sigma^2*t]
> 
> Integrate[q, {t, .5,1}]
> 
> Now Mathematica does not solve this integral, it just repeats the
> command
> 
> 
> 
> I am trying to get an expression in terms of x1. Why do I get a
> statement like this instead of an answer?  There is something about
> the functional form of the integrand that is causing the problem, I
> just don't know what it is.
> 
> 
> Any help you can give me is much appreciated!
> 
> 
Hi,

I did not get a value for your integral, but I want to give an advice:

If you use the exact function Integrate[], do not use inexact numbers as
boundaries! Or use NIntegrate.

I want to demonstrate this with a function, which is in an optical way
similar to yours (I moved one factor t out of the exponential function):

In[1]:=
q = t*Exp[(-(x1 - t)^2/2)*sigma^2];

In[2]:=
Timing[FullSimplify[Integrate[q, {t, 1/2, 1}, Assumptions -> sigma >= 0]]]

Out[2]=
{11.024688*Second, ((2*(E^((3*sigma^2)/8) - E^((sigma^2*x1)/2)))/
     E^((1/2)*sigma^2*(1 + (-1 + x1)*x1)) - Sqrt[2*Pi]*sigma*x1*
     (Erf[(sigma*(1 - 2*x1))/(2*Sqrt[2])] + Erf[(sigma*(-1 +
x1))/Sqrt[2]]))/(2*sigma^2)}

Now let's try the same with .5 instead of 1/2 and constrained to 10
times the time, Integrate has used for exact numbers:

In[3]:=
TimeConstrained[
Integrate[q,{t,.5,1},Assumptions\[Rule]sigma\[GreaterEqual]0]//FullSimplify//
    Timing,10*%[[1]]/Second,$Failed]

Out[3]=
$Failed

Back to _your_ q:

But you are using inexat numbers, therefore I will assume, you're
interested in floats (Reals) as result.

Use NIntegrate[]. NIntegrate needs all constants in its integrand to be
specific numeric values. So the definition

theIntegral[x1_?NumericQ, sigma_?NumericQ] :=
  NIntegrate[Exp[-t*(x1 - t)^2/2*sigma^2], {t, 1/2, 1}]

gives you a function which can be used for other functions (like
FindMaximum, NIntegrate, NLimit[], Plot3D[], etc.)

e.g.: Plot3D[theIntegral[x, s], {x, 0, 2}, {s, 0, 1}, PlotRange -> All]

Peter


  • Prev by Date: RE: How do you set up third party (or your own) packages?
  • Next by Date: rebuild the help index
  • Previous by thread: Re: Integration with non-numeric parameters
  • Next by thread: Possible mistake in ListPointPlot3D?