Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: solution of a transcendental equation
Date: Thu, 17 Jan 2008 21:20:19 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 83
Message-ID: <fmogqj$aht$1@fred.mathworks.com>
References: <fmlr4q$bfd$1@fred.mathworks.com> <5287596.1200557272380.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1200604819 10813 172.30.248.38 (17 Jan 2008 21:20:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 17 Jan 2008 21:20:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:446223


Fulya <fulya_bagci@yahoo.com> wrote in message 
<5287596.1200557272380.JavaMail.jakarta@nitrogen.mathforum.org>...
> I want to solve Fsat and K (refering to b and c respectively).a is a constant 
and 1.289 for this fit.The fitting equation is a trascendental equation so I 
must solve it first by 'fzero' or 'fsolve' before fitting with 'lsqnonlin'. (1-1/c) is 
the exponent of (b+c*y*x)/(b+c*x).y decreases from 1 to 0.4 . There are 180 
experimental y values.I do least squares fitting by obtaining theoretical y 
values by fsolve for experimental x values. Fsat (b) and K(c)can be 2 and 6 
respectively (reasonable values)
> For a=1.289, b=2 and c=6 the curve starts from 1, goes flat  a little and 
bends down to y=0.4 exponentially( it is a semilogx graphic). 
> I used fsolve rather than fzero because 
> yi  = fsolve(funi,yexperimental)
> There are 180 experimental y's, if I use fzero I must enter one(or two) 
parameter as x0 (fzero(funi,x0))(it does not accept more) and since 
theoretical y's must be close to experimental y's I chose fsolve command. x 
(experimental) starts from 0.004 and ends with 1.49.
> It gives a statement as I wrote before and the fit is not smooth and it fits to 
what I write as the initial parameters for Fsat and K.
> 
> function val = OAOLmyLu(s)
> global x yexperimental ytheoretical val
> a=1.289;
> funi = @(y) mean(abs(y-a.*abs((Fsat+K.*y.*x)./(Fsat+K.*x)).^(1-1./K)));
> ytheoretical  = fsolve(funi,yexperimental)
> val = ytheoretical-yexperimental;
> 
> **
> close all, clc
> global x yexperimental ytheoretical val
> read experimental x and y from txt file.
> [solution]=lsqnonlin(@OAOLmyLu,[8.0,3.0]);
> K=solution(1)
> Fsat=solution(2)
> calculate sum(val.^2)
> semilogx(x, yexperimental)
> semilogx(x, ytheoretical)
--------
  Based on the data you have given us, Fulya, it looks as though you are 
facing an impossible task, fitting the theoretical to the experimental data.  
You stated that "x (experimental) starts from 0.004 and ends with 1.49."  You 
also stated that a > 1, that presumably b was to be positive, and that c was to 
be greater than 1.  Finally you stated that, "y decreases from 1 to 0.4 ".  

  The code below uses a = 1.289 and the "reasonable values" b = 2 and c = 6 
you suggested, and plots x versus y over the range .01 <= y <= a^c-.1 .  It 
uses the formula I mentioned earlier for finding x as a function of y, namely, t 
= (y/a)^(c/(c-1)), x = b/c*(t-1)/(y-t), and makes a plot of the curve in yellow.  
(You can easily check that x and y satisfy your original equation.)  It also 
includes the asymptotic lines y = 0 and y = a^c in red.  You will note that 
throughout this y range, x increases as y increases and the two lines y = 0 
and y = a^c are approached asymptotically as x approaches minus and plus 
infinity, respectively.  (This is because the denominator, y-t, becomes zero 
when y = 0 and when y = a^c.)  If you use smaller limits on y, y=linspace
(1.293,2.547,n), so as to restrict x approximately to the experimental range 
in question, you can see that these y values are very far away from the above-
mentioned experimental y values which range from 1 down to .4 and they are 
moving in the wrong direction.  If we use the latter experimental y-range, we 
get negative values for theoretical x, which is again far away from the 
experimental values.

  Assuming only that a > 1, b > 0, and c > 1, this formula of x as a function 
of y shows that on any theoretical curve, x will be zero when t = 1 and 
therefore when y = a.  For larger values of x the y values will be larger.  
Hence, for any such a, b, and c, the theoretical curve will always remain far 
removed from the stated experimental y values and will be sloping in the 
opposite direction.

  If all this is correct, you would have no chance of fitting a theoretical curve 
of the kind you have defined to the experimental data, regardless of what 
method you use to solve the equation.

 % Calculate the theoretical curve above y = 0 and below y = a^c.
 clear
 a =1.289; b=2; c=6;
 n = 1000;
 y = linspace(.01,a^c-.1,n).';
 t = (y/a).^(c/(c-1));
 x = b/c*(t-1)./(y-t);
 plot([x(1),x(n)],[a^c,a^c],'r-',[x(1),x(n)],[0,0],'r-',x,y,'y.')

Roger Stafford