Contributor
Posts: 48

# compute numerical derivative

I have a problem of computing numerical derivative using finite difference method. Obviously, I have to concern two problems, the rounding error and truncation error. The truncation error can be dealt by extrapolation. But the rounding error problem has something to do with machine accuracy and finding the proper scale of perturbation. This probably related to the fundamental of SAS, ie. how the number is stored in SAS and how SAS executes C language. I have already read numerical recipes in C. But I don't know how to apply the method to SAS. Any comment is truly appreciated. Thank you in advance.

Super User
Posts: 23,771

## Re: compute numerical derivative

Borrowing a response from

It is an Intel issue not microsoft or SAS or any other program. There is even an IEE-standard.

IEEE floating point - Wikipedia, the free encyclopedia

floating point double-precision is what Intel is using as standard at the moment. Precision is 15 digits.

SAS(R) 9.2 Companion for Windows, Second Edition

Welcome in the digital age and the caveats.

"There are 10 types of people in the world; those that understand BINARY and those that do not"..

Contributor
Posts: 48

## Re: compute numerical derivative

Thanks Reeza. Now I want to follow the book Numerical Recipe in C to reduce the round off error. In its 3rd edition page 230, it says one needs to use the trick temp=x+h

donothing(temp)

h=temp-x

to achieve the exact h. Any idea how to apply this trick in SAS?

SAS Super FREQ
Posts: 4,243

## Re: compute numerical derivative

To understand more about floating-point arithmetic, see the paper "What Every Computer Scientist Should Know About Floating-Point Arithmetic."

If you are doing numerical analysis in SAS, you should look at the SAS/IML language. The SAS/IML language supports numerical integration, differentiation, optimization, matrix computations, and other operations covered in Numerical Recipes. There is even a separate SAS/IML Support Community for questions about numerical operations.

Here are a few blog posts about numerical differentiation (also call finite differencing):

Discussion stats
• 3 replies
• 779 views
• 0 likes
• 3 in conversation