<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113</link>
    <title>MATLAB Central Newsreader - Numerical Integration</title>
    <description>Feed for thread: Numerical Integration</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 19 Jun 2009 00:36:01 -0400</pubDate>
      <title>Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658635</link>
      <author>Saed </author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I have the following function&lt;br&gt;
&lt;br&gt;
function Psi_Out = Psi(a,b,z)&lt;br&gt;
Fun=@(t)((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)));&lt;br&gt;
Psi_Out =quad(Fun,0,5000);&lt;br&gt;
&lt;br&gt;
where a and b are constants, and z is a sumolic expression. When I run the following commands:&lt;br&gt;
&lt;br&gt;
syms s;&lt;br&gt;
Psi(2,2,s.^2+2.*s);&lt;br&gt;
&lt;br&gt;
an error occurs. Where did I mistake the function?</description>
    </item>
    <item>
      <pubDate>Fri, 19 Jun 2009 01:37:01 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658647</link>
      <author>John D'Errico</author>
      <description>&quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &amp;lt;h1emhh$mok$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have the following function&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function Psi_Out = Psi(a,b,z)&lt;br&gt;
&amp;gt; Fun=@(t)((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)));&lt;br&gt;
&amp;gt; Psi_Out =quad(Fun,0,5000);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; where a and b are constants, and z is a sumolic expression. When I run the following commands:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; syms s;&lt;br&gt;
&amp;gt; Psi(2,2,s.^2+2.*s);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; an error occurs. Where did I mistake the function?&lt;br&gt;
&lt;br&gt;
Because you are trying to use a numerical integration&lt;br&gt;
(quad) on a symbolic problem.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Fri, 19 Jun 2009 08:44:25 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658694</link>
      <author>vedenev</author>
      <description>See, example:&lt;br&gt;
&lt;br&gt;
syms a b z t&lt;br&gt;
Fun=((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)))&lt;br&gt;
Psi=int(Fun,t,0,5000)&lt;br&gt;
&lt;br&gt;
-----------------------------------------&lt;br&gt;
Maxim Vedenev, MATLAB Custom Programming&lt;br&gt;
vedenev@ngs.ru&lt;br&gt;
&lt;a href=&quot;http://simulations.narod.ru/&quot;&gt;http://simulations.narod.ru/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 19 Jun 2009 12:07:00 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658735</link>
      <author>Saed </author>
      <description>vedenev &amp;lt;vedenev.maxim@gmail.com&amp;gt; wrote in message &amp;lt;32ef8539-b42c-447d-8436-f796643fd085@o20g2000vbh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; See, example:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; syms a b z t&lt;br&gt;
&amp;gt; Fun=((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)))&lt;br&gt;
&amp;gt; Psi=int(Fun,t,0,5000)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -----------------------------------------&lt;br&gt;
&amp;gt; Maxim Vedenev, MATLAB Custom Programming&lt;br&gt;
&amp;gt; vedenev@ngs.ru&lt;br&gt;
&amp;gt; &lt;a href=&quot;http://simulations.narod.ru/&quot;&gt;http://simulations.narod.ru/&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
But as I know, using anonymous functions followed by quad command, is the quickest way to do integrations. I have a very long expression in term of s, and I tried the way you suggested, but the program takes a considerable amount of time to be executed. So, I need a suggestion in how to use the quad command, or an equivalent fast integration, please.</description>
    </item>
    <item>
      <pubDate>Fri, 19 Jun 2009 14:02:50 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658768</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &lt;br&gt;
news:h1fv14$79u$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; vedenev &amp;lt;vedenev.maxim@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;32ef8539-b42c-447d-8436-f796643fd085@o20g2000vbh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; See, example:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; syms a b z t&lt;br&gt;
&amp;gt;&amp;gt; Fun=((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)))&lt;br&gt;
&amp;gt;&amp;gt; Psi=int(Fun,t,0,5000)&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; -----------------------------------------&lt;br&gt;
&amp;gt;&amp;gt; Maxim Vedenev, MATLAB Custom Programming&lt;br&gt;
&amp;gt;&amp;gt; vedenev@ngs.ru&lt;br&gt;
&amp;gt;&amp;gt; &lt;a href=&quot;http://simulations.narod.ru/&quot;&gt;http://simulations.narod.ru/&lt;/a&gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; But as I know, using anonymous functions followed by quad command, is the &lt;br&gt;
&amp;gt; quickest way to do integrations. I have a very long expression in term of &lt;br&gt;
&amp;gt; s, and I tried the way you suggested, but the program takes a considerable &lt;br&gt;
&amp;gt; amount of time to be executed. So, I need a suggestion in how to use the &lt;br&gt;
&amp;gt; quad command, or an equivalent fast integration, please.&lt;br&gt;
&lt;br&gt;
You have three choices:&lt;br&gt;
&lt;br&gt;
1) Perform the integration symbolically using INT on an expression &lt;br&gt;
containing a symbolic variable.  This will be slower than the second choice.&lt;br&gt;
&lt;br&gt;
2) Perform the integration numerically using QUAD (or even better QUADGK) on &lt;br&gt;
an expression that does NOT contain symbolic variables.  If you use this &lt;br&gt;
approach, you'll want to integrate only over the region where your function &lt;br&gt;
is &quot;significantly different from zero&quot; (for some definition of &lt;br&gt;
&quot;significantly&quot;) to make sure that the integration routine can see the &lt;br&gt;
details of your function.  After all, if you look out an airplane window at &lt;br&gt;
30,000 feet you're not going to be able to distinguish an individual person &lt;br&gt;
on the ground -- specifying a very large integration interval where the &lt;br&gt;
function is mostly zero is similar to that.&lt;br&gt;
&lt;br&gt;
3) Look up your integral in a table of integrals, and replace the &lt;br&gt;
integration with an evaluation of the closed-form solution of that integral. &lt;br&gt;
This won't work for all integrals, but it's probably going to be the fastest &lt;br&gt;
of all the methods.&lt;br&gt;
&lt;br&gt;
For this particular integral, if you choose choice 3, you'll probably want &lt;br&gt;
to look for stuff related to the Beta distribution, as the expression you &lt;br&gt;
wrote looks somewhat similar to the Beta CDF (modulo the exponential term.)&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Fri, 19 Jun 2009 14:16:02 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#658771</link>
      <author>Saed </author>
      <description>&quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h1g5p7$nhp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:h1fv14$79u$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; vedenev &amp;lt;vedenev.maxim@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; &amp;lt;32ef8539-b42c-447d-8436-f796643fd085@o20g2000vbh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; See, example:&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; syms a b z t&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Fun=((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)))&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Psi=int(Fun,t,0,5000)&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; -----------------------------------------&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; Maxim Vedenev, MATLAB Custom Programming&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; vedenev@ngs.ru&lt;br&gt;
&amp;gt; &amp;gt;&amp;gt; &lt;a href=&quot;http://simulations.narod.ru/&quot;&gt;http://simulations.narod.ru/&lt;/a&gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; But as I know, using anonymous functions followed by quad command, is the &lt;br&gt;
&amp;gt; &amp;gt; quickest way to do integrations. I have a very long expression in term of &lt;br&gt;
&amp;gt; &amp;gt; s, and I tried the way you suggested, but the program takes a considerable &lt;br&gt;
&amp;gt; &amp;gt; amount of time to be executed. So, I need a suggestion in how to use the &lt;br&gt;
&amp;gt; &amp;gt; quad command, or an equivalent fast integration, please.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You have three choices:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 1) Perform the integration symbolically using INT on an expression &lt;br&gt;
&amp;gt; containing a symbolic variable.  This will be slower than the second choice.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 2) Perform the integration numerically using QUAD (or even better QUADGK) on &lt;br&gt;
&amp;gt; an expression that does NOT contain symbolic variables.  If you use this &lt;br&gt;
&amp;gt; approach, you'll want to integrate only over the region where your function &lt;br&gt;
&amp;gt; is &quot;significantly different from zero&quot; (for some definition of &lt;br&gt;
&amp;gt; &quot;significantly&quot;) to make sure that the integration routine can see the &lt;br&gt;
&amp;gt; details of your function.  After all, if you look out an airplane window at &lt;br&gt;
&amp;gt; 30,000 feet you're not going to be able to distinguish an individual person &lt;br&gt;
&amp;gt; on the ground -- specifying a very large integration interval where the &lt;br&gt;
&amp;gt; function is mostly zero is similar to that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 3) Look up your integral in a table of integrals, and replace the &lt;br&gt;
&amp;gt; integration with an evaluation of the closed-form solution of that integral. &lt;br&gt;
&amp;gt; This won't work for all integrals, but it's probably going to be the fastest &lt;br&gt;
&amp;gt; of all the methods.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; For this particular integral, if you choose choice 3, you'll probably want &lt;br&gt;
&amp;gt; to look for stuff related to the Beta distribution, as the expression you &lt;br&gt;
&amp;gt; wrote looks somewhat similar to the Beta CDF (modulo the exponential term.)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Steve Lord&lt;br&gt;
&amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Actually it is the Tricomi's Confluent Hypergeometric function, but I don't think it is a build-in function in MATLAB, so I have to define it by myself.</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 06:51:01 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#672715</link>
      <author>Soumendra Datta</author>
      <description>&quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &amp;lt;h1g6j2$hch$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &amp;lt;h1g5p7$nhp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; news:h1fv14$79u$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; vedenev &amp;lt;vedenev.maxim@gmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;lt;32ef8539-b42c-447d-8436-f796643fd085@o20g2000vbh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; See, example:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; syms a b z t&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; Fun=((1./gamma(a)).*exp(-z.*t).*(t.^(a-1)).*((1+t).^(b-a-1)))&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; Psi=int(Fun,t,0,5000)&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; -----------------------------------------&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; Maxim Vedenev, MATLAB Custom Programming&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; vedenev@ngs.ru&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&amp;gt; &lt;a href=&quot;http://simulations.narod.ru/&quot;&gt;http://simulations.narod.ru/&lt;/a&gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; But as I know, using anonymous functions followed by quad command, is the &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; quickest way to do integrations. I have a very long expression in term of &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; s, and I tried the way you suggested, but the program takes a considerable &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; amount of time to be executed. So, I need a suggestion in how to use the &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; quad command, or an equivalent fast integration, please.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; You have three choices:&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 1) Perform the integration symbolically using INT on an expression &lt;br&gt;
&amp;gt; &amp;gt; containing a symbolic variable.  This will be slower than the second choice.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 2) Perform the integration numerically using QUAD (or even better QUADGK) on &lt;br&gt;
&amp;gt; &amp;gt; an expression that does NOT contain symbolic variables.  If you use this &lt;br&gt;
&amp;gt; &amp;gt; approach, you'll want to integrate only over the region where your function &lt;br&gt;
&amp;gt; &amp;gt; is &quot;significantly different from zero&quot; (for some definition of &lt;br&gt;
&amp;gt; &amp;gt; &quot;significantly&quot;) to make sure that the integration routine can see the &lt;br&gt;
&amp;gt; &amp;gt; details of your function.  After all, if you look out an airplane window at &lt;br&gt;
&amp;gt; &amp;gt; 30,000 feet you're not going to be able to distinguish an individual person &lt;br&gt;
&amp;gt; &amp;gt; on the ground -- specifying a very large integration interval where the &lt;br&gt;
&amp;gt; &amp;gt; function is mostly zero is similar to that.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 3) Look up your integral in a table of integrals, and replace the &lt;br&gt;
&amp;gt; &amp;gt; integration with an evaluation of the closed-form solution of that integral. &lt;br&gt;
&amp;gt; &amp;gt; This won't work for all integrals, but it's probably going to be the fastest &lt;br&gt;
&amp;gt; &amp;gt; of all the methods.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; For this particular integral, if you choose choice 3, you'll probably want &lt;br&gt;
&amp;gt; &amp;gt; to look for stuff related to the Beta distribution, as the expression you &lt;br&gt;
&amp;gt; &amp;gt; wrote looks somewhat similar to the Beta CDF (modulo the exponential term.)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; -- &lt;br&gt;
&amp;gt; &amp;gt; Steve Lord&lt;br&gt;
&amp;gt; &amp;gt; slord@mathworks.com &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Actually it is the Tricomi's Confluent Hypergeometric function, but I don't think it is a build-in function in MATLAB, so I have to define it by myself.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Can you please specify how to define Tricomi's Confluent Hypergeometric function as it is not available in MATLAB?&lt;br&gt;
Soumendra</description>
    </item>
    <item>
      <pubDate>Thu, 13 Aug 2009 13:49:07 -0400</pubDate>
      <title>Re: Numerical Integration</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/254113#672830</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Soumendra Datta&quot; &amp;lt;soumendra_13@yahoo.co.in&amp;gt; wrote in message &lt;br&gt;
news:h60d4l$g1g$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &quot;Saed &quot; &amp;lt;dawoudsaed@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; &amp;lt;h1g6j2$hch$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &quot;Steven Lord&quot; &amp;lt;slord@mathworks.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;h1g5p7$nhp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
*snip*&lt;br&gt;
&lt;br&gt;
&amp;gt; Can you please specify how to define Tricomi's Confluent Hypergeometric &lt;br&gt;
&amp;gt; function as it is not available in MATLAB?&lt;br&gt;
&amp;gt; Soumendra&lt;br&gt;
&lt;br&gt;
As you may or may not know, you can extend the capabilities of MATLAB by &lt;br&gt;
writing your own function M-files.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f7-38012.html&quot;&gt;http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f7-38012.html&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Therefore, to add this functionality to MATLAB, you can find an equation for &lt;br&gt;
this function (Abramowitz &amp; Stegun's Handbook of Mathematical Functions may &lt;br&gt;
list it) and implement that equation in a function M-file.  Then you will be &lt;br&gt;
able to use it like any other MATLAB function.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
  </channel>
</rss>

