Path: news.mathworks.com!not-for-mail
From: "evan klinger" <eklinger1-nospam@cox.net>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solve Equation Symbolically
Date: Thu, 15 Nov 2007 21:38:56 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 99
Message-ID: <fhie9g$4ij$1@fred.mathworks.com>
References: <fha99r$osc$1@fred.mathworks.com> <fhajsd$bcg$1@fred.mathworks.com> <fhb2v2$jqi$1@canopus.cc.umanitoba.ca> <fhd1pu$j8d$1@fred.mathworks.com> <fhe9fk$l62$1@canopus.cc.umanitoba.ca> <fhf89b$srr$1@fred.mathworks.com>
Reply-To: "evan klinger" <eklinger1-nospam@cox.net>
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 1195162736 4691 172.30.248.37 (15 Nov 2007 21:38:56 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Nov 2007 21:38:56 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1181482
Xref: news.mathworks.com comp.soft-sys.matlab:437811



"evan klinger" <eklinger1-nospam@cox.net> wrote in message
<fhf89b$srr$1@fred.mathworks.com>...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> message <fhe9fk$l62$1@canopus.cc.umanitoba.ca>...
> > In article <fhd1pu$j8d$1@fred.mathworks.com>,
> > evan klinger <eklinger1-nospam@cox.net> wrote:
> > >roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> > >message <fhb2v2$jqi$1@canopus.cc.umanitoba.ca>...
> > 
> > >> What kind of ranges of values can your constants take?
> > >> I've been playing around with some test values, and it
> > >looks to
> > >> me as if you could easily encounter severe problems with
> > >loss of
> > >> precision in your calculations, especially if cr > 2.
> > 
> > >cr will always be between 0 and 1
> > >db will be in the millions
> > >p is usually between 0 and 1,000,000
> > >cv[n] is usually between 0 and a few million
> > 
> > cv12 has no real solutions if cv0 > db, which is a
possibility
> > under the constraints you have given (db "in the millions"
> > could be as low as 1 million; cv0 up to "a few million"
> > could exceed that value.)
> > 
> > I tried each combination of the lower and upper value
you gave
> > for each parameter. Taking only the extremes, there were
> > real roots for each case unless cv0 > db. The cases that had
> > only one real root, that root was >= 0. The cases that had
> > two real roots, the second root was < 0.
> > 
> > In random trials over the range of parameters, -usually-
> there was
> > one positive and one negative root, but in one of the
> cases there
> > were only two negative roots. In one of the cases, the
> positive root
> > was about +46 instead of the typical 0.08 - 0.25 range.
> That's going
> > to make it difficult to give good starting guesses for the
> ranges,
> > since your precision will usually be completely washed out
> before x = 4.
> > -- 
> > We regret to announce that sub-millibarn resolution
> bio-hyperdimensional
> > plasmatic space polyimaging has been delayed until the
release
> > of Windows Vista SP2.
> 
> This is what I'm currently using to solve it. It takes about
> 10 seconds to solve. Is there a way to optimize it?
> 
> Thanks
> 
> function [coi] = calc_coi(cv0, db, cr,
> p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,cvgoal)
> 
> syms x
> cv1 = (cv0+p1-x*(db-cv0))*(1+cr);
> simplify(cv1);
> cv2 = (cv1+p2-x*(db-cv1))*(1+cr);
> simplify(cv2);
> cv3 = (cv2+p3-x*(db-cv2))*(1+cr);
> simplify(cv3);
> cv4 = (cv3+p4-x*(db-cv3))*(1+cr);
> simplify(cv4);
> cv5 = (cv4+p5-x*(db-cv4))*(1+cr);
> simplify(cv5);
> cv6 = (cv5+p6-x*(db-cv5))*(1+cr);
> simplify(cv6);
> cv7 = (cv6+p7-x*(db-cv6))*(1+cr);
> simplify(cv7);
> cv8 = (cv7+p8-x*(db-cv7))*(1+cr);
> simplify(cv8);
> cv9 = (cv8+p9-x*(db-cv8))*(1+cr);
> simplify(cv9);
> cv10 = (cv9+p10-x*(db-cv9))*(1+cr);
> simplify(cv10);
> cv11 = (cv10+p11-x*(db-cv10))*(1+cr);
> simplify(cv11);
> cv12 = (cv11 + p12 - (x)*(db-cv11))*(1+cr);
> simplify(cv12);
> eq = cv12 - cvgoal;
> ret = solve(eq);
> 
> coi = ret(1);
> 
> If I remove the simplify() commands it takes even longer, up
> to 18 seconds.
> 


Bump