The piecewise( Command
piecewise(.png

Command Summary

Graphs up to 5 piecewise expressions.

Command Syntax

(expression, condition [,expression, condition])

Up to 5 (expression,condition) pieces are allowed.

Menu Location

1: While editing a program, press [math]

2: Then press [alpha] [apps] (B) or scroll down.

Calculator Compatibility

TI-84+CE OS 5.3

Token Size

2 bytes

The piecewise( command is a new addition in the release of OS 5.3 for the TI-84 Plus CE. As implied, it allows for the graphing of piecewise functions in the Y= editor. The example code demonstrates how this works from within a program.

:ClrDraw
:Input "Y1=",Str1
:Input "Y2=",Str2
:Str1→Y1
:Str2→Y2
:FnOff
:"piecewise(Y1,X≥0,Y2,X<0→Y3
:DispGraph

Advanced Uses

One use of the piecewise( function is to evaluate an expression for a given value of X. For example:

:piecewise(X²+2,X≥0

This code will return the value of the expression if X≥0. So if X=0, then the program will return a value of 2. If X=3, it will return a value of 11. If X=-5, it will return an error.

Optimization

This section includes both ways to optimize use of the command, and other common pieces of code that this command can replace in an optimization. Make sure to mention if the optimization improves speed of the program, size, or both. Sample code should be included too, preferably in the following format:

:unoptimized code
can be
:optimized code

Error Conditions

  • ERR:INVALID is thrown if expressions are not defined.
  • ERR:DATA TYPE is thrown if a quotation mark is not placed before a piecewise command that is to be stored to an equation variable.

Related Commands

Several (around 3) commands have a similar function or are used in a similar context to this command. Make a bulleted list of them, with links to the other commands' pages. It will often be the case that several commands all link to each other.

  • Command 1
  • Command 2
  • Command 3

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.