Symbolic math integrals not solving at all

Hi all, I am playing around with functions and the symbolic math toolbox.
I want to calculate an integral of a difficult function:
syms t t0 tau x;
syms l(t,t0,tau);
l(t,t0,tau)= exp(-1/2*exp(-(t-t0)/tau));
syms f(t,t0,tau);
f(t,t0,tau)= exp(-1/2*((t-t0)/tau));
syms p(t,t0,tau);
p(t,t0,tau)=l(t,t0,tau)*f(t,t0,tau);
It can not integrate p directly, which is not that difficult, wolfram alpha does is. But anyhow, I'll help a little and do the substitution:
p=tau*subs(p,(t-t0)/tau,x)
int(p,x,-inf,inf)
But it still just comes up with nothing. It just puts out a formated version of my input instead of calculating the integral.
The answer should be
sqrt(2*pi)*tau
Did I use the toolbox wrong or is it just not that powerfull?

3 Comments

integrate p with respect to what variable? Not tau as otherwise that could not occur in the solution. But integral with respect to t would be expected to leave t0 in the answer and integral with respect to t0 would be expected to leave t in the answer. Your posted answer suggests that you are integrating with respect to t-t0?
Thanks for your reply.
Actually it does not matter if you integrate with respect to t or t-t0, t0 just shifts the function along the t axis, but has no influence on the shape. The integral is independent of t0. In the first integral I want it to integrate by t.
However, the second integral clearly states to integrate by x, which still doesnt work.
When I take the expression over to Maple and convert the exp() into sinh cosh, then Maple is able to integrate the system. However, I do not seem to be able to do the same thing for MATLAB.

Sign in to comment.

 Accepted Answer

Your function has no obvious closed form integral. You need to switch to numeric integration, such as with integral() or vpaintegral() which will require you to have a numeric value for x. Similar question has already been answered here:
Also, the same is mentioned in the Tips Section of the int documentation:
You can go through the documentations on integral and vpaintegral to try integrate the same function:

8 Comments

It does turn out to have a closed form, tau*sqrt(pi)*sqrt(2)
Adding a few assumptions to the mix:
syms t t0 tau real
syms l(t,t0,tau);
l(t,t0,tau)= exp(-1/2*exp(-(t-t0)/tau));
syms f(t,t0,tau);
f(t,t0,tau)= exp(-1/2*((t-t0)/tau));
syms p(t,t0,tau);
p(t,t0,tau)=l(t,t0,tau)*f(t,t0,tau);
Integrate with t0 = 0
int(p(t,0,tau),t,-inf,inf)
ans = 
Ignore analytic constraints
int(p(t,0,tau),t,-inf,inf,'IgnoreAnalyticConstraints',true)
ans = 
Assume tau > 0
assume(tau,'positive');
simplify(ans)
ans = 
Which is the expected result. I don't know what analytic constraints had to be ignored.
But for some reason, int doesn't like someting about t0
int(p(t,t0,tau),t,-inf,inf,'IgnoreAnalyticConstraints',true)
ans = 
It looks like a simple u-du substitution would get the job done to get back to the prior case, unless there's some other subtle corner case with t0 that needs to be assumed away or otherwise ignored. Putting in some other value for t0 doesn't seem to a problem
int(p(t,sym(11.3),tau),t,-inf,inf,'IgnoreAnalyticConstraints',true)
ans = 
Ah, good idea to work with assumptions and ignoring constraints!
IgnoringAnalyticConstraints always makes me nervous. I'm never sure what's being ignored and what the implications may be.
int() seems to work better like this for some reason?
syms t t0 real
syms tau positive
syms l(t,t0,tau);
l(t,t0,tau)= exp(-1/2*exp(-(t-t0)/tau));
syms f(t,t0,tau);
f(t,t0,tau)= exp(-1/2*((t-t0)/tau));
syms p(t,t0,tau);
p(t,t0,tau)=l(t,t0,tau)*f(t,t0,tau);
int(simplify(expand(p)),t,-inf,inf,'IgnoreAnalyticConstraints',true)
ans(t0, tau) = 
I wonder why.
On R2022a does not work anything from above mentioned steps???!!!
syms t t0 real
syms tau positive
syms l(t,t0,tau);
l(t,t0,tau)= exp(-1/2*exp(-(t-t0)/tau));
syms f(t,t0,tau);
f(t,t0,tau)= exp(-1/2*((t-t0)/tau));
syms p(t,t0,tau);
p(t,t0,tau)=l(t,t0,tau)*f(t,t0,tau);
int(simplify(expand(p)),t,-inf,inf,'IgnoreAnalyticConstraints',true)
ans(t0, tau) =
Any idea what is wrong now???
Nope. Also doesn't work anymore in 2021B.
However, that code yields the closed form solution in 2020B.
In 2021B I had to change the expression for the integrand
int(simplify(expand(p(t,t0,tau),'IgnoreAnalyticConstraints',true),'IgnoreAnalyticConstraints',true),t,-inf,inf,'IgnoreAnalyticConstraints',true)
to get the same integrand as in in 2020B, at least by visual comparison. But even though the integrands were the same, 2021B int() still did not yield the closed form solution.
Thank you everyone here, I would also like to contribute that simplify('Steps', \*int steps\*)
intFuncky = simplify(int((sqrt(tao^2 - (t-tao)^2) * (t-tao)^2),t,0,2*tao),"Steps",100)
or
intFuncky = simplify(int(( f ,x ,a, b), "Steps" ,100);%100 chosen as a small steps count medium is 400 steps
matlab 2022b

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!