MATLAB Answers

Symbolic math integrals not solving at all

3 views (last 30 days)
Florian Rössing
Florian Rössing on 30 Apr 2021
Commented: Paul on 30 Jul 2021
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
Walter Roberson
Walter Roberson on 29 Jul 2021
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

Tanmay Das
Tanmay Das on 29 Jul 2021
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:
  5 Comments
Paul
Paul on 30 Jul 2021
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!