http://www.mathworks.com/matlabcentral/newsreader/view_thread/285000
MATLAB Central Newsreader  How to plot an integral which cannot be symbolically calculated?
Feed for thread: How to plot an integral which cannot be symbolically calculated?
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Sun, 20 Jun 2010 03:20:06 +0000
How to plot an integral which cannot be symbolically calculated?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/285000#755976
Irene
Hello,<br>
<br>
Throughout my question below, I'll have<br>
<br>
syms a b<br>
and <br>
xi and ti data points with i = 1,...,100<br>
<br>
I am trying to graph a function Q(a,b) where<br>
<br>
Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti  u) )<br>
<br>
and a and b are in [0,1].<br>
<br>
After declaring u as a syms I tried the following<br>
<br>
for i = 1:100<br>
Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i)  u)), u, 0, ti(i))<br>
end<br>
<br>
but I get a message about how Matlab cannot calculate the integral explicitly.<br>
<br>
What I am after, though, is not an expression for the integral, but for the plot of the integral with respect to a and b.<br>
<br>
I was also thinking to just graph the integrand but I would have to graph it with respect to u... after which I am stuck, since I do not know how to make it into a graph of a and b...<br>
<br>
Thank you so much for your help!

Sun, 20 Jun 2010 04:16:15 +0000
Re: How to plot an integral which cannot be symbolically calculated?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/285000#755978
Walter Roberson
Irene wrote:<br>
<br>
> Throughout my question below, I'll have<br>
> <br>
> syms a b<br>
> and xi and ti data points with i = 1,...,100<br>
> <br>
> I am trying to graph a function Q(a,b) where<br>
> <br>
> Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti  <br>
> u) )<br>
> <br>
> and a and b are in [0,1].<br>
> <br>
> After declaring u as a syms I tried the following<br>
> <br>
> for i = 1:100<br>
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i)  u)), u, 0, <br>
> ti(i))<br>
> end<br>
> <br>
> but I get a message about how Matlab cannot calculate the integral <br>
> explicitly.<br>
<br>
piecewise(And(0 < <br>
(1+a*ti+b*xi*ti)/(1+a+b*xi),(1+a*ti+b*xi*ti)/(1+a+b*xi) <<br>
ti),undefined,(a+b*xi)*(ln(1+a*ti+b*xi*ti)ln(ti+1))/(1+a+b*xi))<br>
<br>
That is, the integral is undefined if (1+a*ti+b*xi*ti)/(1+a+b*xi) is <br>
(strictly) between 0 and ti, and the integral is<br>
(a+b*xi)*(ln(1+a*ti+b*xi*ti)ln(ti+1))/(1+a+b*xi)<br>
otherwise.<br>
<br>
The undefined portion can occur if xi < 0.

Tue, 22 Jun 2010 19:01:33 +0000
Re: How to plot an integral which cannot be symbolically calculated?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/285000#756632
Steven Lord
<br>
"Irene " <jez_zaz_bel@yahoo.com> wrote in message <br>
news:hvk1d5$j01$1@fred.mathworks.com...<br>
> Hello,<br>
><br>
> Throughout my question below, I'll have<br>
><br>
> syms a b<br>
> and xi and ti data points with i = 1,...,100<br>
><br>
> I am trying to graph a function Q(a,b) where<br>
><br>
> Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti  <br>
> u) )<br>
><br>
> and a and b are in [0,1].<br>
><br>
> After declaring u as a syms I tried the following<br>
><br>
> for i = 1:100<br>
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i)  u)), u, 0, <br>
> ti(i))<br>
> end<br>
><br>
> but I get a message about how Matlab cannot calculate the integral <br>
> explicitly.<br>
><br>
> What I am after, though, is not an expression for the integral, but for <br>
> the plot of the integral with respect to a and b.<br>
<br>
Then you need to specify numeric values for a and b before or inside your <br>
call to INT. After all, what does the plot of the function y = a*x^2 look <br>
like? Does it open upwards or downwards? Without knowing what the sign of <br>
a is, I can't even answer the second of those questions.<br>
<br>
 <br>
Steve Lord<br>
slord@mathworks.com<br>
comp.softsys.matlab (CSSM) FAQ: <a href="http://matlabwiki.mathworks.com/MATLAB_FAQ">http://matlabwiki.mathworks.com/MATLAB_FAQ</a><br>
To contact Technical Support use the Contact Us link on <br>
<a href="http://www.mathworks.com">http://www.mathworks.com</a>

Tue, 22 Jun 2010 23:47:06 +0000
Re: How to plot an integral which cannot be symbolically calculated?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/285000#756717
Roger Stafford
"Irene " <jez_zaz_bel@yahoo.com> wrote in message <hvk1d5$j01$1@fred.mathworks.com>...<br>
> .......<br>
> After declaring u as a syms I tried the following<br>
> <br>
> for i = 1:100<br>
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i)  u)), u, 0, ti(i))<br>
> end<br>
> <br>
> but I get a message about how Matlab cannot calculate the integral explicitly.<br>
> ......<br>
<br>
This definite integral has an elementary solution which can be expressed as:<br>
<br>
Q(i) = c/(1c)*log((1+t)/(1+c*t))<br>
<br>
where c = a+b*xi(i) and t = ti(i). However, the ratio (1+t)/(1+c*t) must be positive for this to be valid. Both 1+t and 1+c*t can be positive or both can be negative but they can't be of opposite sign. Otherwise the logarithm will have an imaginary component. You should be able to plot this very easily.<br>
<br>
I am not sure why your 'int' failed to find it unless it was because of the necessity that the above ratio always be positive. My own reckless 'int' has no such inhibition and coughs up this answer boldly without issuing any such warning.<br>
<br>
Roger Stafford