HP Forums

Full Version: derivative of a function at a point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Here's a homework problem I'm working on and I want to make sure I'm on the right track.
Compute the derivative of the function at the specified point using the limit definition of a derivative of a function at a point. f(x)=2x^2+3x-1 x=-4

here's my work
f(x)-f(a)/x-a = f(x)-f(-4)/x+4
= 2x^2+3x-1-(2(-4)^2+3(-4)-1)/x+4
= 2x^2+3x-1-(32-12-1)/x+4
= 2x^2+3x-20
= (2x-5)(x+4)/x+4
= 2x-5
= 2(-4)-5
=-13

Interesting approach, but what would happen if you have a polynomial that was not factorable so that you can "eliminate" the denominator?

However, you have the right idea. The defintion of the derivative is:

lim h->0 (f(x + h) - f(x)) ÷ (h)

For a numerical calcuation, choose h that is sufficiently small, but not 0.

We haven't gotten to the power rule yet, which is where I think my proffessor will show me how to deal with polynomials, but aren't the nicest polynomials constant and therefore wouldn't their derivative be zero?

John --

I'm finding it difficult to read the equations in your post. Please use the "pre ... /pre" formatting described in the Forum's front page.

Eddie is right about the definition of a derivative. You should apply it directly.

You seem a bit confused in your follow-up post. The derivative of a constant value is zero.

My $15 Casio fx-115MS does numerical differentiation at suitable points. -13 is indeed the correct answer.

-- KS

Hi, Karl;

this looks better, you're right:

f(x)=2x^2+3x-1  x=-4

here's my work
f(x)-f(a)/x-a = f(x)-f(-4)/x+4
= 2x^2+3x-1-(2(-4)^2+3(-4)-1)/x+4
= 2x^2+3x-1-(32-12-1)/x+4
= 2x^2+3x-20
= (2x-5)(x+4)/x+4
= 2x-5
= 2(-4)-5
=-13

Althought the post is not ours, anyone can edit it, copy and paste parts of it, leave it unchanged and exit edit mode. And when you edit a post, original format (whe typing it in) is kept.

Cheers.

Luiz (Brazil)

Luiz,
Thanks for clearing up that mess for me. It is shown in your message as I typed it in, but it posted as that string of junk.
You responded to one of my posts earlier in the month on another homework problem I was working on, and your help was greatly appreciated. You were able to set the groundwork for the problem without giving away to much, thus letting me find my own way to the answer. I have a feeling you must be or have been a teacher. Once again thank you for your help and if I get stumped sometime soon I might post the problem in the hopes that you'll be there with a little friendly advice.
John Littlefield calc.I student

Eddie, I asked my calc professor if it was possible to get a polynomial that wouldn't factor and eliminate the denominator and he said "Never (although it can be tricky to factor bigger degree polynomials). Kind
>of spooky, eh? In the good way, I mean..." I'm sure I'll be finding out soon. John

Well, the correct answer seems to fall out somehow, but the approach is not what was intended. The thing to evaluate is

lim    [f(x+h)-f(x)]/h
h->0

which is an exercise in algebra. For numerical evaluation, a very small non-zero value of h must be selected. For greater accuracy,

lim    [f(x+ h/2) - f(x- h/2)]/h
h->0

can be calculated.

Now (at last!) a connection with HP calculators:

The RPL-based models (HP-28/48/49) will symbolically calculate derivatives of functions. If all variables have entered values, the derivative will be numerically evaluated. Example:

'X' [ENTER] [PURGE]
'2*X^2+3*X-1' [ENTER]
'X' [ENTER]
[d/dx] or [d]

(read '2*(2*X)+3' as the result)

-4 [ENTER]
'X' [ENTER][STO]
[->NUM]
(read -13.0 as the result)

The Casio fx-115MS is less capable, but simpler:

[d/dx] (2X^2+3X-1,-4) = 

(read -13 as the result)

-- KS

Hello,


I think the best way to find derivative function first, then substitue the given 'x'. Your

result is correct, but I think in the way of solute you use some woodoo or something extraterrestial thing from X-files ;)


So, the best way:


f(x)=2*x^2+3*x-1, and the point is x0=4


f(x+h)-f(x)
lim --------------- = this is the definition of derivative function; let's substitue!
h->0 h


2*(x+h)^2+3*(x+h)-1 - 2*x^2-3*x+1
lim ------------------------------------ = square
h->0 h


2*(x^2+2*x*h+h^2)+3*(x+h)-1 - 2*x^2-3*x+1
lim -------------------------------------------- = make multiplication into par.s
h->0 h


2*x^2+4*x*h+2*h^2+3*x+3*h-1 - 2*x^2-3*x+1
lim -------------------------------------------- = make collect
h->0 h


4*x*h+2*h^2+3*h
lim ------------------ = do the simplication with 'h' It's correct, because 'h' is
h->0 h NOT equal zero, just goes to zero

lim 4*x+2*h+3 = and make the limit: 2*h->0
h->0


+-----------+
| |
| 4*x+3 | Tararaaaa ;) Here is the derivative function of f(x)
| |
+-----------+


And this derivative function at x0=-4:


f'(x0) = 4*x0+3 = 4*(-4)+3 = -13 This is the correct result!

Cheers!

Csaba

Or, if you want to use it without find the derivative function, the game is same as above:

f(-4+h)-f(-4)
lim --------------- = this is the definition of derivative function at -4
h->0 h


2*(-4+h)^2+3*(-4+h)-1 - 2*(-4)^2-3*(-4)+1
lim -------------------------------------------- = square
h->0 h


2*(16-8*h+h^2)+3*(-4+h)-1 - 19
lim --------------------------------- = make multiplication into par.s
h->0 h


32-16*h+2*h^2-12+3*h-20
lim -------------------------- = make collect
h->0 h


-16*h+2*h^2+3*h
lim ------------------ = do the simplication with 'h' It's correct, because 'h' is
h->0 h NOT equal zero, just goes to zero

lim -16+2*h+3 = and make the limit: 2*h->0
h->0


+-----------+
| |
| -13 | Popopopooo ;) Here is the derivative of f(x) at x=-4 This is the correct result!
| |
+-----------+

Cheers!

Csaba

;>)

You are correct about constants, the derivative of a constant is 0.

Example
Let f = pi (3.14159...)

lim h->0 [ f(x + h) - f(x) ] ÷ h

= lim h -> 0 [ pi - pi ] ÷ h

= lim h -> 0 0 ÷ h

= lim h -> 0 0

= 0

And yeap! I'm a teacher. I deal with so many subjects, which is common in Brazil, that sometimes I feel as if I have not gone deeply enough in any of them. I read your last post after some of our brainy contributors have already answered, and I saw I had not too much to add... So I just read and learnt a bit more ;-) And be sure that anytime I feel I can help somehow, I'll try to.

I usualy say that I teach almost any subject dealing with numbers, since basic math to hardware design, programming and finacial subjects included. All of them at the university level (engineering, technology, etc.). Now I have a new challenge: A.I. <8-0

Thanks for your kind words and keep doing your best, John.

I wish you success.

Luiz (Brazil)

N.T.

Nice to see Karl's reference to the symmetric definition of the derivative as:

lim (h->0) [f(x+h) - f(x-h)]/2h

This is a form which seems to be well known to numerical analysis people, but which is often ignored by calculus textbooks.

From considerations of symmetry, it makes sense that a chord across a curve will better approximate a tangent to a particular point if the x value of that point is in the middle of the chord rather than at one extreme.

This is especially dramatic for the case of y = x^2, where the symmetric representation of the derivative gives:

(limit of): [(x+h)^2 - (x-h)^2]/2h =

[x^2 + 2xh +h^2 - x^2 + 2xh - h^2]/2h =

4xh/2h = 2x

so that for this case we immediately have the correct result for the derivative without proceeding to the limit at all, since h drops out of the expression.

Try y = x^3. The symmetric form will require the limit of 3x^2 + h^2, while the non-symmetric form needs the limit of 3x^2 + 3xh + h^2. Since the symmetric form has h only in the second power, while the non-symmetric form contains the first power as well, the symmetric form approaches the tangent slope faster than the non-symmetric form (i.e., larger values of h can be used to give the same accuracy).

So it worthwhile thinking about the derivative form that Karl has brought to our attention.

Cheers, Tom

Tom posted,

Quote:
Nice to see Karl's reference to the symmetric definition of the derivative as:

lim (h->0) [f(x+h) - f(x-h)]/2h

This is a form which seems to be well known to numerical analysis people, but which is often ignored by calculus textbooks.

From considerations of symmetry, it makes sense that a chord across a curve will better approximate a tangent to a particular point if the x value of that point is in the middle of the chord rather than at one extreme.


Thank you, Tom. Of course, it goes almost without saying that f(x) must be evaluable and differentiable at the point "x" for the result to be valid. Neither 1/x nor |x| pass both tests at x=0.

Selecting a value of "h" in the ideal range will give the most accurate results. Larger values of "h" can reduce accuracy due to coarseness; too-small values of "h" can reduce accuracy due to roundoff error in the machine used, as significant digits are dropped when "f(x+h)-f(x-h)" is evaluated. HP's introduced prior to the Saturn processor (1984) carry 10 digits; most HP's introduced thereafter carry 12 digits.

Here is a program for the 11C and 15C (and 16C, 33C, and 34C?) to evaluate [f(x+h)-f(x-h)]/(2h) for a user-defined function:

LBL A
STO 1 x
RCL 0 h
+
GSB I f(x+h)
STO 2
RCL 1
RCL 0
-
GSB I f(x-h)
RCL 2
x<->y
-
RCL 0
2
*
/ df/dx = [f(x+h)-f(x-h)]/(2h)
RTN

  1. Program your function f(x) using a label other than "A".
  2. Store the numerical identifier of that label in register I.
  3. Store the value of "h" in register 0.
  4. Put the value of "x" in stack register x.
  5. Do "GSB A" and view df/dx evaluated at "x".

For linear and quadratic functions, I expect that the correct answer will result for any value of "h" that does not cause overflow or underflow.

For other functions, note that increasingly larger "h" reduces accuracy, while increasingly smaller "h" reduces accuracy, and eventually produces a result of zero.

-- KS

Edited: 25 Feb 2005, 1:31 a.m.

... Mr. Littlefield was supposed to do it! ;-)

-- KS

When I was buy my first HP, that was an HP32SII - exactly that was the 2nd. the 1st was an HP45 :,( - I was envy the algebraic features of 28x/48xx, so I wrote an numerical derivator for ANY variable. If you interested, the program is in the Program Library in this site. This program don't use the variables A..Z, only statistical registers, and works with SOLVE and INTEGRATE. (Ideal for searching extremums of functions, or maybe calculate deflection of beams with Betty theorem...)

I was posted this forum a HP32SII program, what can to fit quadratic curve without to store data points, and without linear algebraic computations. I hope it's available yet, if you interested...

Csaba

Thanks for everybody! I'm not a teacher, but I like to teach if I can... (and I'm so exhibitionist :) )

So, who want to send me an HP15C Advanced Functions Hanbook??? (via ICQ or FTP...) :)

Csaba

Thanks, Karl, for the nice program and thoughtful comments.

Here's one that I wrote long ago for the HP-71B, using the "symmetric" form of the derivative. I just dusted it off (couldn't even remember that I had written it!), and it seems to work pretty (approximately!) well for simple applications. Certainly it gets John Littlefield's original problem right, as that involves only linear and quadratic terms.

[1 DEF FNC(X)= whatever expression]

10 DESTROY ALL @ DELAY 8 @ STD

20 INPUT "FIND DERIV AT X =";X

30 IF X#0 THEN 60

40 D=.0001

50 GOTO 70

60 D=.0001*ABS(X)

70 F=(FNC(X+D)-FNC(X-D))/(2*D)

80 DISP "DERIV =";F

90 END

Line 1 is changed as circumstances require. The rest is kept in program memory.

Cheers, Tom