Page 1 of 1

Extremum and second derivative

Posted: Fri Sep 07, 2018 10:23 pm
by Patrick
Hello,

Since I wanted to experiment a way of producing d/dX using the complex variable method, I implement one of Thomas Klemm's post on my hp42s. Even if the structure of my program is quite messy, it gives me d/dX, the extremum and the sign of the second derivative. The main issue here is when I try to execute the same program on my DM42, it doesn't work as expected.

For instance, with a very simple equation like f(x)=2x^2-4, my hp42s gives me an extremum at (0,-4), an F(X)'' of 4 (a minimum) with an initial guess of any number. When I run the same data on the dm42 and Free42, with an initial guess of 1, I get an extremum at (0.9899,-4) and a f(x)'' of -39 196 080 396 (a maximum) witch is obviously false. The only way to get the correct minimum is to provide an initial guess of 0 or very close to 0, like 1E-6.

I know that there's a lot to do to improve my program, but it seems to be accurate on the hp42s.

What should be done to make it work on the DM42 ? I must be missing something.

Here attached is my program. Just enter the equation in EQ and execute dF.

Thanks for your help.

Re: Extremum and second derivative

Posted: Sat Sep 08, 2018 11:05 am
by dlachieze
It seems to come from the x<>y at step 30. You're recovering the Solver previous estimates and uses as the x solution. As the Free42 Solver implementation is different from the 42s implementation you get a different value. But what you need is what you stored in R00, so as a quick fix just replace step 30 by RCL 00 (and then you can simplify your program as you don't need anymore R01...).

Re: Extremum and second derivative

Posted: Sat Sep 08, 2018 12:38 pm
by Patrick
Thank you very much for your help. I modified line 30 and tried the program with f(x)=e^x-3x^2. It works perfectly with initial guess at 0 and 3. :P

Merci Didier, je n'avais pas encore réussi à mettre le doigt sur le problème.