Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
I really don't understand why when using a Symbolic Calculation, the value is obtained more accurately than when checking the value normally. What should I do so that the derivative is calculated correctly?
Looks like a bug! Seems to diverge after delta = 287
I think its a bug. Use next Tip.
You should realise that the numeric and symbolic processors in Mathcad and Prime tackle mathematical problems differently, and sometimes that leads to different results.
So we have (also in Prime 4):
And this is clearly a bug, because the answer should be -1000 exactly. Assuming that the numeric derivatie would be calculated with:
Setting a reasonable value of epsilon, like TOL, gives:
That's closer, but not good. Try:
Hmm:
Now we're getting somewhere.
We can try to find the value of epsilon that Prime would use, if my assumption is correct, with:
Working that around, and using the root function gives, for various guess values of epsilon:
OK, let's try:
Apparently Prime uses a different, buggier method to numerically find the derivative.
So, in case of numerical derivatives, you should better define the derivative yourself, using the symbolics:
Or you can check the numerical derivative with:
Which gives:
for your example.
Success!
Luc
Apparently Prime uses a different, buggier method to numerically find the derivative.
Not only Prime, the problem already exists in real Mathcad. Here is a screenshot from MC15
Also interesting and confusing that for values between 2350 and 3600 the algorithm returns the correct result just to fall back to 0 for larger values of delta.
What does it look like in MC11?
Worksheet in MC11 format attached
BTW, as far as I know Mathcads numeric algorithms often followed the ones found in the "Numerical Recipes" (http://numerical.recipes/). Not sure if this would also apply to the numerical derivative. Chapter 5.7 dealing with numerical derivatives can also be found here http://pelusa.fis.cinvestav.mx/tmatos/LaSumA/LaSumA2_archivos/NumeRCPs/Texto/bookcpdf/c5-7.pdf
Interesting to read anyway.
Mathcad 11:
or, directly:
According to the manual, Mathcad 11 uses the Modified Ridder's method (Press et al., 1992; Lorczak). Then appendix L reveals that Press et al. refers to 'Numerical recipies', and Lorczak refers to 'The Mathcad Treasury'.
They must have broken something between Mathcad 11 and 15...
Ah, and your sheet:
And of course you have this variant. Note the red star!
Luc
> And of course you have this variant. Note the red star!
Ah, yes. I completely forgot about Mathcads option to optimize a definition because I seldom/never used it.
In this case its obviously equivalent to symbolically evaluate the derivative when defining the function as ttokoro and you had shown in your previous answers.
When I was little, adults told me that taking a derivative numerically is an operation that is incorrect from the point of view of mathematics. For this, children are punished - they are put in a corner.