Path: news.mathworks.com!not-for-mail From: "Nina " <ninakuklisova@uchicago.edu> Newsgroups: comp.soft-sys.matlab Subject: 3rd derivative function Date: Thu, 10 May 2012 15:28:20 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 19 Message-ID: <jogmqk$hqn$1@newscl01ah.mathworks.com> Reply-To: "Nina " <ninakuklisova@uchicago.edu> NNTP-Posting-Host: www-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1336663700 18263 172.30.248.37 (10 May 2012 15:28:20 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Thu, 10 May 2012 15:28:20 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 3392200 Xref: news.mathworks.com comp.soft-sys.matlab:767412 Hello everybody, I know this is really simple but I can't see what's wrong now. I'm trying to write a 3rd derivative approximation that uses the first derivative, of an initial function that is the exponential. I've been trying to run this code: if x >=0 then f(x) = exp((x)); end if x <0 then f(x) = 1/(exp((-x))); end f1(x) = (f(x+h)-f(x-h))/(2*h); f3(x) = (3/(h^3))*(f(x+h)-f(x-h)-2*h*f1(x)) but MATLAB refuses it saying Undefined function 'f' for input arguments of type 'double'. Please, does anyone have any idea what could be wrong? Thanks in advance!