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!
(*snip*)
> 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?
(*snip*)
It is conventional (by design) that Mathematica returns an expression
unevaluated when Mathematica does not know how to evaluate this
expression. This can happen for user-defined functions as well as
built-in functions (though in special circumstances).
For instance, having started a new Mathematica session, if we try to
evaluate f[2], Mathematica just returns f[2] since it has not the
slightest idea of what the function f can possibly do.
In[1]:= f[2]
Out[1]= f[2]
Now, we give a definition (a meaning) to the symbol f.
In[2]:= f[x_] = 2 x
Out[2]= 2 x
From now on, evaluating f will return a value.
In[3]:= f[2]
Out[3]= 4
Of course, *Integrate* is a built-in function that has already a
meaning. Still, if Mathematica does not know how to find a definite or
indefinite integral, it returns the original expression as answer.
For instance, Mathematica knows how to integrate E^(-x^2) (in terms of
error function) and E^(-x^3) (in terms of gamma function) but not
E^(-x^3 - x^2) (the expression is returned unevaluated).
In[1]:= Integrate[Exp[-x^2], x]
Out[1]= 1/2 Sqrt[\[Pi]] Erf[x]
In[2]:= Integrate[Exp[-x^3], x]
Out[2]= -((x Gamma[1/3, x^3])/(3 (x^3)^(1/3)))
In[3]:= Integrate[Exp[-x^3 - x^2], x]
Out[3]= Integrate[E^(-x^2 - x^3), x]
Regards,
Jean-Marc
Do not mix arbitrary precision numbers with symbolic built in
functions.
Use 1/2 instead of 0.5!
So,
In[43]:=
Clear["Global`*"]
In[44]:=
y = x1/(2*sigma^2*t)
Out[44]=
x1/(2*sigma^2*t)
In[45]:=
Integrate[y, {t, 1/2, 1}]
Out[45]=
(x1*Log[2])/(2*sigma^2)
In[46]:=
q = Exp[(-((x1 - t)^2/2))*sigma^2*t]
Out[46]=
E^((-(1/2))*sigma^2*t*(-t + x1)^2)
In[47]:=
Integrate[q, {t, 1/2, 1}]
Out[47]=
Integrate[E^((-(1/2))*sigma^2*t*(-t + x1)^2), {t, 1/2, 1}]
The latter integral is not a trivial one!
In another CAS,
convert("Integrate[E^((-(1/2))*sigma^2*t*(-t + x1)^2), {t, 1/2,
1}]",FromMma,evaluate);
1
/ 2 2
| sigma t (-t + x1)
| exp(- -------------------) dt
| 2
/
1/2
Again the integral is stated unevaluated.
Dimitris
there is no analytical expression for integrals of the form
Integrate[Exp[a*t^n],t]
for n>2.
Regards
Jens
Bye
Ben
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