Program code with solve function
|
06-26-2024, 04:10 AM
(This post was last modified: 07-19-2024 01:21 AM by Gene222.)
Post: #5
|
|||
|
|||
RE: Program code with solve function
A. CAS program, where the x variable does not exist
The following CAS program is for the equation y = 3x^2 - 2x - 4. This program uses two function argument variables (px and py), one local variable created inside the procedural function (lAns), and one cas variable (x), where the cas variable x is not declared or defined within the program. The cas variable x is said to "not exist", meaning the cas variable x is not shown in the Vars key, CAS tab, under the "all" sub-menu. As is, this program can only be run on the CAS screen. Running this program on the Home screen will give a syntax error, because the cas variable x was not declared. Code: #cas To find x, given y = 1.5, on the CAS screen, enter f1_xy(x, 1.5) or f1_xy('x', 1.5), which returns {-1.0611, 1.7278}. To find the roots where y=0, on the CAS screen, enter f1_xy(x, 0) or f1_xy('x', 0), which returns {-0.86852, 1.5352}. To find y, given x = -1.0611, on the CAS screen, enter f1_xy(-1.0611, x) or f1_xy(-1.0611, 'x'), which returns {1.5}. When running the program on the CAS screen, use the default CAS settings for page 2. The CAS program can be accessed using the Vars key and CAS tab. However, the program is written and editted using the Shift Program key. On the G1 calculator, when creating a new program, the CAS checkbox does not appear to do anything. 'x' is the un-evaluated variable x. See help for QUOTE. x in the solve equation is a CAS variable. In the solve function, the solve variable cannot be a local variable created within the procedural function. So, we cannot create the solve x variable using the local statement shown above. In a CAS program, to my knowledge, CAS does not allow a local statement outside the procedural function, nor an export statement in the program. This is why the cas variable x is not declared within this cas program. B. Same CAS program, but manual create cas variable x To run this program on the Home screen, you must manually create the CAS variable by typing x:=0 on the CAS screen and pressing the Enter key. CAS variable x can now be seen by the Vars key, CAS tab, and all sub-menu, and the program can now be run on the Home screen, with one exception. One cannot use x as a function argument. Only 'x' can be used. For example, to find x, given y = 1.5, on the Home or CAS screen, enter f1_xy('x', 1.5), which returns {-1.0611, 1.7278}. Using f1_xy(x, 1.5) on the Home or CAS screen will return [[ ]]. C. Adding a purge statement to create the cas variable x To make the program automatically create a CAS variable x, you can add a purge statement to the program, as shown below. However, the program will only create the x variable, when the program is run on the CAS screen. So, before you can run the program on the Home screen, you must first run the program on the CAS screen. CAS will create the variable x, which can be verified by using the Vars key. Now, the program can be run on the Home screen. Code: #cas D. Use system variable X as the solve variable Alternatively, the system variable X can be used as the solve variable. The system variable X already exists, so it will not generate a syntax error when running the program on the Home screen. The system variable X is a real variable, and it seems to work fine with solve in the CAS program. The only change is that the user must input 'X' instead of 'x'. So, the program below works on both the Home and CAS screens. Code: #cas |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Program code with solve function - SoxxoZ - 06-19-2024, 02:23 PM
RE: Program code with solve function - gehakte_bits - 06-20-2024, 10:04 PM
RE: Program code with solve function - Gene222 - 06-25-2024, 08:17 PM
RE: Program code with solve function - Gene222 - 06-26-2024 04:10 AM
RE: Program code with solve function - Gene222 - 06-27-2024, 10:30 AM
RE: Program code with solve function - Gene222 - 06-28-2024, 05:54 PM
RE: Program code with solve function - ftneek - 06-29-2024, 02:28 AM
RE: Program code with solve function - Gene222 - 06-29-2024, 04:31 PM
RE: Program code with solve function - gehakte_bits - 06-21-2024, 02:13 PM
RE: Program code with solve function - Gene222 - 07-09-2024, 09:19 PM
|
User(s) browsing this thread: 2 Guest(s)