From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Calculating the limit of an integral
Date: Fri, 30 Mar 2012 21:02:11 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <jl570j$qfs$>
References: <jl2mtk$a37$> <jl3017$adm$> <jl4dqc$f8c$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1333141331 27132 (30 Mar 2012 21:02:11 GMT)
NNTP-Posting-Date: Fri, 30 Mar 2012 21:02:11 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:762728

"Haojie" wrote in message <jl4dqc$f8c$>...
> But then I dont know how to use fzero to calculate t, because Q1 - Q2=0 is not a function so cannot be used in fzero. I dont know if you mean this or please correct me if I understand wrong
- - - - - - - - - -
  Do something like this.  First write a function:

function q = Haojiefun(t)
 q = quad(@(x) sqrt(t^(2/7)-x.^(2/7)),0,t) ...
    -quad(@(x) sqrt(x.^(2/7)-t^(2/7)),t,1);

This constitutes a perfectly respectable function of t.  For each possible value of t between 0 and 1 there is a corresponding value of q.  (You may want to use other quadrature functions, quadl or quadgk.  Also you may want to specify error tolerances in them.)

  Then use this function as a handle into 'fzero'.

 T = fzero(@Haojiefun,[0,1]);

It should return with the desired T root.  It is a good practice to first use your (Haojiefun) function (in a for-loop) to make a plot of q versus t to see if there are multiple roots (or any at all) between 0 and 1.

  (Note: Earlier I asserted that your function (Haojiefun) would have to be able to accept vector inputs, but that is not true.  The variable t sent to it by 'fzero' will just be a scalar.  However, the functions called on by 'quad' do need to accept vectors, and hence the "x.^(2/7)" notation.)

Roger Stafford