<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/171286</link>
    <title>MATLAB Central Newsreader - Integrating function of a function</title>
    <description>Feed for thread: Integrating function of a function</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, 20 Jun 2008 13:01:44 -0400</pubDate>
      <title>Integrating function of a function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/171286#438599</link>
      <author>Ian Taylor</author>
      <description>I have a function (let us call it shape), and one example I could use&lt;br&gt;
for this is:&lt;br&gt;
&lt;br&gt;
shape = hmin + x*x/(2*R)&lt;br&gt;
&lt;br&gt;
so there are three input arguments: x, hmin, R&lt;br&gt;
&lt;br&gt;
I want to integrate 1/(shape*shape) and 1/(shape*shape*shape).&lt;br&gt;
I'm having trouble with the syntax needed to do this with quad.&lt;br&gt;
&lt;br&gt;
I know that if I simply wanted to integrate shape, I would use&lt;br&gt;
quad(@(x)shape(x,hmin,R),a,b)&lt;br&gt;
&lt;br&gt;
Is it best to define two functions, one being 1/(shape*shape) and the&lt;br&gt;
other being 1/(shape*shape*shape), or can I call quad directly in some&lt;br&gt;
way ?&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Fri, 20 Jun 2008 14:14:44 -0400</pubDate>
      <title>Re: Integrating function of a function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/171286#438620</link>
      <author>Loren Shure</author>
      <description>In article &amp;lt;39e38ef4-9894-45c8-9b17-e264ccf03233&lt;br&gt;
@m44g2000hsc.googlegroups.com&amp;gt;, robert.ian.taylor@gmail.com says...&lt;br&gt;
&amp;gt; I have a function (let us call it shape), and one example I could use&lt;br&gt;
&amp;gt; for this is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; shape = hmin + x*x/(2*R)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so there are three input arguments: x, hmin, R&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to integrate 1/(shape*shape) and 1/(shape*shape*shape).&lt;br&gt;
&amp;gt; I'm having trouble with the syntax needed to do this with quad.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I know that if I simply wanted to integrate shape, I would use&lt;br&gt;
&amp;gt; quad(@(x)shape(x,hmin,R),a,b)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is it best to define two functions, one being 1/(shape*shape) and the&lt;br&gt;
&amp;gt; other being 1/(shape*shape*shape), or can I call quad directly in some&lt;br&gt;
&amp;gt; way ?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Why not just make an anonymous function for the integrand, either &lt;br&gt;
straight from your formula, or using the function shape?&lt;br&gt;
&lt;br&gt;
quad(@(x) 1. / (hmin + x.^2 / (2*R)).^2, a,b)  AND&lt;br&gt;
quad(@(x) 1. / (hmin + x.^2 / (2*R)).^3, a,b)&lt;br&gt;
&lt;br&gt;
OR&lt;br&gt;
&lt;br&gt;
quad(@(x) 1. / shape(x,hmin,R).^2, a,b) AND&lt;br&gt;
quad(@(x) 1. / shape(x,hmin,R).^3, a,b) &lt;br&gt;
&lt;br&gt;
I didn't try these so they might not be correct, but the idea is there.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Loren&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/loren/&quot;&gt;http://blogs.mathworks.com/loren/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sat, 21 Jun 2008 10:24:36 -0400</pubDate>
      <title>Re: Integrating function of a function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/171286#438790</link>
      <author>Ian Taylor</author>
      <description>On 20 Jun, 15:14, Loren Shure &amp;lt;lo...@mathworks.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; In article &amp;lt;39e38ef4-9894-45c8-9b17-e264ccf03233&lt;br&gt;
&amp;gt; @m44g2000hsc.googlegroups.com&amp;gt;, robert.ian.tay...@gmail.com says...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have a function (let us call it shape), and one example I could use&lt;br&gt;
&amp;gt; &amp;gt; for this is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; shape =3D hmin + x*x/(2*R)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; so there are three input arguments: x, hmin, R&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I want to integrate 1/(shape*shape) and 1/(shape*shape*shape).&lt;br&gt;
&amp;gt; &amp;gt; I'm having trouble with the syntax needed to do this with quad.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I know that if I simply wanted to integrate shape, I would use&lt;br&gt;
&amp;gt; &amp;gt; quad(@(x)shape(x,hmin,R),a,b)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Is it best to define two functions, one being 1/(shape*shape) and the&lt;br&gt;
&amp;gt; &amp;gt; other being 1/(shape*shape*shape), or can I call quad directly in some&lt;br&gt;
&amp;gt; &amp;gt; way ?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Why not just make an anonymous function for the integrand, either&lt;br&gt;
&amp;gt; straight from your formula, or using the function shape?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; quad(@(x) 1. / (hmin + x.^2 / (2*R)).^2, a,b) =A0AND&lt;br&gt;
&amp;gt; quad(@(x) 1. / (hmin + x.^2 / (2*R)).^3, a,b)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; OR&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; quad(@(x) 1. / shape(x,hmin,R).^2, a,b) AND&lt;br&gt;
&amp;gt; quad(@(x) 1. / shape(x,hmin,R).^3, a,b)&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I didn't try these so they might not be correct, but the idea is there.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; --&lt;br&gt;
&amp;gt; Loren&lt;a href=&quot;http://blogs.mathworks.com/loren/-&quot;&gt;http://blogs.mathworks.com/loren/-&lt;/a&gt; Hide quoted text -&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; - Show quoted text -&lt;br&gt;
&lt;br&gt;
Thanks for the help. I will try it out. The second suggestion looks&lt;br&gt;
more useful, because at a later date I may want to change the shape&lt;br&gt;
function.&lt;br&gt;
&lt;br&gt;
All the best&lt;br&gt;
&lt;br&gt;
Ian Taylor&lt;br&gt;
&lt;a href=&quot;http://www.iantaylor.org.uk/&quot;&gt;http://www.iantaylor.org.uk/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Sat, 21 Jun 2008 11:34:02 -0400</pubDate>
      <title>Re: Integrating function of a function</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/171286#438800</link>
      <author>John D'Errico</author>
      <description>Ian Taylor &amp;lt;robert.ian.taylor@gmail.com&amp;gt; wrote in message &amp;lt;39e38ef4-&lt;br&gt;
9894-45c8-9b17-e264ccf03233@m44g2000hsc.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; I have a function (let us call it shape), and one example I could use&lt;br&gt;
&amp;gt; for this is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; shape = hmin + x*x/(2*R)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so there are three input arguments: x, hmin, R&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to integrate 1/(shape*shape) and 1/(shape*shape*shape).&lt;br&gt;
&amp;gt; I'm having trouble with the syntax needed to do this with quad.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I know that if I simply wanted to integrate shape, I would use&lt;br&gt;
&amp;gt; quad(@(x)shape(x,hmin,R),a,b)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is it best to define two functions, one being 1/(shape*shape) and the&lt;br&gt;
&amp;gt; other being 1/(shape*shape*shape), or can I call quad directly in some&lt;br&gt;
&amp;gt; way ?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
shape = @(x,hmin,R) hmin + x.*x/(2*R);&lt;br&gt;
&lt;br&gt;
quad(@(x) 1./shape(x).^n,,a,b)&lt;br&gt;
&lt;br&gt;
Note the use of the dotted operators, .* ./ and .^&lt;br&gt;
in these calls. This allows quad to run properly.&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
  </channel>
</rss>

