Derivative on 35s


I know on HP 48gx, it fairly easy to find derivative of an equation where the slope equal 0 and determine if it the low point of curve or high point of curve. I know how to do manually, with chain rule, set to zero and solve, but is there easy way to have 35s do this?


Doesn't the SOLVE set a flag when it hits a minimum/maximum instead of a root?


I don't know. Are you saying, let it iterate until it hit zero?


Try solving for the root of, e.g. (x-2)^2+1:




will give you "NO ROOT FOUND", but a 2 in the display.

Of course, as soon as your function has a root, this method will not work.

You probably could do (limited) symbolic derivatives using RPN, using the indirect array, since differentiating in RPN is easier than in ALG:

e.g. x^2

X x^2

can be diff'd by replacing x^2 by 2 *.

Addition and subtraction just stays the same (+ and -).

Product rule is a bit more advanced: You have to replace

X Y *


X Y' * X' Y * +

and have to evaluate X', Y' by recursion.

All what's left is to find a suitable representation of the symbols as numbers in the indirect registers, but that's a triviality :-)

Cheers, Peter.

Edited: 23 Aug 2007, 5:24 p.m.


Yes, but unfortunately, you have to put the derivative formula in the solver and solve for zero. :-)


So if dy/dx = 3x^3+4.2x^2 - 15, find 9x^2+8.4x and then set to 0 or 9x^2+8.4x = 0, and just enter that in solver? That easy enough...duh :) Been long week I guess.

What if you had a complex equation that not as simple as one above though, is there easy way to differentiate it and solve? Something like:

dy/dx = (sqrt(43x^3/52x+5)*654.2^2-54/458)/sqrt(675^2+98)


If you can express the derivative as an equation on the 35s, then you can solve for a zero.


No, I think you nem understand what I asking. Let me think about how to explain this better.

Only reason that we set to zero, is to find out if it minimum point or maximum point on curve. We must find 1st derivative first. Solving for zero is very easy, and I understand, but sometime finding first derivative is not so easy. Is there way that 35s can do that? Such as if I type in 3x^3+4.2x^2 - 15 it find 9x^2+8.4x is first derivative. Or if I type in (sqrt(43x^3/52x+5)*654.2^2-54/458)/sqrt(675^2+98) it tell me what 1st derivative is. It should return a formula, not a value. I guess I asking if it can differentiate.


It cannot symbolically differentiate like you suggest. The graphing models with a CAS can, but not the 35s.


That not answer I was wish for my friend. :( Well, I have 48gx that can do it I guess, but I rather leave that calculator at home. I wonder how hard it would be to write program to differentiate? It would have to ask for variable you wish to differentiate. Hmmm, I must think about. I have feeling though it would not be easy to symbolically manipulate equation.

I wonder if our friend Valentin could do? He probably say I eat too much paprika and it going to my head and rusting brain cells.


You can always calculate the derivative numerically:

evaluate [f(x+dx) - f(x)]/dx

You may have to play with the size of dx, and there may be unstable regions, of course - just as we learned in Calc I .


Yes, but how would you do that on the 35s? I do not have my manual with me (Gene, when we going to have PDF of manual?) Honestly though, I prefer symbolic result as it show me more.


Yes, but how would you do that on the 35s? I do not have my manual with me (Gene, when we going to have PDF of manual?) Honestly though, I prefer symbolic result as it show me more.

Then the HP 35s isn't the calculator you want. The 35s is purely numeric.



You can use this in conjunction with the solver then, solving a program instead of an equation. For example, to find the minimum/maximum of 3*x^2+2*x+1.

F001 LBL F
F002 EQN 3*X^2+2*X+1
F003 RTN

D001 LBL D
D002 RCL D
D003 STO+ X
D004 XEQ F001
D005 x<>y
D006 STO- X
D007 x<>y
D008 XEQ F
D009 -
D010 RCL/ D
D011 RTN

Program F implements the function you want to find the minimum/maximum of.

Program D computes F'(x) using the approximation (F(x+dx)-F(x))/dx, where you pre-specify dx in register D.

Now use SOLVE:


This yields X=-0.3338.

You can now easily determine F(X) by just pressing:


Which yields F(X) is 0.6667.

Checking this symbolically, the derivative is 6x + 2, which is 0 for x=-1/3.

The difference in the answer is due to the approximation to the derivative. Using a smaller value in D will result in a more precise answer.



Very slick. Thanks for implementing my suggestion!


That work to show you values, but in business you need to see the curve (or understand it). This used many time to solve for profit maximization of cost minimization curve. Your example yes tell me where point is (0.3338), and it also tell me that it is cost minimization curve from value 0.6667 which positive which mean that curve is increasing after zero.

I guess that could work if you need value. Okay, I was just hoping it could show symbolically some how too.

What I don't understand though is your formula. Any you can explain steps in D program.


Hi Vincze,

in the good old days, one would take a piece of paper, write down the registers

and the variables

and fill in the values they assume after each program step. I hope you will find this instructive. Best of all, you can do it yourself immediately and don't have to wait for a reply from some forum.

Cheers, Peter.

Edited: 24 Aug 2007, 9:18 a.m.


That very good tip, thank you my friend. I have question about two steps though. What is difference between D004 and D008? Do they not do same thing? If I understand correctly, after you hit SOLVE X, it go to line D001, which run through D program and call F program on line D004 and line D008?

Edited: 24 Aug 2007, 9:47 a.m.


If you key that into an HP35s, the D008 line will become 'XEQ F001' so yes, they are identical.



The fact that F(x) > 0 where F'(x) = 0 doesn't mean that F(x) is increasing after zero.

Consider the curve, G(x) = -3*x^2-2*x+1. G'(x) = 0 at x=-1/3, G(-1/3) = 4/3. Here too G(x) > 0 where G'(x) = 0, yet G(x) decreases to either side of this point.

As far as the D program goes, here it is with comments:

D001 LBL D
D002 RCL D
D003 STO+ X // add value of D to value in X
D004 XEQ F001 // compute F(x+D)
D005 x<>y // bring D back into the x stack register
D006 STO- X // subtract from value in X to restore x
D007 x<>y // bring F(x+D) back into x stack register
D008 XEQ F // compute F(x)
D009 - // compute F(x+D) - F(x)
D010 RCL/ D // compute (F(x+D) - F(x)) / D
D011 RTN

This could probably be made shorter, but I didn't want to make it too unclear.



Thank you my friend, this very interesting. I find it fascinating how effortlessly you conceptualize what calculator need to do and how calculator work. I still struggle with that.

The fact that F(x) > 0 where F'(x) = 0 doesn't mean that F(x) is increasing after zero.
I beg to differ my friend. When you set to zero and solve if you get positive, it mean you find minimum point on curve, and if you find negative, it mean maximum point on curve. At least that how we learn in Hungary, but result is still the same

In your examples if you plot out you will see. In first example, we get positive result when we solve for x when set to zero and the plot show curve going up after point where x=0. In second example, when we set to zero and solve for x, we get negative number. When we plot, you see that curve going down after point where x=0.

Regardless of this minor error in analyzing result, your program is very good and I kindly thank you!

Edited: 24 Aug 2007, 10:04 a.m.


As a good exercise: modify the program above to compute (F(x+d)-F(x-d))/2d

Numerical Recipes says it has better accuracy than (F(x+d)-F(x))/d

Edited: 24 Aug 2007, 10:06 a.m.


Tried that, and you're right, it works better. Intuitively this makes sense, because you're estimating the derivative based on two points on either side of x, instead of x and a point further along.

I had to add a fair bit of extra code to D to make it work though. Unfortunately, the routine one passes to SOLVE isn't allowed to mess up the value of the register one is solving for, hence there's code that has to put it back the way it was. The revised D program is:

XEQ F // compute F(x+D)
ENTER // compute 2D
XEQ F // compute F(x-D)
x<>y // setup to divide by 2D
RCL D // restore X to original x value
x<>y // leave (F(x+D)-F(x-D))/2D on stack


Edited: 24 Aug 2007, 11:00 a.m.


Sorry, but you are mistaken. The following output is from the text version of Maple:

> g := -3*x^2-2*x+1;
g := -3 x - 2 x + 1

> g1 := diff(g,x);
g1 := -6 x - 2

> solve(g1=0,x);

> subs(x=-1/3,g);

> plot(g,x=-1..0.4);

AA AA +1.2
AA A +
A A+
AA *
A +1
A + AA
AA +0.8
AA + A
A + A
AA +0.6 A
A + A
AA + A
A +0.4 A
A + A
A + AA
A +0.2 A
A + A
A + A
+ AA
-1 -0.8 -0.6 -0.4 -0.2 + 0.2 0.4
+ A
+-0.2 A
+ A

The sign of G(x) for the value of x at which G'(x) = 0 has nothing to do with whether x is the location of a minimum or a maximum.



If I lean back and squint, it looks like the display on my hp 50g.



The sign of G(x) for the value of x at which G'(x) = 0 has nothing to do with whether x is the location of a minimum or a maximum

That's right. You have to either look at the curve, or, mathematically equivalently, take the second derivative and look at its sign.

Possibly Related Threads...
Thread Author Replies Views Last Post
  HP PRIME: derivative at a point Alasdair McAndrew 2 586 11-19-2013, 06:52 AM
Last Post: parisse
  WP34S derivative and solver reset Alessandro Castellani (Italy) 6 958 03-29-2012, 02:15 PM
Last Post: Dominic Richens
  Polynomial Derivative and Integral for the HP 35S Eddie W. Shore 0 351 05-24-2011, 10:29 PM
Last Post: Eddie W. Shore
  Producing symbolic derivative on 48G Roger King 4 642 07-02-2008, 06:39 PM
Last Post: Roger King
  HP 50g finding the nth derivative Jonathan Vogel 3 552 03-10-2008, 12:46 PM
Last Post: Mark W Paris
  derivative of a function at a point john littlefield 19 1,661 02-25-2005, 07:02 AM
Last Post: Tizedes Csaba [Hungary]
  Missing 'program E' in 'Partial Derivative...' Tizedes Csaba 0 328 11-27-2003, 03:48 AM
Last Post: Tizedes Csaba

Forum Jump: