Post Reply 
(15C) (DM 15L) Analyzing a function f(x)
06-05-2020, 05:04 PM (This post was last modified: 06-05-2020 08:12 PM by rawi.)
Post: #1
(15C) (DM 15L) Analyzing a function f(x)
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 we want to analyze.
It does the following tasks:
- Make a table of function values for sketching the curve
- Searching for zero points
- Searching for extrema
- Searching for inflection points (extrema of the first derivative)
- Computing the function value, the 1st and 2nd derivative at any given value for x
Method:
The program approximates the derivate 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).
Making the small value too big or too small delivers poor approximations. In this example 0.01 delivers good results with four significant digits after decimal point.
Use of registers: Register 0-3 and I are used.

How to apply:

Preparation:
- Put in the function under LBL E. It has to take the x-value from the X-register and return f(x) in X register.
- Put in a small number (e.g. 0.01) in Register I. This is used for the numerical computation of the first and second derivates.

Application:
1. To generate a table of function values:
- Starting point of x ENTER
- End 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: The Y-register has X, the X-register 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.
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 derivatie 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.

Example:
Let’s look at the 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. We put 0.01 in STO I.

1) We want to 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. From the table we know that there has to be a zero point between x=-3 and x=-2. Let’s search the zero-point: Put in stack: -3 ENTER -2 f SOLVE E. Result: -2.2346 (x-value of zero point).
There is another zero-point between x=2 and x=3: 2 ENTER 3 f SOLVE E Result: 2,2346

3. From the table we know that there is a minimum between x=-2 and x=0. Let’s search for the extremum:
-2 ENTER 0 f SOLVE B Result: -1.0795. To get f(x) at minimum press f E -> -3.1503

4. There can be an inflection points between -4 and -3, -3 and -2, -1 and 0 and 1 and 3. Let’s check that:
-4 ENTER -3 f SOLVE C -> -3,5395. For f(x) at inflection point press f E -> 3.1531
-3 ENTER -2 f SOLVE C -> -1.9835. f E -> -0.9680
-1 Enter 0 f SOLVE C -> -0.4898 f E -> -2.5978
0 ENTER 3 f SOLVE C -> 0.6831 f E -> -1.4846

Enjoy!
Raimund


01: f LBL A
02: STO 0
03: R↓
04: STO 2
05: x<>y
06: STO 1
07: f LBL 0
08: GSB E
09: RCL 1
10: x<>y
11: R/S
12: RCL 2
13: RCL 1
14: RCL 0
15: +
16: STO 1
17: x<=y?
18: GTO 0
19: g RTN
20: f LBL B
21: GSB 1
22: -
23: RCL I
24: 2
25: X
26: ./.
27: g RTN
28: f LBL C
29: STO 1
30: GSB E
31: STO 0
32: RCL 1
33: GSB 1
34: RCL 0
35: -
36: RCL I
37: ./.
38: x<>y
39: RCL 0
40: x<>y
41: -
42: RCL I
43: ./.
44: -
45: RCL I
46: ./.
47: g RTN
48: f LBL 1
49: STO 2
50: RCL I
51: +
52: GSB E
53: STO 3
54: RCL 2
55: RCL I
56: -
57: GSB E
58: RCL 3
59: x<>y
60: g RTN
61: f LBL E
62: ENTER
63: ENTER
64: ENTER
65: g x²
66: CHS
67: e^x
68: x<>y
69: g x²
70: +
71: 5
72: -
73: x<>y
74: SIN
75: 2
76: +
77: ./.
78: g RTN
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(15C) (DM 15L) Analyzing a function f(x) - rawi - 06-05-2020 05:04 PM



User(s) browsing this thread: 1 Guest(s)