|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Substitutes a value for a variable temporarily.
expression
Menu Location
Press the
This command works on all calculators.
1 byte
The | operator (which nobody seems to know how to pronounce, although TI suggests "with") temporarily sets a variable to some value, just for a single evaluation. For example:
:x^2+2x+1|x=5
6Using the | operator doesn't actually affect the value of the variable. However, it will work both if the variable is undefined, and if the variable already has a different value.
Only one | can occur in a single expression: if you have more, this will either cause an error or ignore all but the first substitution, depending on placement. However, one | is enough for any number of variables: just separate the values to use with and:
:x+y|x=2 and y=2
4Advanced Uses
The | operator has a more complicated use: rather than giving a specific value for a variable, you might give a condition (or several conditions) for its value, using the >, ≥, <, and ≤ operators. This condition will be used if it helps simplify the expression, especially with solve(). For instance:
:abs(x)|x<0
-xWeird things can happen if you do this to a variable whose value is already defined, however:
:5→x
5
:abs(x)|x<0
|undef|Optimization
If a complicated expression has a repeating element, you may be able to make the calculation smaller and faster by replacing this repeating element with a variable, for which you substitute the correct value. For example (here the repeating element is √(1-x^2)):
:x√(1-x^2)+tanֿ¹(x/√(1-x^2))
can be
:x*a+tanֿ¹(x/a)|a=√(1-x^2)A related trick is to make a substitution with a function, for an operation that has to be done several times in a single line. For example:
:a*(a-1)/2+b*(b-1)/2+c*(c-1)/2
can be
:f(a)+f(b)+f(c)|f(x)=x*(x-1)/2Error Conditions
200 - Constraint expression invalid happens when the condition doesn't make sense to the calculator.
