Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to plot an integral which cannot be symbolically calculated?

Subject: How to plot an integral which cannot be symbolically calculated?

From: Irene

Date: 20 Jun, 2010 03:20:06

Message: 1 of 4

Hello,

Throughout my question below, I'll have

syms a b
and
xi and ti data points with i = 1,...,100

I am trying to graph a function Q(a,b) where

Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti - u) )

and a and b are in [0,1].

After declaring u as a syms I tried the following

for i = 1:100
Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i) - u)), u, 0, ti(i))
end

but I get a message about how Matlab cannot calculate the integral explicitly.

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.

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...

Thank you so much for your help!

Subject: How to plot an integral which cannot be symbolically calculated?

From: Walter Roberson

Date: 20 Jun, 2010 04:16:15

Message: 2 of 4

Irene wrote:

> Throughout my question below, I'll have
>
> syms a b
> and xi and ti data points with i = 1,...,100
>
> I am trying to graph a function Q(a,b) where
>
> Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti -
> u) )
>
> and a and b are in [0,1].
>
> After declaring u as a syms I tried the following
>
> for i = 1:100
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i) - u)), u, 0,
> ti(i))
> end
>
> but I get a message about how Matlab cannot calculate the integral
> explicitly.

piecewise(And(0 <
(1+a*ti+b*xi*ti)/(-1+a+b*xi),(1+a*ti+b*xi*ti)/(-1+a+b*xi) <
ti),undefined,(a+b*xi)*(ln(1+a*ti+b*xi*ti)-ln(ti+1))/(-1+a+b*xi))

That is, the integral is undefined if (1+a*ti+b*xi*ti)/(-1+a+b*xi) is
(strictly) between 0 and ti, and the integral is
(a+b*xi)*(ln(1+a*ti+b*xi*ti)-ln(ti+1))/(-1+a+b*xi)
otherwise.

The undefined portion can occur if xi < 0.

Subject: How to plot an integral which cannot be symbolically calculated?

From: Steven Lord

Date: 22 Jun, 2010 19:01:33

Message: 3 of 4


"Irene " <jez_zaz_bel@yahoo.com> wrote in message
news:hvk1d5$j01$1@fred.mathworks.com...
> Hello,
>
> Throughout my question below, I'll have
>
> syms a b
> and xi and ti data points with i = 1,...,100
>
> I am trying to graph a function Q(a,b) where
>
> Q(a,b) = integral over [0, ti] of (a + b*xi) / (1 + u + (a + b*xi)*(ti -
> u) )
>
> and a and b are in [0,1].
>
> After declaring u as a syms I tried the following
>
> for i = 1:100
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i) - u)), u, 0,
> ti(i))
> end
>
> but I get a message about how Matlab cannot calculate the integral
> explicitly.
>
> 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.

Then you need to specify numeric values for a and b before or inside your
call to INT. After all, what does the plot of the function y = a*x^2 look
like? Does it open upwards or downwards? Without knowing what the sign of
a is, I can't even answer the second of those questions.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: How to plot an integral which cannot be symbolically calculated?

From: Roger Stafford

Date: 22 Jun, 2010 23:47:06

Message: 4 of 4

"Irene " <jez_zaz_bel@yahoo.com> wrote in message <hvk1d5$j01$1@fred.mathworks.com>...
> .......
> After declaring u as a syms I tried the following
>
> for i = 1:100
> Q(i) = int((a + b*xi(i)) / (1 + u + (a + b*xi(i))*(ti(i) - u)), u, 0, ti(i))
> end
>
> but I get a message about how Matlab cannot calculate the integral explicitly.
> ......

  This definite integral has an elementary solution which can be expressed as:

 Q(i) = c/(1-c)*log((1+t)/(1+c*t))

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.

  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.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us