(42S) Function Table
|
02-18-2019, 05:04 AM
Post: #1
|
|||
|
|||
(42S) Function Table
The program FTAB uses the function defined in FX, with variable “X” to generate a 2 column matrix of f(X). The matrix is stored in variable MATS. The program ends with MATS in edit mode, so you see all the points generated. Use the soft key [ → ] to view the entries.
Setting up FX To set up the function FX, the program needs to be in the following format: Code:
HP 42S Program FTAB HP 42S, DM 42, Free42 Code:
Example f(x) = x^2 * e^x FX: Code:
Input: X Start: 0 X Step: 0.5 # Steps: 10 Result Matrix MATS: Code:
Link: https://edspi31415.blogspot.com/2019/02/...table.html |
|||
02-21-2019, 08:41 AM
(This post was last modified: 02-21-2019 08:43 AM by ijabbott.)
Post: #2
|
|||
|
|||
RE: (42S) Function Table
Hi Eddie,
X Step should be 0.1 for the results you showed. Also, I don't think RTN is necessary when it precedes END. — Ian Abbott |
|||
02-21-2019, 11:57 AM
Post: #3
|
|||
|
|||
RE: (42S) Function Table
We can GROW the matrix:
Code: 00 { 45-Byte Prgm } (02-21-2019 08:41 AM)ijabbott Wrote: Also, I don't think RTN is necessary when it precedes END. In addition to that I don't see a reason to use MVAR. Code: 00 { 10-Byte Prgm } The value of \(x\) can be found in register 00. Example: 0 ENTER 0.1 ENTER 10 XEQ "FTAB" x: [ 10×2 Matrix ] This creates the same matrix as in Eddie's example: 0.0 0.0000 0.1 0.0111 0.2 0.0489 0.3 0.1215 0.4 0.2387 0.5 0.4122 0.6 0.6560 0.7 0.9867 0.8 1.4243 0.9 1.9923 Cheers Thomas |
|||
02-22-2019, 01:21 AM
Post: #4
|
|||
|
|||
RE: (42S) Function Table
It would be nice if there was a way to detect errors in the called FX function and store an error value in the matrix when it occurs. Flag 25 is close, but can only detect a single error. FTAB could do FS 25 before XEQ "FX" and test the flag afterwards. But if there are multiple places in FX where an error could occur, FX would need FC? 25, RET after each place where an error could occur.
— Ian Abbott |
|||
02-22-2019, 07:18 AM
Post: #5
|
|||
|
|||
RE: (42S) Function Table
(02-22-2019 01:21 AM)ijabbott Wrote: But if there are multiple places in FX where an error could occur, FX would need FC? 25, RET after each place where an error could occur. I'd rather delegate the error-handling to the function FX instead. It could return specific strings like "Error", "+Infty", "-Infty" or "÷ by 0" in case of errors. Code: 00 { 21-Byte Prgm } The program FTAB just creates the table. Example: -1 ENTER 0.25 ENTER 9 XEQ "FTAB" x: [ 9×2 Matrix ] -1.0000 -1.0000 -0.7500 -1.3333 -0.5000 -2.0000 -0.2500 -4.0000 0.0000 "÷ by 0" 0.2500 4.0000 0.5000 2.0000 0.7500 1.3333 1.0000 1.0000 Cheers Thomas |
|||
02-22-2019, 02:02 PM
(This post was last modified: 02-22-2019 02:03 PM by Eddie W. Shore.)
Post: #6
|
|||
|
|||
RE: (42S) Function Table
I used FX and MVAR "X" because I wanted to FX to be versatile, should we need to use FX to calculate integrals.
I like the idea of using error messages in FX. |
|||
02-22-2019, 08:58 PM
Post: #7
|
|||
|
|||
RE: (42S) Function Table
Here's a program for the HP-15C:
Code: 001-42,21,11 : ▸LBL A The function \(f(x)=x^2 e^x\) is implemented here: Code: 020-42,21,15 : ▸LBL E Example: 0 ENTER 0.1 ENTER 10 A A 10 2 The entries can be displayed by repeatedly running RCL A in USER mode. For a moment the corresponding index will be flashed: RCL A A 1,1 0.0000 RCL A A 1,2 0.0000 RCL A A 2,1 0.1000 RCL A A 2,2 0.0111 RCL A A 3,1 0.2000 RCL A A 3,2 0.0489 … RCL A A 9,1 0.8000 RCL A A 9,2 1.4243 RCL A A 10,1 0.9000 RCL A A 10,2 1.9923 Cheers Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)