Path: news.mathworks.com!not-for-mail From: "John D'Errico" <woodchips@rochester.rr.com> Newsgroups: comp.soft-sys.matlab Subject: Re: rounding issue Date: Sat, 21 Mar 2009 10:11:00 +0000 (UTC) Organization: John D'Errico (1-3LEW5R) Lines: 41 Message-ID: <gq2efk$src$1@fred.mathworks.com> References: <gq04jp$8ee$1@fred.mathworks.com> <gq2ak0$gtp$1@fred.mathworks.com> Reply-To: "John D'Errico" <woodchips@rochester.rr.com> 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 1237630260 29548 172.30.248.37 (21 Mar 2009 10:11:00 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 21 Mar 2009 10:11:00 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 869215 Xref: news.mathworks.com comp.soft-sys.matlab:526592 "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gq2ak0$gtp$1@fred.mathworks.com>... > "G. B." <gavrilo.dot.bozovic@gmail.dot.ch> wrote in message <gq04jp$8ee$1@fred.mathworks.com>... > > Hi! > > > > I have to calculate a voltage raise in a constant phase element, using following code: > > > > %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% > > > > I0 = -0.001; % pulse current > > k = 0; > > temp=0; > > > > while(k<1000) > > Vtemp = (((-1)^k) * ((R*C)^(-k-1)) * (t^(alpha*(k+1))))/gamma(alpha*(k+1)+1); > > if abs(Vtemp) < 1e-20 > > break > > else > > k = k+1; > > temp = temp + Vtemp; > > end > > end > > > > Was the above sum approximates an integral? How alpha is chosen? I guess it is related to a timestep? Have you analyzed what kind of error induced for the alpha you are using? > > Sometime it's better to go back to the blackboard and take a new look on the original problem instead of persisting on the bad discretization. > > Bruno I'd very much agree with Bruno. One solution, IMHO the wrong one, is to immediately look for higher precision. The problem is, this just pushes the problem out a little ways. And then you need to go to higher precision yet. And high precision arithmetic is slow. It is better to look for a different approach. Many times it is something as simple as scaling the problem so that the parameter lies in the domain where the series is nicely convergent. John