Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fit quadratic polynomial and find minimum value and its site??
Date: Thu, 15 May 2008 17:17:47 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 46
Message-ID: <g0hr7r$4u8$1@fred.mathworks.com>
References: <g0gvl6$l97$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210871867 5064 172.30.248.37 (15 May 2008 17:17:47 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 May 2008 17:17:47 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:468639


"Rajesh Acharya" <rv_acharya@yahoo.com> wrote in message <g0gvl6$l97
$1@fred.mathworks.com>...
> Hello,
> I have a set of data 
> y = (say) 199 175 163 155 (142) 153 168 179 .. total 30 
> numbers 
> x= 1 2 3 4 5 ....29 30.
> 
> i fit a second order polynomial to this using polyfit and 
> find the coeficients in descending order. 
>  
> now i want to find the 'minimum value' of 'y' and its site 
> with respect to x i.e. in this data y minimum is (142) 
> which is at x=5 but infact the polynomial may be reaching a 
> further minimum value between x=5 and 6 say 5.2145 etc... 
> how to find such a value of x at which the polynomial is 
> minimum using the above polynomial????
> or
> is there another method to find a quadratic function which 
> fits the above data and which i can solve easily to find 
> minval and minsite???
> 
>  I tried 'fnmin' which requires spline/cubic fit but i did 
> not succeed in getting minimum value 
> this is what i did: 
>    fun=spline(X,[0 Y 0]);
>    [minval minsite]= fnmin(fun, X); %interval-X
> for the actual data that i have (not the above one) i got 
> minsite = 2 which was not the site for minval. the min 
> value was at x=13 and i wanted further refinement in x... 
> 
> what could be the solution???
---------
  In any quadratic function, y = a*x^2+b*x+c, you can complete the square:

 y = a*(x+b/(2*a))^2+c-b^2/(4*a)

Hence the minimum or maximum always occurs at x = -b/(2*a), according as 
the quantity a is positive or negative, respectively, and the value there is 
obviously

 c-b^2/(4*a)

Roger Stafford