This program helps in analyzing a function f(x) in a given area of x. The function should be defined and differentiable in the whole area. The program does the following tasks:
- Make a table of function values for sketching the curve
- Search for zero points
- Search for extrema
- Search for inflection points
- Compute the function value, the 1st and 2nd derivative at any given value for x
- Compute the length of the function curve between to given x-values
This is an improved version of an older program. The improvements are:
- For the computation of the first and the second derivative different increment values are used resulting in more precise results.
- Computation of function length is included.
- Code was shortened so that the length of the program did not increase much despite the improvements.
- Error in code was corrected
Many of these improvements are due to suggestions by Valentin Albillo whom I want to thank here.
Method:
The program approximates the derivative by adding and subtracting the small value d stored in Register I to x and evaluation the function. The derivative is estimated by (f(x+d)-f(x-d)/(2d).
The second derivative is approximated in a similar way by using additionally f(x) and a 10 times greater d to get numerical stable results.
Making the small value too big or too small delivers poor approximations. It is recommended to set it by .001. By experience the deviation then is about 1 unit in the fifth figure.
Use of registers: Registers 0-3 and I are used.
How to apply:
Preparation:
- Put in the function under LBL E. It must take the x-value from the X-register and return f(x) in X register.
- Put in a small number (recommendation: 0.001) in Register I.
Application:
1. To generate a table of function values:
- Starting point of x ENTER
- Ending point of X ENTER
- Step length x-values
- Press f A
Output:
- f(x) at starting point R/S
- f(x) at starting point + 1 * step length R/S
- f(x) at starting point + 2* step length R/S
….
Note: In the Y-register there is the x-value, in the X-register the value of f(x)
So at every step you can check the value of x by pressing x<>y
2. To find a zero point of the function: Put in two estimates in the stack and press f SOLVE E (OK, this was easy)
3. To find an extremum: Put in two estimates in stack and press f SOLVE B. Program returns x value of extremum. To get f(x) at extremum press f E. If no extremum is found program returns “Error 8”.
4. To find an inflection point (i.e. an extremum of the first derivate) put in two estimates in stack and press f SOLVE C. Program returns x value of inflection point. To get f(x) at this point press f E. If no inflection point is found program returns “Error 8”.
5. To get the first derivative at a given x: Put in x in stack, press f B.
6. To get the second derivative of a given x: Put in x in stack, press f C.
7. To get the curve length of the function between two points: Put lower x in Y-register and upper x in X register and press f integration key D.
Example:
Function f(x) = (e^(-x²)+x²-5)/(sin(x)+2) in the area from -4 to 4.
Preparation:
The program for LBL E is listed below. 0.001 STO I.
1) Generate a table from x=-4 to x=4 with step width 1:
-4 ENTER 4 ENTER 1
f A: 3.9901 (This is the value of f(x) at -4. To check x press x<>y: -4)
R/S 2.1519 (=f(-3))
R/S -0.9000
R/S -3.1351
R/S -2.0000
R/S -1.2783
R/S -0.3374
R/S 1.8682
R/S 8.8482, which equals f(4).
2) Search for zero point between x=-3 and x=-2. -3 ENTER -2 f SOLVE E Result: -2.2346 (x-value of zero point). Search for zero point between x=2 and x=3: 2 ENTER 3 f SOLVE E -> 2,2346
3) Search for minimum between x=-2 and x=0. -2 ENTER 0 f SOLVE B -> -1.0796. To get f(x) at minimum press f E -> -3.1503
4) Search for inflection points:
-4 ENTER -3 f SOLVE C -> -3,5395. For f(x) at inflection point press f E -> 3.1531
-3 ENTER -1 f SOLVE C -> -1.9825. f E -> -0.9690
-1 ENTER 0 f SOLVE C -> -0.4898 f E -> -2.5978
0 ENTER 3 f SOLVE C -> 0.6831 f E -> -1.4846
5) Estimation the length of the function curve from -4 to 4:
-4 ENTER 4 f INTEGRATION KEY D -> 21.5315
6) Get first derivative at x=2: 2 f B -> 1.3015
7) Get second derivative at x=2: 2 f C -> 1.0425
Enjoy!
Raimund
Code: Select all
f LBL A 001 – 42,21,11
STO 0 002 – 44 0
R↓ 003 – 33
STO 2 004 – 44 2
x<>y 005 – 34
STO 1 006 – 44 1
f LBL 0 007 – 42,21,0
GSB E 008 – 32 15
RCL 1 009 – 45 1
x<>y 010 – 34
R/S 011 – 31
RCL 0 012 – 45 0
STO+1 013 – 44,40,1
RCL 2 014 – 45 2
RCL 1 015 – 45 1
g x<=y 016 – 43 10
GTO 0 017 – 22 0
g RTN 018 – 43 32
f LBL B 019 – 42,21,12
GSB 1 020 – 32 1
- 021 – 30
RCL I 022 – 45 25
/ 023 – 10
2 024 – 2
/ 025 – 10
g RTN 026 – 43 32
f LBL C 027 – 42,21,13
EEX 028 – 26
1 029 – 1
STOXI 030 – 44,20,25
R↓ 031 – 33
STO 1 032 – 44 1
GSB E 033 – 32 15
CHS 034 – 16
STO 0 035 – 44 0
STO+0 036 – 44,40,0
RCL 1 037 – 45 1
GSB 1 038 – 32 1
+ 039 – 40
STO+0 040 – 44,40,0
RCL I 041 – 45 25
STO/0 042 – 44 10,0
STO/0 043 – 44,10,0
EEX 044 – 26
1 045 – 1
STO/I 046 – 44,10,25
RCL 0 047 – 45 0
g RTN 048 – 43 32
f LBL 1 049 – 42,21,1
STO 2 050 – 44 2
RCL I 051 – 45 25
- 052 – 30
GSB E 053 – 32 15
STO 3 054 – 44 3
RCL 2 055 – 45 2
RCL I 056 – 45 25
+ 057 – 40
GSB E 058 – 32 15
RCL 3 059 – 45 3
g RTN 060 – 43 32
f LBL D 061 – 42,21,14
GSB B 062 – 32 12
g x² 063 – 43 11
1 064 – 1
+ 065 – 40
SQRT 066 – 11
g RTN 067 – 43 32
f LBL E 068 – 42,21,15
ENTER 069 – 36
ENTER 070 – 36
ENTER 071 – 36
g x² 072 – 43 11
CHS 073 – 16
e^x 074 – 12
x<>y 075 – 34
g x² 076 – 43 11
+ 077 – 40
5 078 – 5
- 079 – 30
x<>y 080 – 34
SIN 081 – 23
2 082 – 2
+ 083 – 40
/ 084 – 10
g RTN 085 – 43 32