Using Variables. Texas Instruments TI-NSPIRE CAS, TI-Nspire CX, TI-nspire CX CAS, TI-Nspire
जाहिरात
जाहिरात
Using Variables
A variable is a defined value that can be used multiple times in a problem. You can define a value or function as a variable within each application. Within a problem, variables are shared by
TI-Nspire™ applications. For example, you can create a variable in
Calculator, then use or modify it in Graphs & Geometry or Lists &
Spreadsheet within the same problem.
Each variable has a name and a definition and the definition can be changed. When you change the definition, all occurrences of the variable in the problem are updated to use the new definition. In the TI-Nspire™ software, a variable has four attributes:
• Name - User-defined name assigned when the variable is created.
• Location - Variables are stored in memory.
• Value - Number, text, mathematical expression, or function.
• Type - Type of data that can be stored as a variable.
Note: Variables created with the
Local
command within a user-defined function or program are not accessible outside that function or program.
Linking values on pages
Values and functions created or defined in one application can interact with other applications (within the same problem) to share data.
When using linked items, keep in mind:
• Values can be linked between applications on one page or between different pages of the same problem.
• All applications are linked to the same data.
• If the linked value is changed in the original application, the change is reflected in all linked usages.
Defining a variable is the first step in linking values.
Creating variables
Any portion or attribute of an object or function created within an application can be stored as a varible. Examples of attributes that can become variables are the area of a rectangle, the radius of a circle, the value contained in a spreadsheet cell or the contents of a row or column, or a function expression. When you create a variable, it is stored in memory.
Using Variables 425
Types of variables
You can store the following data types as variables:
Data type
Expression
Examples
2.54
1.25
E6 2 p xmin/10 2+3i (x
N2)
2
List {2, 4, 6, 8} {1, 1, 2} {"red", "blue", "green"}
Matrix
1 2 3
3 6 9
This can be entered as:
[1,2,3;3,6,9]
Character string “Hello”
Function, program myfunc( arg )
“xmin/10” “The answer is:” ellipse( x, y, r1, r2 )
Measurement area, perimeter, length, slope, angle
When you click or press h
on a handheld to open the list of stored variables, a symbol indicates the type.
Creating a variable from a Calculator value
This example shows how to create a variable using a handheld. Complete the following steps to create a variable named
num and store the result of the expression 5+8
3
in that variable.
1. On the Calculator entry line, type the expression
5+8^3
.
2. Press
¢
to expand the cursor to the baseline.
426 Using Variables
3. Press
/ h
and then type the variable name
num
.
This means: Calculate 5+8
3
and store the result as a variable named
num.
4. Press
·
.
Calculator creates the variable
num and stores the result there.
Creating a variable in the computer software
When creating a variable in the computer software, use the following conventions. As alternatives to using
&
(store), you can use “
:=
” or the
Define
command. All of the following statements are equivalent.
5+8
3 &
num
num := 5+8
3
Define
num=5+8
3
Checking a variable’s value
You can check the value of an existing variable by entering its name on the Calculator entry line. When you type the name of a stored variable, it appears in bold type.
` On the Calculator entry line, type the variable name
num
and press
·
.
The value most recently stored in
num
displays as the result.
Automatically creating variables in Graphs & Geometry
In the Graphs and Geometry applications, functions defined on the entry line are automatically stored as variables.
Using Variables 427
In this example,
f1(x)=x
3
is a variable definition, which allows it to be displayed in other applications including a table in the Lists &
Spreadsheet application.
Creating a variable from a Graphs & Geometry value
1. Click to select the value to store as a variable.
2. Click .
Handheld: Press h
.
The Variables options are displayed with
Store Var
highlighted.
3. Press
·
. VAR := appears before the selected value. This is the default name.
428 Using Variables
4. Replace the default name VAR with the variable name you want to give the value.
5. When the variable name is typed, press
·
.
The value is saved to that variable name, and the stored value or its name appears in bold text to indicate it is a stored value.
Note: You can also share a Graphs & Geometry axis end value with other applications. If necessary, click
Actions
,
Show/Hide Axes End Values
to display the end values on the horizontal and vertical axes. Click the number for an end value to highlight it in the entry field. Name the variable and store it for use with other applications by using any method described in Step 2.
Automatically creating variables in Lists & Spreadsheet
Naming a list at the top of a Lists & Spreadsheet column automatically stores that value as a list variable. This variable can be used in other applications including Data & Statistics.
Using Variables 429
Creating a variable from a Lists & Spreadsheet cell value
You can share a cell value with other applications. When defining or referring to a shared cell in Lists & Spreadsheet, precede the name with an apostrophe (‘).
1. Click the cell that you want to share.
2. Click to open the Variables menu.
Handheld: Press h
.
3. Select
Store Var
.
A formula is inserted into the cell with
var as a placeholder for a variable name.
4. Replace the letters “
var” with a name for the variable, and press
·
.
The value is now available as a variable to other applications within the same problem.
Note: If a variable with the name you specified already exists in the current problem space, Lists & Spreadsheet displays an error message.
430 Using Variables
Using (linking) variables
Sharing, or linking, the variables you create is a powerful tool for math exploration. The display of linked variables is automatically updated when the variable’s value changes.
Linking to shared variables
To use a stored variable:
1. Display the page and select the location or object to which you want to link a variable.
2. Select the Variables tool h
.
The Variables options are displayed. The software knows which types of variables will work in the location or with the object selected and will only display those variables.
3. Use
9 and : to scroll the list, or type part of the variable name.
As you type, the system displays a list of variables that begin with the letters you typed. Typing part of the name enables you to locate a variable more quickly if the list is long.
4. When you locate and highlight the name of the variable you want to use, click the name or press
·
.
The selected variable value is linked.
Linking a Lists & Spreadsheet cell to a variable
When you link a cell to a variable, Lists & Spreadsheet keeps the cell value updated to reflect the current value of the variable. The variable can be any variable in the current problem and can be defined in Graphs
& Geometry, Calculator, or any instance of Lists & Spreadsheet.
Note: Do not link to a system variable. Doing so could prevent the variable from being updated by the system. System variables include
ans,
StatMatrix, and statistics results (such as RegEqn, dfError, and Resid).
1. Click the cell that you want to link to the variable.
2. Open the VarLink menu:
– Click ,
Cell
.
–
Handheld:
Press h
.
The VarLink menu displays.
Using Variables 431
3. Under
Link To
, scroll to the name of the variable and click it.
The cell shows the value of the variable.
Using a variable in a calculation
After storing a value in a variable, you can use the variable name in an expression as a substitute for the stored value.
1. Enter the expression:
– Type
4*25*num^2
on the entry line, and press
Enter
.
–
Handheld:
Type
4
r
25
r
num^2
on the entry line, and press
·
.
Calculator substitutes 517, the value currently assigned to
num, and evaluates the expression.
2. Enter the expression:
– Type
4*25*nonum^2
, and press
Enter
.
–
Handheld:
Type
4
r
25
r
nonum^2
on the entry line, and press
·
.
CAS: Because the variable
nonum has not been defined, it is treated algebraically in the result.
Because the variable
nonum has not been defined, the expression returns an error message.
Entering multiple statements on the entry line
To enter several statements on a single line, separate them with a colon
(“:”). Only the result of the last expression is shown.
432 Using Variables
Setting variable values with a slider
In the Graphs and Geometry applications, a slider control lets you adjust or animate the assignment of values for a numeric variable. Use a slider to represent multiple variable values in a continuous range.
1. From the Document Tools menu, select
Actions > Insert Slider.
Handheld: Press b 1
A
to insert a slider.
The slider displays on the work area. If you need to adjust or animate value selection for more than one variable, you can repeat this step and insert multiple sliders.
Note: You can access the context menu to Pin a slider to its location and prevent unintentional movement.
2. Click the slider to activate it and press e
to move between the slider scale and the variable’s value.
3. Use
¡
and
¢
to move the slider on the scale.
4. Press
Enter
to select the value.
Access the context menu and choose
Settings
to view or change the default slider settings.
Naming variables
Variable and function names that you create must meet the following naming rules.
Note: In the unlikely event that you create a variable with the same name as one used for statistical analysis or by the Finance Solver, an error condition could occur. If you begin entering a variable name that is already in use in the current problem, the software shows the entry in
bold
to let you know.
• Variable names must be in one of the forms
xxx or xxx.yyy. The xxx part can have 1 to 16 characters. The
yyy part, if used, can have 1 to 15 characters. If you use the
xxx.yyy form, both xxx and yyy are required; you cannot start or end a variable name with a period “.”
Using Variables 433
• Characters can consist of letters, digits, and the underscore character
(_). Letters can be U.S. or Greek letters (but not
Π or p), accented letters, and international letters.
• Do not use
c
or
n
from the symbol palette to construct a variable name such as
c1
or
n12
. These may appear to be letters, but they are treated internally as special symbols.
• You can use uppercase or lowercase letters. The names
AB22, Ab22,
aB22, and ab22 all refer to the same variable.
• You cannot use a digit as the first character of
xxx or yyy.
• Do not use spaces.
• If you want a variable to be treated as a complex number, use an underscore as the last character of the name.
• CAS: If you want a variable to be treated as a type of unit (such as
_m or
_ft), use an underscore as the first character of the name. You cannot use subsequent underscores in the name.
• You cannot use an underscore as the first character of the name.
• You cannot use a preassigned variable, function, or command name, such as
Ans
,
min
, or
tan
.
Note: For a complete list of TI-Nspire™ functions, refer to the
Reference Guide.
• Library documents and library objects are subject to additional naming restrictions. For details, see the “Libraries” section of the documentation.
Here are some examples:
Variable names
Myvar, my.var
My var, list 1 a, b, c
Log, Ans
Log1, list1.a, list1.b
3rdTotal, list1.1
Valid?
Yes
No. Contains a space.
Yes
No. Preassigned to a system function or variable.
Yes
No.
xxx or yyy starts with a digit.
434 Using Variables
Locking and unlocking variables
Locking lets you protect variables from modification or deletion. Locking prevents unintended changes to a variable.
Time and altitude lists can be locked to ensure problem fidelity
Reference function
f1
can be locked to prevent unintended change
Variables you cannot lock
• System variable
Ans
•
stat. and tvm. variable groups
Important information about locked variables
• To lock variables, use the Lock command.
• To modify or delete a locked variable, you must first unlock the item.
• Locked variables display a lock icon on the variable menu list.
• The Lock command clears the Redo/Undo history when applied to unlocked variables.
Examples of locking
Lock a,b,c
Locks application.
Lock mystats
. Locks all members of variable group
mystats.
UnLock func2
Unlocks
lm:=getLockInfo(var2)
Retrieves the current lock status of
var2 and assigns that value to
lm in the Calculator application.
For details about
Lock
,
UnLock
, and
getLockInfo()
, refer to the
Reference Guide section of the documentation.
Using Variables 435
Updating a variable
If you want to update a variable with the result of a calculation, you must store the result explicitly.
Comment Entry a := 2 a
3
a a := a
3
a a
2
&
a a
2
8
Result
2
8
8
64
64
Result not stored in variable
a.
Variable
a updated with result.
Variable
a updated with result.
Reusing the last answer
Each instance of Calculator automatically stores the last calculated result as a variable named Ans. You can use Ans to create a chain of calculations.
Note: Do not link to Ans or any system variable. Doing so could prevent the variable from being updated by the system. System variables include statistics results (such as
Stat.RegEqn, Stat.dfError, and Stat.Resid) and
Finance Solver variables (such as
tvm.n, tvm.pmt, and tvm.fv).
As an example of using Ans, calculate the area of a garden plot that is 1.7 meters by 4.2 meters. Then use the area to calculate the yield per square meter if the plot produces a total of 147 tomatoes.
1. Calculate the area:
– On the Calculator entry line, type
1.7*4.2
, and press
Enter
.
–
Handheld:
On the Calculator entry line, type
1.7
r
4.2
, and press
·
.
2. Reuse the last answer to calculate the yield per square meter:
– Type
147/ans
, and press
Enter
to find the yield.
–
Handheld:
Type
147
p
ans
, and press
·
to find the yield.
436 Using Variables
3. As a second example, calculate and then add
2*log(45)
.
– Type
3.76/(-7.9+sqrt(5))
, and press
Enter
.
–
Handheld:
Type
3.76
p
(
v
7.9+sqrt(5))
, and press
·
.
4. Reuse the last answer:
– Type
ans+2*log(45)
, and press
Enter
.
–
Handheld:
Type
ans+2
r
log(45)
, and press
·
.
Temporarily substituting a value for a variable
Use the “|” (such that) operator to assign a value to a variable for just a single execution of the expression.
Removing a linked variable
1. Select the linked variable.
2. Press h
.
The Variables options display.
3. Select
Unlink
.
The link is removed from the value, and the value displays without any bolding.
Using Variables 437
438 Using Variables
डाउनलोड
जाहिरात