Path: news.mathworks.com!not-for-mail
From: "Jonathan " <jauni6@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Nonlinear functions need to find the accuracy
Date: Thu, 8 Apr 2010 19:17:25 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 18
Message-ID: <hpla45$q5q$1@fred.mathworks.com>
Reply-To: "Jonathan " <jauni6@hotmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1270754245 26810 172.30.248.38 (8 Apr 2010 19:17:25 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 8 Apr 2010 19:17:25 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2305141
Xref: news.mathworks.com comp.soft-sys.matlab:624788

I'm trying to evaluate a nonlinear function to an accuraccy of 10^-8.  I have a function S1=1/(k^3-x)^1/2 and I want to determine how many terms are needed to achieve the desired accuracy.  To solve this requires an integration and an expansion using taylor series.  My code is as follows:

clc
syms k x   
f=k^(-3/2)/sqrt(1+x/k^3);
y=taylor(f);
z=int(y)
a=subs(z,x,1) % subtitute x=1 into z
a=1;
while a<10^-8;
	k=1;
	k=k+1;
	a=z+a;
disp(k)
disp(a)
end

How can I determine how many terms are required to get the desired accuracy?  Thanks.