Note that there are some explanatory texts on larger screens.

plurals
  1. POJava estimate a derivative at a point
    text
    copied!<p>I am currently writing a calculator application. I am trying to write a derivative estimator into it. The formula below is a simple way to do it. Normally on paper you would use the smallest h possible to get the most accurate estimate. The problem is doubles can't handle adding really small numbers to comparatively huge numbers. Such as 4+1E-200 will just result in 4.0. Even if h was just 1E-16, 4+1E16 will in fact give you the right value but doing math it it is inaccurate because anything after the 16th place is lost and rounding can't happen correctly. I have heard the general rule of thumb for doubles is 1E-8 or 1E-7. The issue with this is large numbers wont work as 2E231+1E-8 will just be 2E23, the 1E-8 will be lost because of size issues.</p> <p><code>f'(x)=(f(x+h)-f(x))/h as x approaches 0</code></p> <p>When I test f(x)=x^2 at the point 4 so f'(4), it should be exactly 8 now I understand that I will probably never get exactly 8. but I the most accurate seems to be around 1E-7 or 1E8 the funny thing is 1E-9 all the to 1E-11 give the same answer. Here is a list of h's and results for <code>f(x)=x^2 at x=4</code></p> <pre><code>1E-7 8.000000129015916 1E-8 7.999999951380232 1E-9 8.000000661922968 1E-10 8.000000661922968 1E-11 8.000000661922968 1E-12 8.000711204658728 </code></pre> <p>Here are my questions:</p> <ol> <li>What is the best way to pick h, obviously 1E-8 or 1E-7 make sense but how can I pick an h based off of x, so that it will work with any sized number even if x is 3.14E203 or 2E-231.</li> <li>How many decimals of precision should I account for.</li> <li>Do you have any idea how Texas instruments does it, the TI 83, 84, and Inspire can numerically figure out derivatives to 12 decimals or precision and almost always be right, but the maximum precision of their numbers is 12 digits anyway and those calculators are non CAS so they aren’t actually deriving anything</li> <li>Logically there is a number somewhere between 1E-7 and 1E-8 that will give me a more precise result, is there any way to find that number, or at least get close to it.</li> </ol> <p><strong>ANSWERED</strong></p> <p>Thank you very much BobG. The application is currently planned to be in 2 forms, a command line PC application . And an Android application. You will be mentioned in the special thanks to portions of the About page. If you would like it will be open source but I am not posting links to the project site until I work out some very very large bugs. At the moment I have been calling it Mathulator, but the name will likely change because there is already a copyright on it and it sounds stupid.I have no clue when the release candidate will be running, at the moment I have no clue when it will be stable. But it will be very powerful if I can implement everything I want too.Thanks again. Happy Programming.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload