This section describes the program ROOTR, which finds the value of x at which f(x) = y. You supply the variable name for the program that calculates f(x), the value of y, and a guess for x (in case there are multiple solutions).
Level 3 | Level 2 | Level 1 | → | Level 1 |
|
|
|
|
|
'function name' | y | xguess | → | x |
|
|
|
|
|
Techniques used in ROOTR
Programmatic use of
Programs as arguments. Although programs are commonly named and then executed by calling their names, programs can also be put on the stack and used as arguments to other programs.
ROOTR program listing |
| ||
|
|
|
|
|
| Program: | Comments: |
|
|
|
|
|
| « |
|
|
| → fname yvalue xguess | Creates local variables. |
|
| « | Begins the defining procedure. |
|
| xguess 'XTEMP' STO | Creates variable XTEMP (to be solved for). |
|
| « XTEMP fname | Enters program that evaluates f(x) - y. |
|
| yvalue - » |
|
|
| 'XTEMP' | Enters name of unknown variable. |
|
| xguess | Enters guess for XTEMP. |
|
| ROOT | Solves program for XTEMP. |
|
| » | Ends the defining procedure. |
|
| 'XTEMP' PURGE | Purges the temporary variable. |
|
| » |
|
|
|
|
|
|
| `OROOTR K | Stores the program in ROOTR. |
|
|
| |
|
|
| |
Checksum: # 4708d |
| ||
Bytes: | 163 |
|
Example: Assume you often work with the expression
3.7x3 + 4.5x2 + 3.9x + 5 and have created the program X→FX to calculate the value:
«→ x '3.7*x^3+4.5*x^2+3.9*x+5' »
You can use ROOTR to calculate the inverse function.